Turtlebot Programming
- Start the Turtlebot simulator by following the steps from
the previous lab.
- Download either approach.py or approach_oo.py .
-
Execute the file by typing:
python approach.py
or
python approach_oo.py
inside the directory that contains the file. If all is well, the
simulated robot should approach the wall in front of it.
-
Make a copy of your file named
wander.py
and open it in your favorite text editor. (If you use gedit, make
sure to configure it to insert spaces instead of tabs:
Edit->Preferences->Editor-> Tab width 4, Insert spaces instead of
tabs.)
-
Modify the resulting file so that it allows the Turtlebot to wander
around without colliding with obstacles. Feel free to use any
strategy you like, but I suggest the following algorithm as a simple
starting point:
- Move forward until the distance to the nearest obstacle is too
small.
- Move a few inches backward, then turn a few degrees to the
left.
- Repeat.
The Python time
module can be used to determine the current system time in seconds:
import time
time.time() # returns current time.
This may be helpful in writing code that allows the robot to execute
some operation for a fixed amount of time. For example: moving
backward for exactly .4 seconds.
Test and debug your program until it works to your satisfaction
Testing on a Real Robot
Command-Line ROS