This tutorial shows how to build a map to let the robot remember the environnment around. With generated map, robot can autonomously navigate around.
After setting up the tf tree, sensor sources and the odometry information for your robot, the next step is to implement localization algorithms/mapping algorithms or Simultaneous Localization and Mapping(SLAM) algorithms.
The selected package to build the map is Hector Mapping. This package create a floor plan/occupancy grid map using laser scans. Note that this algorithm can create only a 2D occupancy grid map. It should be sufficient for any ground robot that always navigates on a given plane.
sensor_msgs/LaserScan topic ( laser scan source).
Download the github repository and compile the code following these instructions:
mkdir -p ~/erle_ws/src cd ~/erle_ws/src git clone https://github.com/erlerobot/gazebo_cpp_examples cd .. catkin_make --pkg ros_erle_rover_navigation
Make sure the minimal software has already been launched on the robot and you have configured your network correctly.
Now launch the slam algorithm:
roslaunch ros_erle_rover_navigation slam.launch
Teleoperate Erle-Rover around to generate the map:
rosrun ros_erle_cpp_teleoperation_erle_rover teleoperation ErleRoverManager : using linear vel step . ErleRoverManager : using linear vel max [1560, 1440]. ErleRoverManager : using angular vel step . ErleRoverManager : using angular vel max [1900, 1100]. Reading from keyboard --------------------------- Forward/back arrows : linear velocity incr/decr. Right/left arrows : angular velocity incr/decr. Spacebar : reset linear/angular velocities. q : quit.
During the SLAM we can see how the map is built. We need to execute a node to transform the map structure to an image:
rosrun hector_compressed_map_transport map_to_image_node
image_view in the correct topic:
rosrun image_view image_view image:=/map_image/full _image_transport:=compressed
NOTE: Once we have built the desired map we cannot forget to save the map before closing the slam node.
rosrun map_server map_saver -f /tmp/map