This ROS package implements SLAM on a 2 wheeled differential drive robot to map an unknown environment. A joystick is used to teleoperate the robot in Gazebo. The map generated is then used for autonomous navigation using the ROS Navigation stack.
$ git clone https://github.com/devanshdhrafani/diff_drive_bot.git
$ cd ..
$ catkin_make
$ sudo apt-get install ros-melodic-dwa-local-planner
$ sudo apt-get install ros-melodic-joy
The package uses slam_gmapping to map the environment. For the purpose of this demonstration, we use the Gazebo simulation environment to move around the robot.
/worlds/mybot.world
. To continue with default model:
$ roslaunch diff_drive_bot gazebo.launch
$ roslaunch diff_drive_bot gmapping.launch
$ roslaunch diff_drive_bot joy_teleop_launch.launch
OR teleop using keyboard:
$ rosrun diff_drive_bot keyboard_teleop.py
$ rosrun map_server map_saver -f ~/test_map
~/diff_drive_bot/maps/
directory and edit the .yaml file to match the path. This package uses the ROS Navigation stack to autonomously navigate through the map created using gmapping.
/launch/amcl_move_base.launch
and add map .yaml location and name to map_server node launch.$ roslaunch diff_drive_bot gazebo.launch
$ roslaunch diff_drive_bot amcl_move_base.launch
To make it easier to map environments, I added a joystick_teleop node to control the robot movement using my xbox controller. If you are using some other controller, you can easily map your buttons:
$ sudo apt-get install ros-melodic-joy
$ ls /dev/input/
/launch/joy_teleop_launch.launch
and edit the dev parameter value to /dev/input/jsX
.joy_teleop.py
script in the /scripts/
folder.joyCallback()
function.$ roslaunch diff_drive_robot joy_teleop_launch.launch
joy_teleop.py
script with your respective axes.