In this lesson we will learn how to send robot a command: “go to a specific position at map”.

We will work with the files from github repository. You can find the information how to clone the github repository in “Writing Your First Script” lesson. We assume that your files are situated here ~/helloworld/turtlebot.

Launching Gazebo and Rviz

1. Launch Gazebo.

roslaunch turtlebot_gazebo turtlebot_world.launch

2. Run the navigation demo.

roslaunch turtlebot_gazebo amcl_demo.launch

3. Launch Rviz.

roslaunch turtlebot_rviz_launchers view_navigation.launch

4. View the current rotation.

Run the command:

rosrun tf tf_echo /map /base_link

You will see the following output in the terminal:

Current Position

We are interested in four numbers in quaternion (current rotation). We will send a goal to change position with approximately the same rotation. Note four numbers: [0, 0, 0, 1].

5. Choose a point.

Select Publish point and choose a point on map where you want TurtleBot to go (do not click). You should note two numbers you see on the bottom left corner of Rviz window. Look at the picture:

Choose a Point

There are two numbers: [3.52, -1.7].

NOTE: The third number is altitude. It may show a number that is not perfectly 0, but regardless of what it says, use 0.

Launching Script

1. Change directory.

cd ~/helloworld/turtlebot

2. Edit go_to_specific_point_on_map.py

emacs -nw go_to_specific_point_on_map.py

NOTE: You can use editor you prefer.

3. Modify line #83.

Old values:

position = {'x': 1.22, 'y' : 2.56}

New values:

position = {'x': 3.52, 'y' : -1.7}

4. Press Ctrl+X, then Ctrl+S to save the changes. After saving is finished, you will see a message like this:

Wrote /home/<user_name>/helloworld/turtlebot/go_to_specific_point_on_map.py

5. Press Ctrl+X, then Ctrl+C to exit Emacs.

6. Launch script.

python go_to_specific_point_on_map.py

7. See the results in Rviz.

TurtleBot will go to the specific point.

8. Interrupt the processes. Close the terminals.

You can watch these steps in the video:

Going to a Specific Location on Your Map Using Code