Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.

Slides:



Advertisements
Similar presentations
Exercise 1: Install PC Software & NXT Firmware
Advertisements

Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
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.
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
Graphical RobotC NXT (EV3) Robot Workshop 2015 Instructor: Dr. Fred Brauchler Assistant: Chris Parker 2/7/2015Lawrence Technological University1.
Automation and Robotics
Developed in collaboration with Introduction to Programming.
Robot C Ready, SET, Go! Workshop SDSU, Fall 2013.
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
Introduction to Sensors
Introduction to NXT Software and Functionality Bot’oberfest October 15, 2007.
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
The NXT is the brain of a MINDSTORMS® robot. It’s an intelligent, computer-controlled LEGO® brick that lets a MINDSTORMS robot come alive and perform.
LEGO Mindstorms NXT Programming We will be using the Common Palette for our Robots This is how you download your program onto the brick Drag and drop a.
While Loops and Do Loops. Suppose you wanted to repeat the same code over and over again? System.out.println(“text”); System.out.println(“text”); System.out.println(“text”);
2008 – 2009 Team Unlimited (FTC # 1) Coding for the FIRST Tech Challenge NXT/G, LabVIEW & RobotC compared, and a Crash Course in RobotC Presented by Team.
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.
LEGO NXT Robot Programming Introduction to Programming a Lego NXT robot in Java.
ROBOTC for VEX On-Site Professional Development
Coding for the FIRST Tech Challenge: RobotC
The New FTC Platform (Connecting your legacy hardware)
Robot C Set-up FTC Clinic Nov Patrick Michaud & RobotC Curriculum
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
AUTOMATION WITH ROBOTC Starting to write and troubleshoot computer code.
Lego MindStorm An Introduction to Blocks. Blocks Blocks are used to give instructions to your robot. There are many types of blocks You can use the blocks.
Castor Bot. Now, we will begin creating a robot Log onto your computer On your screen, click on the website labeled “castor bot” Your building instructions.
Session 11 Intro to FRC API.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
ROBOTC Software EV3 Robot Workshop
ROBOTC Software EV3 Robot Workshop Lawrence Technological University.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Vex Robotics program three: using motors and sensors together.
Testbed Coding In this activity you will code different challenges for the Testbed. For each challenge a sample program is shown. Use what this sample.
Programming Basics - RobotC Introduction to Robotics.
Testbed Coding In this activity you will code different challenges for the Testbed. For each challenge a sample program is shown. Use what this sample.
© 2006 Carnegie Mellon Robotics Academy Designed for use with the LEGO MINDSTORMS ® Education NXT Software and Base Set #9797 Sentry System Two-Way Communication.
After Construction Name: Per #:.
Introduction to Programming in RobotC
OpModes in FTC Eric Golde.
Branching Error (a.k.a. the VM Program Instruction Break Error)
Variables and Functions
Mindstorms EV3 Programming
Introduction to Programming
ROBOTC for VEX Online Professional Development
Mindstorms EV3 Programming
Programming – Touch Sensors
Mindstorms EV3 Programming
Variables and Functions
Variables and Functions
Automation and Robotics
Variables and Functions
Controlling your quadcopter
Programming Basics - RobotC
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
Programming - Buttons Intro to Robotics.
Automation with RobotC
Programming - Buttons Intro to Robotics.
Robotics Programming Using Shaft Encoders
While Loops and If-Else Structures
RobotC Programming for LEGO Mindstorms NXT
Automation with RobotC
While Loops and If-Else Structures
While Loops And If-Else Structures
Controlling your quadcopter
Introduction to Programing the Cortex for BEST
Presentation transcript:

Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001

Why RobotC?  Speed  RobotC runs quicker on the NXT  Differences in speed are small until larger code is written  Control  In RobotC you have control over almost everything  Real Time Debugger to allow viewing of code line by line while running  Personal Preference  Text base control  Advanced math functions  Team Decision RobotC

Hardware Review  Servo  Can only go 180 degrees  In code, it is from 0 to 255  DC Motor  Continuous  Controlled by power rather than degree (+100 forward to -100 backward) RobotC °

Plan the Code  Get a diagram of the field  Draw the general routine w/ arrows and numbers  Make side notes noting what happens at each time interval  Start your first draft of the code RobotC

Coding Basics Comments:  “//” is used as a line comment  “/*” is the beginning of a group comment  “*/” ends a group comment  Comments never affect the function of code  Always comment code so your team members understand it! Example: RobotC

Dead Reckoning vs. Sensing  Dead Reckoning  A prewritten routine  Code flows A to B to C  If interrupted, will only try to continue  Easier to write  Sensing  Routine that can adapt  Code flows, but can respond  If interrupted, can attempt to correct  More complicated RobotC

Reacting to the Environment  Sense the world and react to it  Touch switch is pressed, against something  Ultrasonic rapidly changes, something crossed paths  Light sensor spikes, on a line or off a line  Useful to be able to change course  Code “thinks” for itself  Only as smart as YOU code it! RobotC

Flow of the Code  Flow from place to place  DON’T JUMP ALL OVER THE PLACE!  Structure the code ahead of time, plan it out  Make things easy to fix  Make your code neat and clean  Plan the code out ahead of time  Don’t haphazardly place code in  Order your code  Do you want an interrupt?  Is there an importance to the steps? RobotC

Commenting  Use comments to remind yourself  Often you will forget why something is in the code  Explains to the JUDGES what you were thinking  Allows for easy corrections  Write complete thoughts  “Checks for a touch sensor being pressed, if not, continue”  Use them LIBERALLY RobotC

RobotC Home Screen RobotC

RobotC Basics  Make sure you are on version 3.00  If not, uninstall RobotC COMPLETELY before installing the newest version  Use the Sample codes included in RobotC  Access by File > Open Sample Programs  Save RobotC files in separate location on Hard Drive  Download and watch coding presentations at Robotics Academy RobotC

Connect NXT RobotC

Select NXT Brick RobotC

Selecting the Firmware RobotC

Download and Complete  Make sure this message appears before exiting RobotC

Rename NXT RobotC

Name Your NXT  Type in the name for your NXT (default is NXT)  Recommended name is your team number to four digits (i.e FTC #0001 is 0001  If you have more than one NXT, place an A, B, etc. after the number RobotC

Connecting to Bluetooth 1. Go to Robot > NXT Brick > Link Setup RobotC

Connecting to Bluetooth RobotC 2. Make sure that this box is checked to perform a bluetooth search 2. Select here to make a pair between the NXT and your laptop

Bluetooth at the Competition  Take from the Field Preparation Guide (you can find it here) here  Remember to always do these steps at the Playing Field RobotC

Bluetooth at the Competition RobotC

RobotC Menu  Compile and Download  Compiles and downloads  Compile Program  Compiles locally  Debugger  Scans code for errors  Motor & Sensor Setup  Set up Motor and Sensors  Download firmware  Download firmware to NXT RobotC

RobotC Menu  Link Setup  Used to establish a link between NXT and Computer  Poll Brick  “Online Window”  File Management  Manage files on the NXT  Joystick Control  “FTC Controller Station” RobotC

RobotC Debugger  Allows for program control wirelessly  Allows to view where the code is currently  Allows to view errors in your code while running RobotC

RobotC Debugger Buttons  Start/Stop – Starts or Aborts Program  Suspend – Pauses code  Step Into – Pauses code and proceeds to next line  Step Over – Pauses code and skips over next procedure  Step Out - Pauses code and exits procedure  Clear All – Resets all values to default  Refresh Rate  Once – Refreshes values manually  Continuous/Stop – Switch between continuous and stop updating RobotC

RobotC Debugger Joystick Control  “FTC Controller Station”  Allows control over Teleoperator and Autonomous  Views controller data RobotC

RobotC “Loops”  While statement  Performs code as long as the statement is true  I.e. while (ServoValue[Servo1] < 255)  If statement  Performs entirety of code if statement is true  I.e. if (sensorValue[Touch] == 0)  Else statement  Performs entirety of code if “If Statement” is false  i.e. else RobotC

RobotC Punctuation  Brackets { }  Used to control flow of code  Semicolons ;  Used after lines to denote an end  Square Brackets [ ]  Used for sensors and motor declarations  Parenthesis ()  Used for time and math functions RobotC

RobotC Operators RobotC  == (test a condition)  i.e. while (sensorValue[Touch] == 0)  = (equals)  i.e. motor[motorD] = 0;  (less than, greater than)  i.e. if ( -10 < joystick.joy1_y1 < 10 )  || (or)  i.e. if ( joy1Btn(1) || joystick.joy2_TopHat == 0 )

RobotC Commenting  // TEXT  Comments out a single line of text  /* TEXT */  Comments out all text within the /* and */  /*  Comments out all text after RobotC

RobotC Simple Program RobotC

Sample Code  FTC Template  Joystick Control  DC Drive Motor sample  NXT Motor sample  Servo sample  Touch Sensor sample  Light Sensor sample  Ultrasonic Sensor sample  Compass Sensor sample RobotC

Teleop Template RobotC

Autonomous Template RobotC

Joystick Control Sample RobotC

DC Motor Sample RobotC

NXT Motor Sample RobotC

Servo Sample RobotC

Touch Center Sample RobotC

Light Sensor Sample RobotC

Light Sensor Sample RobotC

Ultrasonic Sensor Sample RobotC

Compass Sensor Sample RobotC

Field Diagram RobotC

RobotC Resources  RobotC RobotC  RobotC Forums RobotC Forums RobotC Forums  Robotics Academy Robotics Academy Robotics Academy  FTC Function Guide (From Robotics Academy) FTC Function Guide FTC Function Guide  Setting up Dual Template Mode Setting up Dual Template Mode Setting up Dual Template Mode  Field Procedures for Bluetooth Field Procedures for Bluetooth Field Procedures for Bluetooth  Software Information (Links at our website) Software Information Software Information  Code and Software Presentation Code and Software Presentation Code and Software Presentation RobotC

RobotC Resources  RobotC Sample code  Program files > Robotics Academy > RobotC for Mindstorms > Sample Programs > NXT  File > Open Sample Programs (if RobotC is open) RobotC

Coding for the FIRST Tech Challenge: RobotC Questions?

Programming Structures  Clean code  Readable to humans  Comment and Methods  Reiteration RobotC

Variables  What are variables?  They are things you store in the program that you may want to use  How are they made?  They are made according to their ‘types’ eg. Integer (int)  Example Structure: int apple = 0;  If they occur outside { } of any methods, they are instance variables RobotC

Variables Continued…  Variables are ‘alive’ only in the highest method they are in  ‘Dead’ Variables can be used again  Eg. Void appleCount { int apple = 3; } Void pearCount{ int apple = 4 } RobotC

Variables continued…  So why have different variable names?  To avoid confusion! RobotC

Camel Casing  thisIsCamelCasing  Capitalizing the first letter of a word in a sentence starting from the second word  Looks like camel humps  Why?  Not to confuse with other commands  Camel Casing is used for variables you make RobotC

For Loop  Does the loop for a specific number of times  Known repeat number  Structure: for(int i=0; i< (number of times you want to repeat it; i++){ //code } RobotC

While Loop  Want to repeat it  Unknown number of times of repeat  Example Structure: while ( sensorVal < 100){ // code } RobotC

If … Else… Statements  If something is true, do this, or else do something else  Example Structure: if ( sensorVal == 4){ //code for dance happy dance } else{ //code for go forward } RobotC

Methods  What are methods?  Methods are things that you can call to do over and over again (eg. Move forward 5 cm)  Why use methods?  Reiteration  Robot Code example (activity)  Example Structure: void danceRobotDance{ // make robot dance } RobotC