Passenger Pick Up Challenge
ICE Workshop: September 10th, 2011
Passenger Pick Up Challenge
Robot Road Course
ICE Weekend Workshop
September 10th, 2011
Pre Workshop Survey
Post Workshop Survey
Program a your Passenger Robot to follow the driving course. Robot must stop and pick up Passengers at the 3 stops on the course. There may be a traffic obstacle. If your robot encounters the obstacle, it must drive around the obstacle and continue the course. Robot must start and stop in the "Parking Lot"
Sequence of Skills:
These resources will help you complete the challenge. You will need to decide what sequence and controls you need to make these resources work.
Passenger Robot Port Assignments
Types of Line Following:
Basic Line Follow
"Just Right Line Follow"
Proportional Line Follow
Dark Stop (Using Wait Block)
Line Following with LoopStop (Exiting a Loop)
Drive a Rectangle
Passenger Robot Course:
Passenger Robot Basic Design and Port Assignments:
(TrafficBot Building Instructions)
Basic Line Follow Instructions:
Line following works by using the Light Sensor to read the changes in reflected light level along the edge of a dark and light surface. Then the Switch Block directs the motors to vary the speeds depending on the Light Sensor Value.
In a Basic Line Follow the Light Sensor reads the light value. If the value reads darker than a set value the left wheel spins and the right wheel stops. If the value reads lighter than the set value the right wheel spins and the left wheel stops.
The pseudo code for Basic Line Follow Reads as:
Just Right Line Follow:
Proportional Line Follow Instructions:
The Proportional Line Follow uses a linear equation to adjust the Power in the C and B motors in proportion to the dark/light value in the Light Sensor. The darker the reading, the faster the rate of turn. This makes for a very smooth Line Follow.
1. Select "Edit -> Define Variables" and create the Variable "Kp". Make sure the Datatype is "number."
2. Continue to add the following Variables (all Datatype "number"):
3. Drag a Variable Block into the program area and Select "Kp" (The Kp is the constant that determines how reactive the robot is to Dark and Light. (The slope of the Linear Equation.))
4. Set the Kp variable parameters to "write" and "250" for Value:
5. Drag a Variable Block into the program and Select "offset." (The "offset" is the target value for the Light Sensor)
6. Set the offset parameters to "write" and "45" for value.
7. Drag a Variable Block into the program and select "Tp". (The "Tp" block represents the initial straight forward speed for the robot.) Set the Value of "Tp" to 40.
8. Drag a Loop Block to the program.
9. We will now create the equation: "error = LightValue(3) - offset." Put an "offset" variable and a Light Sensor Block into the Loop.
10. Put a Math Block in the Loop:
11. Set Math Block to "Subtraction."
12. Put a Variable Block after the Subtraction Block, set it to "error."
13. Set the error parameters to "Write."
14. Run a Data wire (Yellow Line) from the LightSensor Block to the A port of the Math Block
15. Run a Data wire from offset to "B" in the Math Block.
16. Run a Data wire from the Result of the Math Block to the error Block.
17. We will now write this equation: "Turn = (error*Kp) / 100." Put two more variable blocks in the program. Set to "error" and "Kp"
18. Put a Math Block in the program and set it to "Multiply." Wire the error and Kp blocks to the Multiply Math Block
19. Put another Math Block in and set it to "Divide."
20. Set the Divide block parameters to B = 100.
***Note: Why divide by 100? In NXT-G 1.0 (The version this program is written in) We do not have Floating Point Numbers. (Decimals). Thus, we do calculations multiplied by 100 (Or Kp = 250 instead of Kp = 2.5) and then Divide by 100 right before we use the Variable.)***
21. Wire Divide Block
22. Put a "Turn" Variable in the Program. Set Turn to "write" and wire result from Divide into Turn.
23. Build the equation for the CPower: "CPower = Tp - Turn."
24. Build the equation for the BPower: "BPower = Tp + Turn."
25. We now need to correct of CPower if it is Less than 0: Put a CPower Variable and a Compare Block in the program. Set the Compare to "Less Than" ( < ). Wire the CPower block to the "Less Than" block.
26. Put a Switch Block on the program. Uncheck the "Flat View" Checkbox.
27. Set the Switch Block parameter Control to "Value" and the Type to "Logic."
28. Put a CPower variable block in the "True" side of the Switch.
29. Set the CPower in the Switch to "Write" and the value to "0"
30. Wire Logic Block to Switch. Command now reads:
if (CPower < 0)
CPower = 0;
31. Do the same for the following command:
if (CPower > 100)
CPower = 100;
32 Set commands for the BPower blocks:
33. Put a CPower Variable block and a C Motor Action Block in the program
34. Wire the CPower block to the Power input of the C Motor Block:
35. Repeat process for BPower Block and B Motor Block:
36. You are done! The entire program will look like this:
37. Save and test your program on the line. Make adjustments as needed. To use Proportional Line Follow - you should turn it into a "MyBlock."
Dark Stop (Using the Wait Block):
MyBlocks: A MyBlock is a user defined segment of code that resides
within one programming block. The user can take multiple blocks and
"group" them together into a block that can be reused in different
programs. This is similar to defining methods or functions in other
We can exit a Loop with a Sensor control. In this project, we need the robot to stop Line Following when the 2nd Light Sensor reaches the black mark at the passenger stations. The psuedo code for this would look like:
Drive a Rectangle:
1. Develop a Good Line Following Program to the Robot can get all the way around the course.
2. Add the Dark Stop and Turns to get the robot from the parking lot to the Track and then around the course.
3. Make a MyBlock out of the Line Follow.
4. Add the Exit Loop codes so the robot stops at the Passenger Stations.
5. Add the Code so the Robot can Load the Passengers at Each Station.
6. Develop additional Exit Loop codes so the robot will stop for traffic if needed (using Ultrasonic Sensor).