Prerequisite:
cmd_vel
, laser
, tf
,…)Even without having a map of the environment, we can create one on-the-fly, thanks to SLAM (Self Localization and Mapping).
You will need to set up you robot completely, then to launch slam_gmapping
. It may be helpful to create a launchfile to pass parameters, for example in gmapping.launch
:
<launch>
<param name=“use_sim_time” value=“false”/>
<node pkg=“gmapping” type=“slam_gmapping” name=“slam_gmapping” output=“screen”>
<!– descriptions and defaults:
http://www.ros.org/wiki/gmapping#Parameters –>
<param name=“xmin” value=“-5.0”/>
<param name=“ymin” value=“-5.0”/>
<param name=“xmax” value=“5.0”/>
<param name=“ymax” value=“5.0”/>
<param name=“maxUrange” value=“59.0”/><!–60! ?–>
<param name=“maxRange” value=“63.0”/>
<param name=“map_update_interval” value=“5.0”/> <!– def –>
<param name=“linearUpdate” value=“0.2”/>
<param name=“angularUpdate” value=“0.15”/>
<param name=“particles” value=“50”/>
<param name=“delta” value=“0.1”/>
</node>
</launch>
Then, launch rviz
and see the result, published in topic /map
.
sudo apt-get install ros-hydro-hector-slam
One may need to first record the data before computing the map. That is possible, with a “bag”.
See the tutorial http://wiki.ros.org/slam_gmapping/Tutorials/MappingFromLoggedData
One first needs to make a bag of data, e.g.:
rosbag record -O mylaserdata /scan /tf