ROBOTC for VEX CORTEX Professional Development Jesse Flot
Welcome Tech Check Tools VEX CORTEX Hardware Robot Virtual Worlds Basic Movement Program Planning
Tech Check
Voice communication –Introduce yourself –Checkmark yourself Screen sharing –DEMO: Starting ROBOTC
Tools
CS2NLearn - The Learning Management System (LMS) –Logging in, and where to post homework Three Main Pieces of Software –1. WebEX –2. ROBOTC Application / Robot Virtual Worlds –3. ROBOTC Curriculum / Tutorial Videos
Tools The Forums –Class Forum for announcements and asking questions can be found under the Announcements and Information section: – Active ROBOTC Community
Hardware Overview
VEX 2.0 Cortex Overview Coordinates the flow of information and power on the robot All electronic components interface with the Cortex 10x Faster than the PIC 10 Motor Ports 8 Analog Ports 12 Digital VEXnet Wireless I2C and UART Ports
Clawbot with Sensors 2 Driving Motors 1 Arm Motor 1 Claw Motor 3 Integrated Motor Encoders 1 Quadrature Encoder 3 Line Followers 1 Touch Sensor 1 Ultrasonic Rangefinder 1 Gyroscope
Squarebot and Swervebot These robot models will work, too, with some small adaptations:
ROBOTC Overview & Features
ROBOTC this Week There may be several versions of ROBOTC on your desktops This class we will primarily use ROBOTC for VEX Robotics (and ROBOTC Graphical)
Background Information ROBOTC is developed specifically with teachers, classrooms, and competitions in mind Complete programming solution for the VEX PIC, VEX Cortex, VEX IQ and several other popular robot platforms Only programming language for the VEX PIC, VEX Cortex, and VEX IQ with a real-time debugger –You’ll learn more about this feature later on Very similar to industry-standard C programming –Students get real-world programming experience
Function Library Lists commands that can be drag-and-dropped into the program. List of available functions will expand or shrink depending on the “Menu Level”
Sample Programs ROBOTC includes over 300 Sample Programs Code is fully explained via commenting
ROBOTC Help In-depth explanations about the ROBOTC interface, commands, debugger, etc.
Introduction to Programming VEX Cortex
Student-Paced Instruction Everyone learns different things at different paces Everyone MUST move at a different pace –Going too fast results in failure and frustration –Going too slow results in loss of attention (i.e. future failure) VEX Cortex Video Trainer can be used as a teaching aid –One instructor can’t teach at 20 different paces simultaneously –One instructor plus 20 computers can
Overview
What are ? RVWs are simulation environments that run virtual LEGO and VEX robots programmed in the same languages as physical robots (ROBOTC). Check out the video on the front page of
Why RVW (Initially)? 1.Many classrooms don’t have enough robots for students 2.Very few students have robots at home to do homework or make up missed classwork The Robot Virtual Worlds Project tackles both of these problems by allowing students to program virtual robots using the same programming software
Why RVW (Now)? Research between the CMU Robotics Academy and the LRDC at the University of Pittsburgh shows that learning to program in a simulated environment is actually more efficient than with physical robots! Liu, A., Newsom, J., Schunn, C., Shoop, R. Learn to program in half the time!. Robot Magazine, [ Author Proof (PDF) ] Proof (PDF)
RVW Solutions Curriculum Environments –Challenge Pack –Curriculum Companion Tables –Level Builder Competition Environments –VEX Nothing But Net –VEX IQ Bank Shot –Beltway Themed / Game Environments –Ruins of Atlantis –Operation Reset –Palm Island –Mobile Games
RVW Curriculum Companion All of the programming tables found in the ROBOTC Curriculum in a virtual environment Students follow along with the tutorials and go through the practice challenges, with physical virtual robots Every student in a classroom can learn to program, even at home!
Virtual Robots Virtual robots emulate their real- world counterparts Several robots available, based off of models used in curriculum Have working color sensors, touch sensors, distance sensors, gyro sensors, and motors with encoders Still communicate with the ROBOTC Debugger!
Measurement Tools In-game measurement tools eliminate the need to “guess-and- check” for programming solutions Create waypoints in the world to find key distances and angles Go to and choose Tools > Measurement Toolkit for more informationhttp://robotvirtualworlds.com/
Achievements / Badges As students complete challenges, they earn badges similar to modern games Designed to motivate them, engage them in CS activities long-term Badges are also displayed on CS2N.org, allowing teachers and parents to track progress
Tracking Progress CS2N.org also allows teachers to create “Groups” with their students RVW Challenge Completion and Quiz scores are all presented in convenient, easy-to- understand format
Getting Started with RVW
Using Robot Virtual Wolds 1.Switch Robot > Compiler Target to Virtual Worlds 2.Choose Window > Menu Level > Select Virtual World to Use > Curriculum Companion 3.Compile and Download a Program to Launch the Virtual World
First Program – Moving Forward
VEX Motors 3 Main Types: –Original 3-wire motor –Newer 2-wire motor 269 –Newer 2-wire motor 393 All motors are programmed the same way in ROBOTC –Accept values between 127 (full forward) and -127 (full reverse)
Before You Begin Make sure you have done the following: –Updated the VEX Cortex Brain, Motors and Sensors –Installed ROBOTC Firmware –Chose the correct compiler target
Platform Type Make sure to configure ROBOTC to work with the Cortex!
Compiler Target Make sure your Compiler Target is set to “Physical Robot”.
VEX Cortex Communication Mode Allows you to specify: 1.How programs are downloaded 2.Whether the Cortex looks for a VEXnet connection when it starts up With “VEXnet or USB” the Cortex will look for a VEXnet connection before running code
VEX Cortex Microcontroller The Cortex has two processors that are responsible for different tasks –Master Processor: VEXnet communication, low-level motor control –User Processor: Interpret ROBOTC Programs Each processor has software called “firmware” that allows it to perform its tasks
Renaming and Reversing Robot > Motors and Sensors Setup –Optional but a good practice –Give Motors and Sensors custom names –Reverse motor polarity
Naming Rules The Motors and Sensor Setup window allows you to give your motors and sensors custom names. The names, however: –Should be descriptive of the sensor or motor they refer to (rightMotor, frontBumper, ect.) –Must be all one word made up of letters, numbers, and underscores –Must contain no special characters (&, $, /, ect.) –Cannot already be a ROBOTC reserved word (task, motor, true)
Basic Programming: Motor and Wait Commands
rightMotor On for 5 Seconds
Turns the port2 rightMotor on at half power forward
rightMotor On for 5 Seconds Causes the robot to wait here in the program for 5.0 seconds
rightMotor On for 5 Seconds Stops the port2 rightMotor. End Result: rightMotor spins for 5.0 seconds.
Basic Commands: Program Flow
Moving Forward The basics of programming with the ROBOTC Graphical is to take a command from the left and drag it to the right. Start with the Forward command block
Moving Forward What happens if you choose "Seconds" as the unit in a Forward movement command? Try it!
Backward Command What happens when you use a Backward command in your program instead of a Forward command? Write a program using a Backward command. Try it!
Arm Control In order to control the arm of our robot, we will need to use a new Command Block: moveMotor Change your setting to 315 degrees. Positive values lower the arm and negative values raise the arm. Try it!
Moving Forward Mini Challenge: 50 cm Challenge –Program your robot to travel exactly 50 cm!
Motors Debug Window Displays the status of all of the motors configured on your robot “Readable” and “Writable”
Turning
Turning in Place Use the following Command Block to make your robot turn. What happens? Is it what you expected? Why not?
Turning in Place Units of Turn What happens if you switch the second box of the turnLeft or turnRight command from Rotations to Degrees? Try it!
Turning in Place Mini Challenge: 90 Degree Turn Challenge Program your robot to turn exactly 90 degrees to the right!
Movement Exercises 1.Move the robot forward at full speed for 3.5 seconds, and stop 2.Point Turn to the left at half power for 5 seconds, then Point Turn to the right at full power for 2 seconds 3.Move Backward for 3.25 seconds at half power, then Swing Turn to the right for 2.35 seconds
Program Planning
Behavior Based Programming A behavior is anything your robot does: –turning on a single motor, moving forward, tracking a line, navigating a maze Three main types of behaviors: –basic behaviors – single commands to the robot (turn on a motor) –simple behaviors – simple task performed by the robot (move forward, track a line) –and complex behaviors – robot performs a complex task (solve the maze) Complex behaviors can always be broken down into simple behaviors, which are then broken down into basic behaviors
Labyrinth Challenge
The Labyrinth Challenge
Programming Discussion The Challenge: Labyrinth The Solution: ??? The Programmer’s (your) Role –Plan out the robot’s path / actions - Pseudocoding –Understanding Program Flow and Behavior Based Programming –Translate the Pseudocode into real code The Robot’s role –To carry out your instructions! The Solution: Programmer and Robot working together, fulfilling their roles –True for all robotic challenges!
Pseudocode Pseudocode is a shorthand notation for programming which uses –informal programming structures (if touch1 is pressed…) –verbal descriptions of code (move forward, stop) Emphasis is placed on expressing the behavior or outcome of each portion of code rather than on correct syntax Your lines of Pseudocode should also be listed in the same order as they will appear in the ROBOTC Program
Pseudocode Sample Pseudocode:
Putting it all Together Effective Program Planning is essential to writing correct code. Carrying out that plan is equally important! Once you have your plan, don’t try to implement it all at once! Systematically add sections of code, testing at every step!
Code Commenting “Comments” allow the programmer to make notes in the program that the robot will ignore –Begin with “//” –You can also click on a line number to “comment out” a line of code. This is useful during troubleshooting.
Labyrinth Challenge
The Labyrinth Challenge
Homework! Homework assignments can always be found and turned-in on CS2NLearn You’ll also be expected to watch a series of videos for review Optional practice quizzes will prepare you for the certification exam at the end
Appendix
Big Ideas and Teaching
Big Ideas What can you teach with a robot? How do you teach with a robot? What do I need to know about programming?
Preconceptions & Pedagogy Preconceptions –You have preconceptions Students have preconceptions –New information has to be reconciled with existing beliefs –Something has to give! –Contradictory statements can coexist in the mind …this is called CONFUSION We want to get rid of this. Effective instruction requires teachers to address preconceptions effectively
Preconceptions Do we expect you to believe this yet? –NO! –You can’t change preconceptions by simply making claims and justifications –Preconceptions are too closely linked to the rest of our world view –2 ways to change belief: Repeated experience Trauma We prefer this one, but hey…
Teaching with Robotics Often, you will encounter a problem
Teaching with Robotics Solve the problem
Teaching with Robotics Problem solved…
Teaching with Robotics Problem not solved??
Teaching with Robotics
The Problem The Real Problem The Really Real Problem
The Robotics Teacher Build an understanding that leads to a solution Understand the underlying problem and solution Make it work Instruction vs. Unstruction –What happens if you just solve the problem for the student? Remove the tip of the iceberg Don’t actually solve the problem At a loss to explain why the same problem re-emerges soon after –Result: Confuses students Teaches dependence as a solution
The Robotics Teacher Level 1: Answer Level –“Explode” the iceberg (tip) –Short term solutions –Shallow understandings –“Solving the problem” often doesn’t solve the problem! –Be aware of, but do NOT stop or let your students stop here Understand the underlying problem and solution Make it work
The Robotics Teacher Level 2: Student Level –Realize the underlying nature and scope of the problem (whole iceberg) –Find a way to solve the real problem –Students need to achieve this level of understanding Understand the underlying problem and solution Make it work
The Robotics Teacher Level 3: Teacher Level –“Remove” the water –Expose the problem –Build an understanding –Lead the student toward a working solution to the “whole” problem –You must reach this level Build an understanding that leads to a solution Understand the underlying problem and solution Make it work
The Robotics Teacher Build an understanding that leads to a solution Understand the underlying problem and solution Make it work Instruction vs. Unstruction –Teachers must operate fluently at the highest level This includes understanding a student’s level and perspective –You must: Be aware of and eschew Level 1 understandings Construct a Level 2 understanding Expand into a Level 3 understanding
Preconceptions Do we expect you to believe this yet? –Have you had repeated experience or trauma yet?
Robot Math
How did you solve the 50 cm problem? How did you solve the math problem behind it? Some common methods: –Scale Factor (“Scaling” multiples of a known quantity) –Rate: Unit Ratio (# of X in a single Y, times the number of Y’s) “Rate” relationship Find #degrees/1cm, then multiply that rate by the total What about #degrees per floor-line? –Rate: Raw Ratio (# of X per # of Y, times the number of Y’s) Find 360degrees/20.4cm, then multiply that rate by the total –Direct Proportion (Traditional “ratio” equation) 20.4 cm = 50 cm 360 deg X deg Solved mechanically using cross-multiplication Solved algebraically as a Linear Equation of One Variable
The M in STEM Did you all solve the same problem? Did you all get the same answer? Did you all use the same method? Answer Problem Did it matter?
The M in STEM To measure distance, we have many tools… –Why should robotics be any different? –Why should mathematics be any different? Give students more tools and more experience in choosing and using them!
The M in STEM steM Many STEM teachers will not be teaching in “Math class”, yet when Math is the correct tool… –Make the math explicit; don’t waste the opportunity! Embrace multiple methods of solving the same problem; students need more tools at their disposal, not conflicting information about which ones are “better” than others (none are, use what works!)
Abstraction Bridges Criticism: What good is Robot Math? –Is the SAT going to ask you about encoder counts and wheel rotations? Refining the math skills –Generalize understanding (apply to other numbers and contexts) –Practice Compare these problems: –A robot moves 3 meters in 2 turns of its wheel. How far does it go in 6 turns of the wheel? –You can get 3 T-shirts for 2 dollars at the mall. How many can you get for 6 dollars?
Underlying Math Structure Abstraction Bridge –Problem-pair is one type of Abstraction Bridge –Same question, different context Are these the same question? –20 cm in 412 degrees, find deg/cm –200 mi in 41.2 dollars, find mi/$ Are these the same question? –120 cm is 80% of the total. How many cm to go? –80% of 30 questions were correct. How many wrong?
Expedition Atlantis
“Program” robots to move based on solving proportional math problems Students learn to solve “forward” problems, then “turning”, then combine to “turn and move forward” Students can customize robots 4 different difficulty levels Available in iTunes, Mac, PC