This project implements a custom robot that performs autonomous navigation using Nav2 in Gazebo while avoiding dynamic obstacles.
✅ Autonomous Navigation with ROS 2 Nav2
✅ Dynamic Obstacle Avoidance
✅ Custom C++ Node for Navigation (navigation_node
)
✅ RViz Visualization
✅ Gazebo Simulation
git clone https://github.com/Ellakiya15/ros2-dynamic-obstacle-avoidance-bot.git
cd Dynamic-obstacle-avoidance-bot
colcon build
source install/setup.bash
ros2 launch bot_gazebo spawn_robot.launch.xml
ros2 launch bot_nav navigation.launch.xml
rviz2
ros2 run bot_nav navigation_node
The ROS 2 C++ node (navigation_node) is responsible for managing navigation goals interactively.
The node sets an initial pose estimate to localize the robot in the simulated world.
The user enters a target location (x, y, yaw), and the node sends this as a goal to the Nav2 stack.
Once the robot reaches the target location, "Goal Reached" is printed in the terminal.
After reaching the goal, the user is prompted to enter a new target location. The process repeats until the user decides to exit.
[INFO] [navigation_node]: Setting initial pose...
Enter new goal (x, y, yaw): 2.0 3.5 1.57
[INFO] [navigation_node]: Navigating to (2.0, 3.5, 1.57)...
[INFO] [navigation_node]: Goal reached!
[INFO] [navigation_node]: Adding marker at (2.0, 3.5)
Enter new goal (x, y, yaw): -1.0 4.0 0.0
[INFO] [navigation_node]: Navigating to (-1.0, 4.0, 0.0)...
[INFO] [navigation_node]: Goal reached!
[INFO] [navigation_node]: Adding marker at (-1.0, 4.0)
Enter new goal (x, y, yaw): 3.0 -2.5 1.0
[INFO] [navigation_node]: Navigating to (3.0, -2.5, 1.0)...
[WARN] [navigation_node]: Goal failed!
Enter new goal (x, y, yaw):