|
THS
|
Robots /
HW 2Pi + 1 - Putting it all togetherYour goal for this programming task is to reuse your code from tasks 1, 2, and 3 from the previous homework and merge them into a single program. There are a few minor changes made to the programs ( in red). For class on Nov 13/14, you need to hand in the following pages stapled together BEFORE CLASS BEGINS...
and email that file to Jim Dalphond at james_dalphond@student.uml.edu What your robot needs to do...Your new program should do the following for exactly THIRTY SECONDS ... 1. (#1 from last HW) The play LED blinks on and off until the play button is pressed. The Power LED is green.
2. (#3 from last HW) Start the robot driving in a small circle (v = +50 mm/sec, r = 100 mm), make the Play and Advance LEDs blink and the Power LEDs steady green. When play is pressed, the robot accelerates from its current velocity up to 200 mm/sec in 3. ( Optional bonus if you add to your program - +5 points - only do this AFTER you get the rest of the program working!) (#4 from last HW) While the robot is driving in circles (step #2 above), do the following: When the left bumper is pressed, play a short song and turn on left CM led. When the right bumper is pressed, turn on advance LED and right CM LED. When both are pressed, turn on both CM LEDs, but nothing else. Power LED on and green the whole time, and the advance LED should blink on & off.
4. (#2 from last HW) If the robot encounters an unsafe event while execturing 2 & 3 above, beep error and blink the power LED on and off (bright red), Play light off. When the robot RETURNS to a safe state, go back to step 1 to wait for the user to press play again.
At the end of EXACTLY TWO MINUTES, make the robot stop, beep once, and turn the Power LED red (no blinking). Design Hints...
you could use this instead...
if (cr8->bumper_right == 1) && ( (cr8->cliff_left == 0) && (cr8->cliff_right == 0) && (cr8->cliff_frontleft == 0)
@@&& (cr8->cliff_frontright == 0) && (cr8->wheeldrop_left == 0) && (cr8->wheeldrop_right == 0)
&& (cr8->wheeldrop_castor == 0))// blah blah blah
and this line of code would do the same thing, taking advantage of the "not" symbol (exclamation point, !) and the fact that these data values are 1 or 0 (true or false), so you can skip the comparison...
if (cr8->bumper_right) && (!cr8->cliff_left && !cr8->cliff_right && !cr8->cliff_frontleft && !cr8->cliff_frontright
&& !cr8->wheeldrop_left && !cr8->wheeldrop_right && !cr8->wheeldrop_castor)// blah blah blah
|