In this tutorial, we do some SLAM with TurtleBot robot.
1.Before anything, you have to install all packages for gazebo and gmapping and TurtleBot:
1 |
sudo apt-get install ros-kinetic-gmapping ros-kinetic-turtlebot-gazebo ros-kinetic-turtlebot-simulator ros-kinetic-turtlebot-teleop ros-kinetic-turtlebot-rviz-launchers |
2.Launch gazebo and TurtleBot
1 |
roslaunch turtlebot_gazebo turtlebot_world.launch |
3. Call the gmapper to read laser scan and build the map:
1 |
roslaunch turtlebot_gazebo gmapping_demo.launch |
Only for indigo:
if you got and error, you need to do some hacky stuff and following changes some
1 |
sudo gedit /opt/ros/indigo/share/turtlebot_gazebo/launch/gmapping_demo.launch |
comment this line:
1 |
<include file="$(find turtlebot_navigation)/launch/includes/gmapping.launch.xml"/> |
and add the following line:
1 |
<include file="$(find turtlebot_navigation)/launch/includes/gmapping/gmapping.launch.xml"/> |
so at the end, your file should look like this:
1 2 3 4 |
<launch> <include file="$(find turtlebot_navigation)/launch/includes/gmapping/gmapping.launch.xml"/> <!-- <include file="$(find turtlebot_navigation)/launch/includes/gmapping.launch.xml"/> --> </launch> |
4.Call the rviz so you can see the map:
1 |
roslaunch turtlebot_rviz_launchers view_navigation.launch |
5.Move your robot via keyboard or joystick controller:
1 |
roslaunch turtlebot_teleop keyboard_teleop.launch |
1 |
roslaunch turtlebot_teleop logitech.launch |
or
1 |
roslaunch turtlebot_teleop xbox360_teleop.launch |
or
1 |
roslaunch turtlebot_teleop ps3_teleop.launch |
To make your joystick controller works, you have to hold the “axis_deadman” button. This has been specified in the corresponding launch file. For instance for xbox360 controller edit
1 |
sudo gedit /opt/ros/indigo/share/turtlebot_teleop/launch/xbox360_teleop.launch |
you can see, in this file, it has been assigned to 4
1 |
<param name="axis_deadman" value="4"/> |
To see which button on your controller has been assigned to “axis_deadman”, run
1 |
sudo jstest /dev/input/js |
and press all buttons one by one until you see which button is 4″
now you have to keep pressing that button for sending a command from your controller. You can watch the state of each button by listening to the /joy topic:
1 |
rostopic echo /joy |
Now start adding objects into gazebo scene and start exploring the environment, you should see the map:
[…] to learn how to move the robot with your joystick controller please follow my other tutorial on that here […]