Note: This tutorial assumes that you have completed the previous tutorials: PR2/StartRobot. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Build and Bringup of the Navigation Stack
Description: This tutorial provides a step-by-step guide to building and running the navigation stack on a PR2 robot. Before you begin this tutorial, please make sure that you follow the PR2/StartRobot. We assume that you successfully brought up everything from that step.Tutorial Level: BEGINNER
For our purposes, we'll refer to the robot being used as prg, you can just replace the g with the appropriate letter for the robot you want.
Contents
Build
Build everything we need for the navigation stack:
ssh prg2 rosmake 2dnav_pr2
You'll need to make sure that the robot has the same version (svn revision) of both the 2dnav_pr2 and the nav_view. If not, a message saying the md5sum doesn't match will appear.
If you have your own map
If you have your own map to use, you'll need to complete the following step. If you want to use the willow map, or no map at all, just follow the instructions below.
ssh prg2 cd "the directory where your map is stored" rosrun map_server map_server "map_file" "map_resolution"
Launch
If you wish to run the navigation stack with a global map, see the Launch with Localization section. Otherwise, if you just want to run the robot in a local coordinate frame with no map and no localization see the Launch without Localization section.
Launch with Localization
- Bringing up the nav stack from here just requires one roslaunch and setting one environment variable
ssh prg3 roscd 2dnav_pr2 export ROBOT=pr2 roslaunch move_base/2dnav_pr2.launch or, if you have your own map roslaunch move_base/2dnav_pr2_no_map.launch
You may see connectivity exceptions for a bit until localization initializes, this is OK. - The robot doesn't know where it is in the world, so we'll have to tell it. Execute the following on your local machine (e.g., laptop, desktop):
rosmake nav_view export ROS_MASTER_URI=http://prg2:11311 roscd 2dnav_pr2 roslaunch nav_view/nav_view_move_base.launch
- In the window that pops up, you will need to set the pose of the robot:
- Take note of where the robot is in the world
- Right click and drag to zoom on the map
- Click the "Set Pose" button in the nav_view GUI window
- Left click on the map at the location of the robot and drag to set orientation
The nav stack is now up and ready to run
- You can also use rviz instead of nav_view, however make sure to launch rviz with the launch file at
roscd 2dnav_pr2 roslaunch rviz/rviz_move_base.launch
- If you don't use this launch file rviz will publish goals on the wrong topic
Continue to the Manually giving goals section.
Launch without Localization
- Bringing up the nav stack from here just requires one roslaunch and setting one environment variable
ssh prg3 roscd 2dnav_pr2 export ROBOT=pr2 roslaunch move_base_local/2dnav_pr2.launch
You may see connectivity exceptions for a bit until localization initializes, this is OK. - In order to send goals to the navigation stack, we'll have to build/launch a visualization tool like nav_view.
rosmake nav_view export ROS_MASTER_URI=http://prg2:11311 roscd 2dnav_pr2 roslaunch nav_view/nav_view_move_base_local.launch
- You can also use rviz instead of nav_view, however make sure to launch rviz with the launch file at
roscd 2dnav_pr2 roslaunch rviz/rviz_move_base_local.launch
- If you don't use this launch file rviz will publish goals on the wrong topic
Tucking the arms
In order for the navigation stack to operate safely, it is important to tuck the arms within the footprint of the robot. To do this, we'll run one of the following invocations of the tuckarm.py script depending on if our robot has a left, right, or both arms.
First, make sure pr2_tuckarm is made:
rosmake pr2_tuckarm
For a robot with a right arm run:
rosrun pr2_tuckarm tuckarm.py r
For a robot with a left arm run:
rosrun pr2_tuckarm tuckarm.py l
For a robot with both arms run:
rosrun pr2_tuckarm tuckarm.py b
Manually giving goals
You can set goals manually via nav_view or rviz:
- Click the "Set Goal" button in the nav_view/rviz GUI window.
- Left click on the map at the location of the goal and drag to set orientation
- If the robot is surrounded by obstacles, it may not move. Move obstacles or set a new goal to try again.
Further Learning
If you're interested in sending the navigation stack goals to follow from code rather than from rviz or nav_view, you should check out the Sending Simple Goals tutorial in the navigation stack documentation. It will show, step-by-step, how to write a simple ROS node to send goals to the PR2.