1 / 32

ROBOT C for VEX On-Site Professional Development

ROBOT C for VEX On-Site Professional Development. Squarebot 3.0. Features: 2 Driving Motors 1 Arm Motor Ultrasonic Rangefinder Shaft Encoders Touch Sensors RF Receiver VEX PIC. VEX Microcontroller. “Brains” of the robot Controls up to 8 motors and/or servos

kareem
Download Presentation

ROBOT C for VEX On-Site Professional Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ROBOTC for VEXOn-Site Professional Development

  2. Squarebot 3.0 • Features: • 2 Driving Motors • 1 Arm Motor • Ultrasonic Rangefinder • Shaft Encoders • Touch Sensors • RF Receiver • VEX PIC

  3. VEX Microcontroller • “Brains” of the robot • Controls up to 8 motors and/or servos • Receives feedback from up to 16 analog and/or digitalsensors • Can run Autonomously, Tele-operated, or a combination of the two • Stores and executes one program at a time (typically) • Can be used to control pneumatic actuators, LCD screens

  4. ROBOTC • Developed specifically with teachers and classrooms in mind • Complete programming solution for the VEX plus several other robot platforms • Only programming language for the VEX with a real-time debugger • You’ll learn more about this feature later on • Very similar to industry-standard C programming • ROBOTC demonstration

  5. Teaching ROBOTC for IFI VEX Robots (TRC4V) • 40 tutorial videos • 275 pages of printable guides aligned to the videos • 50 pages of supplementary “helper guides” • 35 programming challenges • Freely available at www.robotc.net

  6. 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) • TRC4V can be used as a teaching aid • One instructor can’t teach at 20 different paces simultaneously • One instructor plus 20 computers can

  7. 1 2 3 A Tale of Two Softwares • Use TRC4V to update the VEX firmware in ROBOTC: http://www.robotc.net/vex_full/ ROBOTC for IFI(the GREEN icon)

  8. Firmware Check • What is Firmware? • Does the robot need to be turned on in order to transfer firmware? • What needs to happen after the firmware transfer is complete, before doing any programming?

  9. Get Your Motors Running • Motor Check • Right Motor is plugged into MOTORS 2 • Left Motor is plugged into MOTORS 3 • Download Sample Program • Training Samples > Motor Port 3 Forward • Basic Movements • Forward / Reverse • Swing Turns / Point Turns • Manual Adjustments

  10. Programming Discussion • The Challenge: The Labyrinth • The Solution: ??? • The Programmers (your) Role • Plan out the robot’s path / actions - Pseudocoding • Understanding Program Flow and Behavior Based Programming • Translate the Pseudocode into real code • The Robots role • To carry out your instructions! • The Solution: Programmer and Robot working together, fulfilling their roles • True for all robotic challenges!

  11. Movement Challenges • TRC4V Videos (recommended) • Watch videos in the Fundamentals Section • Watch videos in the Movement Section • The Labyrinth • Remember to Pseudocode • Turning Investigation • Remember to Pseudocode • Consider what you can teach with a robot • Sentry Simulation

  12. Review Questions • Why does the robot spin if both motors are set to the same power level? • What are valid power levels on the VEX? • All commands that we want the robot to follow must be in _________? • Each command must end with a(n) _________?

  13. Troubleshooting • Student: I want my robot to move forward, then turn. I had it moving forward, and added the turn. Now it’s turning, then moving forward.

  14. Troubleshooting • Student: I want my robot to move forward, then reverse. I had it moving forward, and added the reverse, but it never actually backs up.

  15. Troubleshooting • Student: My code compiles, but ROBOTC gives me an error when I try to download it to the robot. • Check: • Is the robot turned on and sufficiently powered? (blinking green light) • Is the robot connected to the computer? • Is the correct platform type selected in ROBOTC? • Is the correct port selected in ROBOTC? • Has the driver for the programming cable been installed? • Has the firmware been loaded on the VEX? • Does the Master Firmware need re-downloaded? • Is another ROBOTC window open, using the debugger windows?

  16. Shaft Encoders

  17. Shaft Encoders • How they work • Digital counting sensor • Capabilities and Resolution • “Quadrature” vs. Standard • Setting them up • ROBOTC Motors and Sensors Setup window • Using them • The SensorValue[] command • The while() loop

  18. Better Movement with Encoders • Forward for a specific distance • Advantages / Disadvantages • Reverse for a specific distance • Advantages / Disadvantages • “Clearing” the encoder • Turning • Advantages / Disadvantages

  19. Variables • What is a variable? • Types of variables • Integer, Boolean, Character • Usage rules • Capitalization, Spelling, Availability • Usefulness • Can store data to be manipulated by your robot • Can improve the readability and expandability of your programs

  20. The M in STEM • Current method for moving the robot: • Guess-and-check - true for wait states and encoder rotations • Do it smarter! • We can measure the distance for the robot to travel • We can measure the circumference of the wheel • We know 360 degrees = 1 wheel rotation • Ideas? • Use your idea to move forward and reverse • Discuss how well your ideas worked • Discuss Turning • Is having the robot turn 90 degrees the same as having the encoder turn 90 degrees? Why or why not?

  21. The M in STEM • How did you solve the math problem? • 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/1in, 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/8.6in, then multiply that rate by the total • Direct Proportion (Traditional “ratio” equation) • 8.6 in = 24 in 360 deg X deg • Solved mechanically using cross-multiplication • Solved algebraically as a Linear Equation of One Variable

  22. Answer Problem 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? • Did it matter?

  23. The M in STEM • Did we do something demonstrably useful? • NCTM Numbers and Operations Standards (6-8) • Select appropriate methods and tools for computing with fractions and decimals from among mental computation, estimation, calculators or computers, and paper and pencil, depending on the situation, and apply the selected methods • Develop and analyze algorithms for computing with fractions, decimals, and integers and develop fluency in their use • Develop and use strategies to estimate the results of rational-number computations and judge the reasonableness of the results • Develop, analyze, and explain methods for solving problems involving proportions, such as scaling and finding equivalent ratios.

  24. The M in STEM • Did we do something demonstrably useful? • NCTM Algebra Standards (6-8) • Represent, analyze, and generalize a variety of patterns with tables, graphs, words, and, when possible, symbolic rules • Relate and compare different forms of representation for a relationship • Model and solve contextualized problems using various representations, such as graphs, tables, and equations • NCTM Geometry Standards (6-8) • Understand both metric and customary systems of measurement • Solve problems involving scale factors, using ratio and proportion

  25. The M in STEM • Did we do something demonstrably useful? • NCTM Problem Solving Standards (6-8) • Build new mathematical knowledge through problem solving • Solve problems that arise in mathematics and in other contexts • Apply and adapt a variety of appropriate strategies to solve problems • Monitor and reflect on the process of mathematical problem solving • NCTM Communication Standards (6-8) • Organize and consolidate their mathematical thinking through communication • Communicate their mathematical thinking coherently and clearly to peers, teachers, and others • Analyze and evaluate the mathematical thinking and strategies of others • Use the language of mathematics to express mathematical ideas precisely • NCTM Connections Standards (6-8) • Recognize and apply mathematics in contexts outside of mathematics

  26. Everyone is a Math Teacher • How did you solve the math problem? • Many STEM teachers will not be teaching in Math class, yet Math is clearly what they are teaching • 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!)

  27. Moving Straight • Even with the shaft encoders, the robot still veers (probably). • Does it have to? Discuss. • By comparing the values of the two encoders, we should be able to tell which side is falling behind, and adjust motor power in real time! • Watch the Automated Straightening Video in TRC4V

  28. Moving Straight Check • How will the robot be able to tell which side is falling behind? • How will the robot be able to adjust its motor power? • Will adjusting the motor power once solve the problem? Why or why not? • Pseudocode the Moving Straight Code! • Translate the Pseudocode into real code. • Test! Did you notice any improvement? • How does the program flow through the code?

  29. Moving Straight Discussion • The automatic moving straight code works great, but imagine using it to solve the Labyrinth. • Automatic moving straight code = ~20 lines • 5 Forward movements needed for the Maze • 5 x ~20 = ~100 Lines of code! • And that doesn’t include turns or other commands! • Notice that the moving straight code is mostly comprised of the same exact code, over and over. • What if there were a way to reuse the same set of code? • There is: Functions!

  30. Functions • Functions are used to group together several lines of code, which can then be referenced many times in task main, or even other functions. • Convenient uses in the Labyrinth • Moving Straight • Turning 90 Degrees Left • Turning 90 Degrees Right • Creating Functions • Simplified Example: Moving Forward • Function Header (Part1 – The name of the function) • Function Definition (Part 2 – The code that goes with the function) • Using Functions • Function Call (Part 3 – Where you want the function code to run)

  31. Advanced Functions • What about the very similar lines of code that go with the automatically moving straight code? Is there a way to include those lines in the function? • What’s different each time we use the code? • The number of degrees for the distance of the straight movement! • What programming tool do we have that lets us store numbers in our code? • Variables! Functions allow use for a special kind of variable, called a Parameter. • Parameters allow you to pass values into functions to account for small differences, like the number of degrees to move forward.

  32. Advanced Movement Challenges • TRC4V Videos (recommended) • Watch Behaviors and Functions Parts 1 & 2, found in Sensing > Autonomy (Encoders) • The Labyrinth Revisited • Remember to Pseudocode • Seeing the Difference • Remember to Pseudocode

More Related