Implement a gmapping
ROS package that is based on the Grid-based FastSLAM algorithm to map an environment.
Install packages' dependencies
$ cd ..
$ source devel/setup.bash
$ rosdep -i install turtlebot_gazebo
$ rosdep -i install turtlebot_teleop
$ rosdep install gmapping
Open a new terminal and run
$ cd <Your catkin workspace>
$ catkin_make
$ source devel/setup.bash
- turtlebot_gazebo
To use the Gazebo world file. - turtlebot_teleop
To manually control a robot using keyboard commands. - slam_gmapping
To provide SLAM capabilities.
- Open a new terminal and run
$ roslaunch turtlebot_gazebo turtlebot_world.launch world_file:=worlds/willowgarage.world
- Open another terminal and launch
$ roslaunch turtlebot_teleop keyboard_teleop.launch
- In a new terminal, run
$ rosrun gmapping slam_gmapping
- In another teminal, run
Edit the rviz configuration as follows
$ rosrun rviz rviz
- Change the Fixed Frame to map
- Keep Reference Frame as default
- Add a robot model
- Add a camera and select the /camera/rgb/image_raw topic
- Add a map and select the /map topic
- You can now map the environment by driving your robot using keyboard commands.
- (Optional) To save a map of the environment
With the map_server you can load and save maps. Running map_server will generate the map.pgm and the map.yaml files.
$ cd /home/workspace/ $ rosrun map_server map_saver -f myMap