Getting Started in RobotC

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.
Automation and Robotics
Developed in collaboration with Introduction to Programming.
Using the NXT Light Sensor. 2 Connect One Light Sensor – 1 From My Files use Left / Right NXT buttons and get to View menu and push Orange button. From.
V EX C OACHES ' T RAINING October 12, Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.
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.
Available at: – Program Optical Quad Encoders in Autonomous Mode Program optical quad encoders in autonomous mode.
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:
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.
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.
Programming Design ROBOTC Software Principles of Engineering
Autonomy using Encoders Intro to Robotics. Autonomy/Encoders Forward for Distance In this unit, you will learn to use the encoders to control the distance.
Find the Mindstorms Icon on the computer.. To start a new program click go.
Getting Started in RobotC // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run Take out your notes.
Vex Robotics Program four: reversing and turning.
Automated Mechanisms Help. Potentiometers Potentiometer Check –Analog Port 2 How they work –Analog sensor –Measures rotation of a shaft between 0 and.
RobotC Remote Control. Learning Objectives: Focusing on Virtual World with Physical Examples Understand Real-Time Joystick Mapping Understand how to use.
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.
ROBOTC Software EV3 Robot Workshop
Programming your Robot
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Vex Robotics Program Two: Using two motors. Program two: using the motors In the last section, you learned how to turn on one motor. Now, you will take.
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.
ROBOTC for VEX Robotics (VEX IQ) On-Line Session 2014 My name is Jason McKenna I will be leading you through these sessions Teacher for 17 years Hopewell.
Mechanical Components and Programming Ken Youssefi Introduction to Engineering – E10 1.
Programming Basics - RobotC Introduction to Robotics.
Bot Shop Jane Taylor Dee Wallace Robot C For Vex.
Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance.
Introduction to Programming
Understanding Communication with a Robot? Activity (60 minutes)
SuperQuest Salem Motion.
Robotics Programming Using Shaft Encoders
Copyright © 2008 by Helene G. Kershner
StartStruck in a Virtual World
Automation and Robotics
StarStruck in a Virtual World: Fantasticbot Version
Programming Design ROBOTC Software Computer Integrated Manufacturing
Programming - Motion Intro to Robotics.
RobotC Sensors.
Movement using Shaft Encoders
Autonomy using Encoders
Programming – Touch Sensors
RobotC Sensors.
Using variables, for..loop and functions to help organize your code
Automation and Robotics
Basketball Drill Programming Alternatives
An Introduction to VEX IQ Programming with Modkit
Getting Started in RobotC
Auto Straightening using VEX Shaft Encoders
Programming Basics - RobotC
While Loops and If-Else Structures
Robotics Programming 9/18/2015.
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
Robotics Programming 9/18/2015.
Robotics Programming Using Shaft Encoders
Robotics Programming Using Shaft Encoders
Remote Control For this activity we will use the Squarebot
While Loops and If-Else Structures
RobotC Programming for LEGO Mindstorms NXT
Robotics Programming Using Shaft Encoders
While Loops and If-Else Structures
Programming Design ROBOTC Software Principles of Engineering
While Loops And If-Else Structures
Is there an alternative to copy-paste for repeating code?
Presentation transcript:

Getting Started in RobotC // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run Getting Started in RobotC

Learning Objectives Understand Motion Motors: How they work and respond. Fuses: Understand why they keep blowing Understand how to control Motors with a program including Setting up the motors Reading the basic outline of a program Using commands for controlling motors motor[port1] = … motor[rightMotor] = … wait1Msec(); Be able to develop a program using behaviors and pseudo code

VEX Motion: Motors 2-Wire Motor 393 100 RPM No load Torque peaks at 13.5 in-lbs at 0 RPM 3.6 amp draw Continually at 3.375 in-lbs +/- 77 RPM 0.9 amp draw It can lift 13.5 lbs. that are on a pulley with 1” radius. But it can’t do this for very long. 6.75 lbs … 2” radius Note you are running at 25% of max torque when running consistantly

