This is the implementation of an autonomous navigation project using TurtleBot3 in a custom Gazebo world. The project integrates ROS 2 Humble, SLAM Toolbox, and a custom Dijkstra algorithm for path planning. The goal is to simulate a robot navigating through a maze-like environment, avoiding obstacles, and reaching its destination efficiently.
- SLAM (Simultaneous Localization and Mapping): Generate maps in real-time using the SLAM Toolbox.
- Custom Gazebo World: A maze world built in Gazebo for simulation.
- Custom Path Planning: Implemented Dijkstra’s algorithm to find the shortest path in the mapped environment.
- ROS 2 Navigation Stack: Used for obstacle avoidance and path following.
- Real-time Visualization: RViz is used to visualize the robot, map, and path.
cd your-ros-workspace
cd src
git clone https://github.com/AAArpan/Autonomous-Navigation-and-Path-planning-on-ROS2-using-Dijkstra-and-SLAM.git
cd ..
colcon build
sudo apt update
sudo apt install ros-humble-turtlebot3* ros-humble-slam-toolbox
export TUTRTLEBOT3_MODEL=burger
Create a world on Gazebo and save it. Copy and paste the path in turtlebot3_world.launch.py
- Launch the custom world map on Gazebo
ros2 launch turtlbot3_custom turtlebot3_world.launch.py use_sim_time:=true
- RUN SLAM to create a 2-D MAP We have to move the TurtleBot all over the map to create a precise 2-D map.
ros2 launch slam_toolbox online_async_launch.py use_sim_time:=true
ros2 run my_py_pkg robot_command_publishrer
- RVIZ for Visualization
ros2 launch nav2_bringup rviz_launch.py
- Save the Map Once the mapping is complete, save the map:
ros2 run nav2_map_server map_saver_cli -f ~/my_custom_map
This will create two files my_custom_map.pgm and my_custom_map.yaml
- Run Dijkstra'a Algorithm
python3 Dijkstra.py
Click on any 2 points on the map and you'll get the shortest path
- Run the Navigation Stack
ros2 launch turtlebot3_navigation2 navigation2.launch.py map:=/path/to/my_custom_map.yaml use_sim_time:=true
Launch Rviz and select the map topic to visualize the bot and the 2D map. Choose the same two points as before, and you will observe the bot navigating along the predicted path while efficiently avoiding obstacles.
- Map to Grid Conversion: The environment map is converted into a 2D grid where each cell is a node.
- Graph Representation: The grid is treated as a graph with adjacent cells connected as neighbors.
- Shortest Path Calculation: The Dijkstra algorithm computes the optimal path from the start to the goal.
- Path Execution: The planned path is sent to the navigation stack, and the robot follows it autonomously.