Presentation is loading. Please wait.

Presentation is loading. Please wait.

Auto Straightening using VEX Shaft Encoders

Similar presentations


Presentation on theme: "Auto Straightening using VEX Shaft Encoders"— Presentation transcript:

1 Auto Straightening using VEX Shaft Encoders

2 Learning Objectives Understand how the strategy for using shaft encoders to help the robot drive straight. Be able to program the robot to go straight using shaft encoders Be able to use the while loop, if and variables.

3 Using Encoders to go Straight
Limit drifting when trying to go straight In this section we will look at if else Variables and types Applying all of this to help the robot go straight

4 Flowchart for the day Take notes on a video using the motor encoders to go straight. Discuss the video and focus on using the if statement with encoders to get the robot to go straight. Online time to test the code on the ‘Huge Table’ Take notes on videos on using variables to help refine the motion Discuss the video Incorporate variables into your sample program. Start the next set of Challenges Cortex Videos 1 and 2.

5 Pseudo Code (What we are trying to get the robot to do)
While the robot has not reached the destination If the left motor has gone farther, slow the left motor and have right motor go at speed If the right motor has gone farther, slow the right motor and have the left motor go at speed If the motors are the same, have both motors go at speed

6 If Statements When your robot reaches an if Statement in the program, it evaluates the condition contained between the parenthesis. If the condition is true, any commands between the braces are run. If the condition is false, those same commands are ignored. Very similar to how a while loop works, but does not repeat the code!

7 Going Straight: Translating to Code
Pseudo Code While the robot has not reached the destination If the left motor has gone farther, slow the left motor and have right motor go at speed If the right motor has gone farther, slow the right motor and have the left motor go at speed If the motors are the same, have both motors go at speed

8 If-else statements The if-else Statement is an expansion of the basic if Statement. The “if” section still checks the condition and runs the appropriate commands when it evaluates to true Using the “else” allows for specific code to be run only when the condition is false. Either the “if” or the “else” branch is always run; no more, no less.

9 Implementing if..else Code this and test it on the Huge Table.
Take notes on Videos 3 and 4.

10 But… If the motors are not close in their Power to Speed then the difference between 50 and 63 might not be sufficient. So it will take some tweaking. Rather than changing the 63 to another value when modifying the ‘at speed’ needed, you can use variables.

11 Make sure these are in your notes.
RobotC Variables Make sure these are in your notes. int Stores integer values: 5, 0, -100 float Stores floating point (real) values: 3.01, -5.21, 0 string Stores words: “Hello World” char Stores single characters: “A”, bool Stores Boolean (true, false) values

12 Code After Using Variables for Speed Values
Declaring the variables. type name; Modify your going straight code to incorporate variables. Initialize the variables. Try modifying the fullSpeed and slowerSpeed values to see how if changes the robot behavior.

13 Summary motor[] SensorValue[] wait1Msec() while if if..else Conditions
Conjunctions Motors and Sensor Quadrature Encoder Strategies on going straight Timing vs. distance

14 Driving Straight Activity
Use the Clawbot Next set of challenges Driving Straight II using encoders Bull in the Ring: Using a while or an if Robo-Slalom I: Using a while or an if


Download ppt "Auto Straightening using VEX Shaft Encoders"

Similar presentations


Ads by Google