High Speed Gears High Speed Gearing: 60% faster Unscrew the motor and replace internal gearing. 160 RPM No Load Torque 8.4 in-lb in bursts 0 RPM 3.6 AMP Continually at 2.1 in-lbs +/- 123 RPM 0.9 amp draw

Motor Controller Motor Controller: 2-Wire to 3-Wire Not needed for motor ports 1 and 10

What happens when you floor it? Motor: 3.6 Amp One Motor Stops Controller: 3 Amp One motor stops Cortex Port: 4 amps combined with four other ports. Robot Stops Current (Amps) in Yellow http://www.vexmen.com/2014/02/troubles-tripping-circuit-breakers-with-10-big-393-motors/ Signal in Blue

Getting Started Open RobotC Select VEX 2.0 Cortex Platform Robot-> Platform ->VEX 2.0 Cortex Make the robot compile to Virtual Worlds Robot-> Compiler Target -> Virtual Worlds Select Virtual World Window->Select Virtual World to Use -> Curriculum Companion

Your Robot

Configuring the Robot: Focus on Motors Robot -> Motors and Sensors Setup Select the motor Currently can only purchase 393 Motors, also modify for internal gearing (high speed, turbo speed) Naming Convention Rules Start with a letter No spaces, punctuation or reserved words (blue) Style Describes what it represents First letter is lowercase otherWordsStartWithUppercaseLetters For these motors leftMotor clawMotor armMotor rightMotor

Motors and Sensors Setup Page 1) Select the ‘Motors’ tab. 3) Use the pull down menus to select the motor. 4) The left motor will need to be reversed so the robot does not go in circles. 2) Name the motor in the desired port. 5) Select the side for drive motors. Naming Conventions Rules Start with a letter No spaces, punctuation or reserved words (blue) Style Describes what it represents First letter is lowercase otherWordsStartWithUppercaseLetters 6) Complete the setup for the remaining motors. 7) Click on Apply to remember the changes.

Code the setup creates ‘pre-processor directives’

Now we can start looking at RobotC motor[motorName] = motorPower; wait1Msec(milliseconds); wait10Msec();

What do you think this code will do? {} Vocabulary // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run The Header // In front of the line makes this line a comment /* */ for multiple line comments. What do you think this code will do? {} Marks the begin and end of a block of code task main() Marks the beginning of the instructions for the Robot. RobotC Is CaSe SeNsItIvE! ; is used to mark the end of a command. motor[rightMotor] = 127; motor[] Used to select the motor. rightMotor = This represents the place where the motor is attached. motor[port10] = 127; does the same thing. = 127; 127 = full power -127 = Reverse 0 = stop Advanced students can also download the program to their physical robot. wait1Msec(2000); The robot continues what it was doing for (2000) milliseconds. Two seconds in this case. Code Break. Open RobotC, configure the motors and enter the above code.

Testing the Program Compile the program Download the program Changes into machine code that the robot understands. Download the program Moving the machine language to your Virtual or Physical Robot Virtual Robot Log in Select Robot Select Challenge Start Activity

Compiling the Program

Oops! The compiler catches syntax (typing) errors and gives some hints on how to fix them.

Any guesses on how to fix these mistakes? Errors Red X = error Yellow X = Warning Errors and hints on the bottom of the page. If you click on an error it will highlight the line of the error. Any guesses on how to fix these mistakes?

Corrected and Compiled

Download the program Since we set it up to map to Virtual Worlds it will download to a Virtual Robot.

Set up and Account with CS2N. It will track progress Set up and Account with CS2N. It will track progress. Can log in locally as a guest without tracking.

Information for CS2N

Select Your Robot 1) Robots Tab 2) We will be using the Clawbot for discussion Note: This shows the motors and sensors attached to this robot

Robots Tab Physical properties of Robot Different Robots Available Motors and Sensors on the Robot selected.

Challenges We’ll use the Power Level Inv. To test our program Click to Select Different Challenges We’ll use the Power Level Inv. To test our program Summary of the activity with a pdf that includes details about the challenge. Click on ‘Start Activity’ to begin

We’ll Test Our Program in the Movement -> Power Level Inv 3) Start Activity

