This task involves using TurtleBot3 for autonomous navigation in a Gazebo simulation environment using ROS default planners. The steps include creating a map of the environment, traversing autonomously from point A to point B, and visualizing the robot's environment using RViz.
Ensure you have the following software installed:
- ROS (Robot Operating System)
- Gazebo
- TurtleBot3 packages
- Git
Clone the project repository:
git clone https://github.com/rishang19dx/Task_1_Autonomous_Navigation.git
cd Task_1_Autonomous_Navigation
Make sure all dependencies are installed. If not, follow these steps:
-
Install ROS and TurtleBot3 Packages:
sudo apt-get update sudo apt-get install ros-noetic-desktop-full sudo apt-get install ros-noetic-turtlebot3 ros-noetic-turtlebot3-simulations
-
Set Up Workspace:
mkdir -p ~/ws/src cd ~/ws/ catkin_make source devel/setup.bash
-
Launch Gazebo World and TurtleBot3:
export TURTLEBOT3_MODEL=burger roslaunch turtlebot3_gazebo turtlebot3_world.launch
-
Creating and saving the map:
-
Mapping the environment manually with teleoperation proved to be a bulky task to me. Hence, I used a plugin which creates 2D occupancy map of the world at a given height
-
To include the plugin, add the following line in between the tags of your Gazebo world file:
<plugin name='gazebo_occupancy_map' filename='libgazebo_2Dmap_plugin.so'> <map_resolution>0.1</map_resolution> <!-- in meters, optional, default 0.1 --> <map_height>0.3</map_height> <!-- in meters, optional, default 0.3 --> <map_size_x>100</map_size_x> <!-- in meters, optional, default 10 --> <map_size_y>100</map_size_y> <!-- in meters, optional, default 10 --> <init_robot_x>0</init_robot_x> <!-- x coordinate in meters, optional, default 0 --> <init_robot_y>0</init_robot_y> <!-- y coordinate in meters, optional, default 0 --> </plugin>
-
To generate the map, call the
/gazebo_2Dmap_plugin/generate_map
ros service:rosservice call /gazebo_2Dmap_plugin/generate_map
-
The generated map is published on the
/map2d
ros topic. -
You can use the map_saver node from the map_server package inside ros navigation to save your generated map to a .pgm and .yaml file:
rosservice call /gazebo_2Dmap_plugin/generate_map rosrun map_server map_saver -f hospital /map:=/map2d
-
The last map generated with the
/gazebo_2Dmap_plugin/generate_map
call is saved.
-
-
Launch Navigation with the Saved Map:
export TURTLEBOT3_MODEL=burger roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/hospital.yaml
-
Set Initial Pose and Goal in RViz:
Use RViz to set the initial pose of the robot and the goal location for autonomous navigation.
-
Mapping:
- A complete map of the environment will be created .
-
Autonomous Navigation:
- The robot will autonomously navigate from point A to point B using the generated map and default planners.