Helpful Hints:
If you are ready to move on, collect from me a Handyboard, a diskette containing the software, a power converter, the board that connects the Handyboard to the computer, and both connector wires.
If your group cannot access a Handyboard immediately, read through the handout on the Handyboard and Interactive C, the programming language for the robot. Look over the sample programs attached here and figure out what each one does by looking up the commands in the manual. Watch what other teams are doing.
Do the following to get set to activate the robot:
beep(); fd(0); off(0); fd(1); ao(); fd(2); ao(); fd(3); ao(); bk(1); bk(3); ao(); motor(1, 50); motor(3, -50);
Make the robot spin in place without dragging either drive wheel.
At this point, please let another group work with the Handyboard if one is waiting. Look over the programs below if you have not done so already.
In Interactive C, type load beeper.c at the prompt.
It should load the file without errors, and automatically download
it to the robot.
To execute the program, turn the Handyboard off, and then on again. This program should beep every time you press the "Start" button. Notice that the message on the LCD panel changes, too.
Go back into SimpleText. Edit the file beeper.c so that instead
of looking for the start button to be pressed, it looks for the
touch sensors to be pressed. Use the procedure defined at the
top of the file: touched or both-touched.
To call touched you put an expression like:
touched(leftTouch)If it is called by itself it needs a semi-colon at the end, but if it is being used in an
if statement or as the test condition
for a loop (for or while) then it does not
need a semi-colon at the end.Save the new file under the name beeper2.c so that you still have the original.
Go back to Interactive C, and unload beeper.c. Then load beeper2.c. You may need to "debug" your new program, but keep working until you get it to do what you want.
Finally, make the program print out a different message when the left sensor is touched than when the right sensor is touched.
At this point, let another team use the Handyboard and software. Save all your work, and copy it to your own diskette or network folder. Then remove the copies that you created in the folder on the desktop so the next team has a clean slate to work from. DO NOT ERASE THE FILES THAT I PUT THERE!
Load the file in Interactive C (be sure to unload any existing files first). Now, turn the Handyboard off and unhook the telephone cable from the robot. You might borrow a twist-tie or a rubber band to tie up the various wires so that they won't get tangled in the wheels. Setting the Handyboard on an open space (the floor in the hallway would be good) turn it on and watch the program run.
Edit the file moving.c and save it as moving2.c so that the robot will trace out the shape of a square on the floor: it will move forward a distance, turn as close to 90 degrees as you can get, move forward again, and so forth.
Load and test your program, being sure to unload moving.c before loading moving2.c.
How would you have the robot move in a circle?
Again, let another team have a try now.
Open the file berandom.c, and look it over. This program causes the robot to move forward a random amount every time the start button is pushed, and to turn a random amount every time the stop button is pushed.
Load this file in Interactive C (did you remember to unload any previous files?), and take the robot back into the hallway to test out the program. Be sure you understand how it works.
Now, edit the program, saving the new program as wander.c, so that the robot wanders continuously, moving forward, backward, turning left and right. Pick a time-scale between changes that makes the movement of the robot relatively graceful, and be sure that it is possible for the robot to turn completely around.
Hint: You might use the random number procedure to pick among the robot's general options: move forward, move backward, turn right, turn left, and then do the chosen option for some random amount of time before repeating the process.
If you want to get fancy, try adding procedures for arcing left and right (turning and moving at the same time). These would be just like the turning procedures, except that both motors would be moving in the same direction, just at different speeds.
Test out your new program until it works satisfactorily.
Now, let another team have access to the Handyboard and software.
Create a new version of the wander.c, wander2.c, so that in addition to what it did before it checks to see if one or the other bumper has been pressed. If it has, the robot should stop, beep a few times, and just sit there.
You might let another team use the Handyboard here, too.
Create your final program, wander3.c. This should, instead of stopping when a bumper is pressed, respond in a sensible manner: backing away from the obstacle, turning in a direction that will tend to reduce the likelihood of hitting the obstacle again, etc. Think about strategies for this before trying to write a program for it.
The ultimate test for your final program is not the relatively open hallway, but the robot playpen I'll construct. You'll need to demo your final program before the rest of the class on Monday.