Click-Drag: Rotate View Select Camera and Go Follows Right Scroll: Zoom 2) Top Down View Play: Run the program 3) Free Movement: Scroll: Zoom Click-Drag: Rotate View Reset Home Show Sensors Toggle

Show the measuring tool in the Virtual World. Your Turn Run the program Modify the program to test how far the robot travels for difference times. Use this Virtual World to determine how far you will travel in … 1 Second 2 Seconds 3 Seconds … How can you use this to help you find the wait time to cover a certain distance? We will collect your data to help determine the time needed to cover a distance. Show the measuring tool in the Virtual World.

Power Investigation Distance Covered (cm)for given times 1000 ms 2000 ms 3000 ms 4000 ms Use the class data to determine a relationship between distance and time. Time (ms) = distance (cm) *( 1000 ms/ 47 cm) urns:

Turning Investigation Time to angle Point Turn 45 degrees 90 degrees 135 degrees 180 Degrees

Programming: How to get started? What behaviors are needed to complete the challenge? Looking at the Basketball Drills Developing a solution.

Basketball Drill Pseudocode Refining to get to code Code Go forward and cross the first line Go back to the start Go forward until you cross the second line Go forward until you cross the third line Put the left and right motors on Wait until they go far enough to cross the first line Put the left and right motors in reverse Wait until they go far enough to Go back to the start … motor[leftMotor] = 100; motor[rightMotor] = 100; wait1Msec(2400); motor[leftMotor] = -100; Motor[rightMotor] = -100; motor[leftMotor] = 0; motor[rightMotor] = 0; … Will need to test the times and power levels.

Teaching Strategy: Grading Student Programming Movement: Basketball Drills Programming (10 Points = 100%) ___ Program compiles (4 points) ___ Header complete with names, description and date (2 points) ___ Code is properly indented (2 points) ___ Comments in the program describing the code (2 points) Performance (10 points = 100%) ____ Completed

Online Time: Movement Challenges Basketball Drills Sentry Simulation 1 Labyrinth Challenge

Basketball Drill Programming Alternatives If time… Using the Basketball Drills Activity to introduce: Variables For loop Functions

Looking at Potential Solutions to Basketball Drills Pseudo Code Go forward long enough to cross the first line Come back Go forward long enough to cross the second line Go forward lone enough to cross the third line With enough guessing and checking, you can get the correct values for the wait1Msec()

Using a Variable to help with changes If only there was a tool in RobotC that would let the code repeat.

For loop in RobotC When to use it Syntax When you want to repeat something a set number of times Syntax for(int line = 1; line<=3; line++) { //Code repeated } If the line variable is less than or equal to 3 when it reaches this, it will do the loop another time. After completing the loop, it will add 1 to the variable line. Declares an integer variable called line and gives it an initial value of 1 In this example it will repeat the code inside the {} three times. Once when line = 1 Once when line = 2 And Once when line = 3

No loop vs. for loop

Since line = 1 the first time through this loop line Since line = 1 the first time through this loop line*timeToLine is the same as 1*2400 = 2400 the first time through this loop. Then 2*2400 = 4800 the second time and 3*2400 = 7200 the third time. RobotC does the math inside the () before executing the wait1Msec() command For loop example

Using Functions to make the main body easier to read Define the Functions above the main body. Main Body

Function Details //+++++ moveForward The function ‘Header’ void – It will not return a value moveForward – The name of this function. You get to pick the name of you function as long as: -Starts with a letter -No spaces or punctuation -Not a reserved Word And it should describe what it is doing. //+++++ moveForward Comments added to make the program easier to read. You can add details, … Function Details int timeToMove int – Sets an integer variable timeToMove – An integer variable that will store the value sent to the function in the call statement. The code for the function goes between {}. When the function is finished the program will return to the line after the call statement.

Dry Run: Reading the Program timeToMove timeToMove line Main Body

Online Time: Movement Challenges Basketball Drills Sentry Simulation 1 Labyrinth Challenge When you complete the activities, incorporate variables, loops, and functions