By this point you’ve cloned the github repository for this article series and successfully created a map (saved at /tmp/mymap) of your current location. (If you have changed locations since the map generation article, create a new map.)

TurtleBot Without Obstacle Avoidance

Let’s run our first script again. On TurtleBot:

roslaunch turtlebot_bringup minimal.launch

On the workstation run:

python ~/helloworld/

Your TurtleBot will be going forward. Intentionally stand in front of it and TurtleBot will crash into your feet. Press CTRL + C to stop it.

TurtleBot with Obstacle Avoidance

Manually orient TurtleBot so it can go forward 3 meters without crashing into anything. On TurtleBot run:

roslaunch turtlebot_bringup minimal.launch
roslaunch turtlebot_navigation amcl_demo.launch map_file:=/tmp/my_map.yaml

On the workstation run:

roslaunch turtlebot_rviz_launchers view_navigation.launch --screen

TurtleBot can’t reliably determine its initial pose (where it is) so we’ll give it a hint by using “2D Pose Estimate”. Select “2D Pose Estimate” and specify TurtleBot’s location. Leave RViz open so we can monitor its path planning.

TIP: After you estimate TurtleBot’s pose it can reliably know where it is even while traveling.

In a separate terminal run:

python ~/helloworld/

Try walking into the robot’s path while it is driving to see how it responds.

Go Forward and Avoid Obstacles

Go Forward and Avoid Obstacles Results

Why Does It Go in Circles?

TurtleBot is looking around for features, comparing them to the map and using that to determine where it is. This process is called localization. Here’s an excellent video on TurtleBot localization created by Melonee Wise:

TurtleBot Localization Primer by Melonee Wise

Let’s have a look at the code:

gedit ~/helloworld/

It’s also available for viewing on GitHub.

Note that instead of saying “go forward for a few seconds” we’re saying “we want to end up at the location 3 meters forward regardless of what path takes us there”. TurtleBot can take up to 60 seconds to try and find a path to this location all with a few lines of code.

Learn more at