This repository contains the code of description, mapping, localization, and navigation for a prototype using C++ and Python. gmapping package is used to create the map and save it to be used in navigation later in navigation using the SLAM algorithm. Sending goals is implemented in two different ways, GUI in Rviz and C++ node
cd catkin_ws/src
- Clone this repo here:
git clone "https://github.com//ROS_Prototype"
cd ..
(Go back to catkin_ws/)catkin_make
Open a terminal and rungedit .bashrc
and add this line in it
source {add_location_to_devel_folder}/setup.bash
To launch the urdf prototype description
model in Gazebo
open a new terminal and write:
roslaunch slam gazebo.launch
To start moving robot in gazebo
In a new terminal:
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
To start to view the simulated robot model and take information from the robot's camera,
In a new terminal:
rviz rviz
Run these commands in two different terminal tabs
roslaunch slam gazebo.launch
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Run SLAM, in a new terminal:
roslaunch slam gmapping.launch
In a new terminal,
Run RVIZ :
cd catkin_ws/src/slam/rviz
rviz -d map.rviz
To create a map of your environment, drive the robot around the environment you want to map.
map.mp4
Once you completed mapping the whole environment, save the map:
rosrun map_server map_saver ~/catkin_ws/src/slam/maps/name_of_map
Autonomous Navigation can be done using the following -- giving the final destination:
launch the urdf model in Gazebo
In a new terminal:
roslaunch slam gazebo.launch
Run RVIZ :
cd catkin_ws/src/slam/rviz
rviz -d navigate.rviz
Using the amcl package for localization, Run amcl.launch
. The amcl algorithm implements Monte Carlo localization for state estimation.
We will use amcl with a map built in the previous step. In the second part, we will create our map using the gmapping package and then use the resulting map for localization.
roslaunch slam amcl.launch map:='name_of_map'
The move_base package implements an action that will attempt to reach it with a prototype base. This node links a global and local planner to accomplish its global navigation task. The move_base node also maintains two costmaps, one for the global planner and another for a local planner that are used to accomplish navigation tasks. Run move_base.launch
.
roslaunch slam move_base.launch
prototype_nav_gui.mp4
- Red arrows indicate the probable location.
- Set a goal for the robot in RVIZ (Click "2D Nav goal" and pinpoint the desired location and direction on the map).
- Green line indicates the path planned.
- It avoids obstacles "according to the pre-saved map" and also
Dynamic obstacles
that are added when it navigates.
launch the urdf model in Gazebo
On a new terminal:
roslaunch slam gazebo.launch
Run RVIZ :
cd catkin_ws/src/slam/rviz
rviz -d navigate.rviz
Run amcl.launch
, giving the name of the map you have created and saved:
roslaunch slam amcl.launch map:='name_of_map'
Run move_base.launch :
roslaunch slam move_base.launch
Run the move_robot node that sends the goal to navigation-stack
rosrun move_robot move_robot
move_robot.mp4
- The desired rooms/final goals location are predefined through the user and mapped to i.e. letters A, B, C, and D.
- Each letter indicates the coordinate of the room.
- While ROS System is run in this mode, the user is asked to the next destination.