(!) 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.

GMapping for P2OS Robots

Description: This tutorial will explore the process of mapping for the p2os system.

Tutorial Level: BEGINNER

Next Tutorial: C++ Pose Listener For P2OS C++ Pose Listener For P2OS

Set Up Laser Position

It is very important to have the laser set up correctly to work well with GMapping. So, we must first set up the laser's position with respect to the robot in a static transform.

This is the first launch file we will be looking at.

$ nano `rospack find p2os_launch`/tf_lrf_p2os.launch

        <!-- publish the required transform /base_link -> /laser -->
        <include file="$(find p2os_launch)/tf_base_link_to_laser.launch" />
        <!-- assuming we're using a hokuyo laser, start up the hokuyo node -->
        <include file="$(find p2os_launch)/hokuyo.launch" />

        <!-- if you use a sicklms instead of a hokuyo laser: -->
        <!-- <include file="$(find p2os_launch)/sicklms.launch" /> -->

If you need to use the SICK laser, uncomment the above line and comment out the hokuyo line. Now we need to set up the transform for the robot.

$ nano `rospack find p2os_launch`/tf_base_link_to_laser.launch 

        <node pkg="tf" type="static_transform_publisher" 
         name="base_link_to_laser" args="0 0 0.1397 0 0 0 
         base_link laser 100" />

Change the numbers in args to match the location of your laser with respect to the base of the robot in meters. These measurements come from the middle of the robot.

Initialize the Robot

Now we need to run the pioneers.

$ roslaunch p2os_launch pioneerMasterLaunch.launch 

If you wish to use a joystick, you need to modify this launch file as well. In the same process as above, change the arguments that deal with this.

To enable the motors (in case the above file failed to enable them), run the following command.

$ rostopic pub /cmd_motor_state p2os_msgs/MotorState 1

Then wait briefly and stop publishing.

== Run GMapping == Now we can map! Hooray! When the p2os dashboard comes up, you will need to enable the motors. If you wish, you can check out a package that turns the motors on here. Now run GMapping. The default parameters do not work well with the Pioneers, so I recommend changing the arguments.

 $ rosrun gmapping slam_gmapping scan:=scan _particles:=100 _linearUpdate:=0.1     _angularUpdate:=0.03

To visualize the map you are making, we will open RVIZ.

 $ rosrun rviz rviz

You should get something similar to the picture below. Feel free to email me anytime when help is needed. I will update the tutorial when questions are asked in this section.

alt text

When you are ready to save your map, you run

 $ rosrun map_server map_saver -f mymap

Wiki: p2os-purdue/Tutorials/GMapping With Pioneer-3dx (last edited 2015-03-08 02:50:00 by HunterAllen)