Programming Basics - RobotC Introduction to Robotics.

Slides:



Advertisements
Similar presentations
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Advertisements

Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Automation and Robotics
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
Robot Programming. Programming Behaviors Behaviors describe the actions and decisions of your robot.
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Vex 1.0 © 2005 Carnegie Mellon Robotics Academy Inc. Programming in easyC.
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
Introduction to a Programming Environment
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
Testbed: Exercises.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Chapter 2 How to Compile and Execute a Simple Program.
Topics Introduction Hardware and Software How Computers Store Data
Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Coding for the FIRST Tech Challenge: RobotC
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Introduction to programming in the Java programming language.
Introduction to Computer Programming
Identifiers Identifiers in Java are composed of a series of letters and digits where the first character must be a letter. –Identifiers should help to.
Programming Fundamentals. Thinking about Programming Robots are made to perform useful tasks. Each robot is designed to solve a specific problem, in a.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Getting Started in RobotC // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run Take out your notes.
Agenda Computer Languages How to Write a Simple C Program
Robot Programming. Programming Behaviors Behaviors describe the actions and decisions of your robot.
CPS120: Introduction to Computer Science Introduction to C++
Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
CS 177 Recitation Week 1 – Intro to Java. Questions?
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
Introduction to Computing Systems and Programming Programming.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Alice and Java Unit 7 1. Day 1  Objective: Gain an introduction to Java and Eclipse  Essential skill: DM-1: Use technology to advance critical thinking.
Bot Shop Jane Taylor Dee Wallace Robot C For Vex.
Programming Design ROBOTC Software. Behavior-Based Programming A behavior is anything your robot does –Turning on a single motor or servo Three main types.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Robotics Education & Competition Foundation
CSC201: Computer Programming
Lecture 1 Introduction Richard Gesick.
Chapter 3 GC 101 Java Fundamentals.
Programming - Motion Intro to Robotics.
TRANSLATORS AND IDEs Key Revision Points.
Getting Started in RobotC
Automation and Robotics
Graph Paper Programming
Graph Paper Programming
Getting Started in RobotC
Topics Introduction Hardware and Software How Computers Store Data
Programming Basics - RobotC
Programming Fundamentals
ICT Programming Lesson 1:
ICT Gaming Lesson 2.
CPS120: Introduction to Computer Science
RobotC Programming for LEGO Mindstorms NXT
Week 1 - Friday COMP 1600.
Presentation transcript:

Programming Basics - RobotC Introduction to Robotics

Thinking about Programming Creating a successful robot takes a team effort between humans and machines. Role of the Robot The robot follows the instructions it is given, thereby carrying out the plan.

Human/Machine Communication Because humans and robots don’t normally speak the same language, a special language must be used to translate the necessary instructions from human to robot. These human-to- robot languages are called programming languages. Instructions written in them are called programs. ROBOTC is just one of many such programming languages that humans use to talk to machines.

Think about “Behaviors” Behaviors are a convenient way to talk about what a robot is doing and what it must do. Moving forward, stopping, turning, looking for an obstacle… these are all behaviors. Complex Behavior Some behaviors are big, like “solve the maze.” Basic or Simple Behavior Some behaviors are small, like “go forward for 3 seconds.” Big behaviors are actually made up of these smaller ones.

Planning the Behaviors

PSUEDOCODE As the programmer becomes more experienced, the organization of the behaviors in English will start to include important techniques from the programming language itself, like if-else statements and loops. This hybrid language, halfway between English and the programming language, is called pseudocode.It is an important tool in helping to keep larger programs understandable.

ROBOTC is text based! Commands to the robot are first written as text on the screen. They are then processed by the ROBOTC compiler into a machine language file that the robot can understand. Finally, they are loaded onto the robot, where they can be run.

Code Text written as part of a program is called code. You type code just like you type normal text. Keep in mind that capitalization is important to the computer. Replacing a lowercase letter with a capital letter (or a capital letter with a lowercase letter) will cause the robot to become confused.

Code COLOR As you type, ROBOTC will try to help you out by coloring the words it recognizes. If a word appears in a different color, it means ROBOTC recognizes it as an important word in the programming language.

Statements Statements are instructions for the robot. The most basic kind of statement in ROBOTC simply gives a command to the robot. The motor[port3] = 127; statement in the sample program you downloaded is a simple statement that gives a command. It instructs the motor plugged into Motor Port 3 to turn on at full power.

Order the Statements Statements are run in order as quickly as the robot is able to reach them. Running this program on the robot turns the motor on, then waits for 3000 milliseconds (3 seconds) with the motor still running, and then ends.

RobotC Rules How did ROBOTC know that motor[port3]= 127 and wait1msec[3000] were two separate commands. Was it because they appeared on two different lines? No. Spaces and line breaks in ROBOTC are only used to separate words from each other in multi-word commands. Spaces, tabs, and lines don’t affect the way a program is interpreted by the machine.

ROBOTC Rules So why ARE they on separate lines? For the programmer. Programming languages are designed for humans and machines to communicate. Using spaces, tabs, and lines helps human programmers read the code more easily. Making good use of spacing in your program is a very good habit for your own sake.

Punctuation! But what about ROBOTC? How DID it know where one statement ended and the other began? It knew because of the semicolon (;) at the end of each line. Every statement ends with a semicolon. It’s like the period at the end of a sentence.

Punctuation Pairs Punctuation pairs, like the parentheses and square brackets in these two statements, are used to mark off special areas of code. Every punctuation pair consists of an opening punctuation mark and a closing punctuation mark. The punctuation pair designates the area between them as having special meaning to the command that they are part of.

Punctuation Pairs Different commands make use of different kinds of paired punctuation. The motor command uses square brackets and the wait1Msec command uses parentheses. This is just the way the commands are set up. You will have to remember to use the right punctuation with the right commands or plan.

Control Structures Simple statements do the work in ROBOTC, but control structures do the thinking. Control structures (or control statements) are pieces of code that control the flow of the program’s commands, rather than issue direct orders to the robot. One important control structure is task main. Every ROBOTC program includes a special section called task main. This control structure determines which code the robot will run as part of the main program.

Control Structures

Comments Comments are text that the program ignores. A comment can contain notes, messages, and symbols that may help a human, but would be meaningless to the robot. ROBOTC simply skips over them. Comments appear in green in ROBOTC.