REMINDER: configure your environment before starting this tutorial.
First of all we are going to download hector_mapping ROS package. This package is a SLAM approach that can be used without odometry and even in platforms that exhibit roll/pitch motion (of the sensor, the platform or both). It reads the laser from the rover and returns 2D pose estimation.
Download and compile this package by running:
cd ~/simulation/ros_catkin_ws/src git clone https://github.com/tu-darmstadt-ros-pkg/hector_slam cd ~/simulation/ros_catkin_ws source devel/setup.bash catkin_make --pkg hector_mapping
Before launching the simulation, we are going to modify to set the base and odom frames for the SLAM node to be able to create the map. Modify
hector_mapping/launch/mapping_default.launch and replace
<arg name="base_frame" default="base_footprint"/> <arg name="odom_frame" default="nav"/>
<arg name="base_frame" default="sonar2_link"/> <arg name="odom_frame" default="sonar2_link"/>
Now, let's launch the simulation.
source ~/simulation/ros_catkin_ws/devel/setup.bash cd ~/simulation/ardupilot/APMrover2 ../Tools/autotest/sim_vehicle.sh -j 4 -f Gazebo # once MAVProxy has launched completely, load the parameters param load /[path_to_your_home_directory]/simulation/ardupilot/Tools/Frame_params/3DR_Rover.param # NOTE: replace [path_to_your_home_directory] with the actual path to your home directory. # Example: param load /home/john/simulation/ardupilot/Tools/Frame_params/3DR_Rover.param param set SYSID_MYGCS 1
In another terminal
source ~/simulation/ros_catkin_ws/devel/setup.bash roslaunch ardupilot_sitl_gazebo_plugin rover_maze.launch
This will spawn the Erle-Rover inside a maze.
Run the SLAM node by running:
cd ~/simulation/ros_catkin_ws source devel/setup.bash roslaunch hector_mapping mapping_default.launch
To see the map that the node is publishing, you can use rviz (install it by running
sudo apt-get install ros-indigo-rviz if you haven't already):
rosrun rviz rviz
Once rviz has been launched, add a new display (Ctrl+N) and inside the
By Topic tab select
/map and press OK.
Then, on the left panel, in
Display>Global Options>Fixed Frame select
Now you should be able to see the following, which is the partial map generated by the SLAM node:
If we want the SLAM node to generate the whole map, we should move the rover through the maze like we did in the 2nd tutorial. Run the explorer node by running:
cd ~/simulation/ros_catkin_ws source devel/setup.bash rosrun erle_rover_explorer erle_rover_explorer.py
This will open the following window and start moving the rover trough the maze
The blue lines represent the laser readings and the red line the direction that the rover needs to follow. The number is simply the angle that the line has with the Y axis.
Once the rover has exited the maze, you should be able to see the final result of the map in rviz.
Which is pretty similar to the original: