Programming Basics - RobotC

Slides:



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

Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
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
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
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.
Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Introduction to programming in the Java programming language.
Programming Fundamentals. Thinking about Programming Robots are made to perform useful tasks. Each robot is designed to solve a specific problem, in a.
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
CPS120: Introduction to Computer Science Introduction to C++
Vex Robotics Program four: reversing and turning.
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.
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.
Programming Basics - RobotC Introduction to Robotics.
Bot Shop Jane Taylor Dee Wallace Robot C For Vex.
Robotics Education & Competition Foundation
After Construction Name: Per #:.
Programming Design ROBOTC Software Principles Of Engineering
Binary Representation in Text
Introduction to Programming in RobotC
INTRODUCTION TO ROBOTICS Part 5: Programming
AP CSP: Creating Functions & Top-Down Design
JavaScript/ App Lab Programming:
Programming Languages
CSC201: Computer Programming
Lecture 1 Introduction Richard Gesick.
Topics Introduction Hardware and Software How Computers Store Data
Chapter 3 GC 101 Java Fundamentals.
Introduction to Programming
Chapter 2, Part I Introduction to C Programming
Programming Mehdi Bukhari.
UNIT 3 – LESSON 5 Creating Functions.
The Need for Programming Languages
Programming - Motion Intro to Robotics.
Problem Solving (design of programs) CS140: Introduction to Computing 1 8/26/13.
TRANSLATORS AND IDEs Key Revision Points.
Getting Started in RobotC
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
Automation and Robotics
Graph Paper Programming
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
Number and String Operations
Graph Paper Programming
Getting Started in RobotC
Topics Introduction Hardware and Software How Computers Store Data
Creating your first C program
Programming Fundamentals
Hour of Code.
Programming Design ROBOTC Software Principles Of Engineering
Automation with RobotC
ICT Programming Lesson 1:
ICT Gaming Lesson 2.
Tonga Institute of Higher Education IT 141: Information Systems
CPS120: Introduction to Computer Science
Tonga Institute of Higher Education IT 141: Information Systems
RobotC Programming for LEGO Mindstorms NXT
Automation with RobotC
Basic Concepts of Algorithm
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
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. Basic or Simple Behavior Some behaviors are small, like “go forward for 3 seconds.” Big behaviors are actually made up of these smaller ones. Complex Behavior Some behaviors are big, like “solve the maze.”

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.