Going to a Specific Location on Your Map Using Code
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.
2. Run the navigation demo.
3. Launch Rviz.
4. View the current rotation.
Run the command:
You will see the following output in the terminal:
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:
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.
2. Edit go_to_specific_point_on_map.py
NOTE: You can use editor you prefer.
3. Modify line #83.
Old values:
New values:
4. Press Ctrl+X
, then Ctrl+S
to save the changes. After saving is
finished, you will see a message like this:
5. Press Ctrl+X
, then Ctrl+C
to exit Emacs.
6. Launch script.
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: