Use SLAM Toolbox to generate a map of the environment, then utilize the Nav2 stack for autonomous navigation within that mapped space. Rviz provides visualization of the robot, its surroundings, and ongoing navigation tasks.
This package provides:
- Gazebo simulation environment.
- ROS2 Control integration to handle the robot’s joints and controllers.
- SLAM Toolbox for online (asynchronous) map building as the robot explores.
- Nav2 stack to plan paths and autonomously navigate in the mapped environment.
- Rviz2 visualization for monitoring robot state, the map, and navigation plans.
If you intend to run the auto_nav package on your local dev environment, you need to install the following. Otherwise, skip this section if you are using the Docker container.
sudo apt install ros-<distro-name>-xacro - Gazebo ROS Packages
sudo apt install ros-<distro-name>-gazebo-ros-pkgs- ROS2 Control
sudo apt install ros-<distro-name>-ros2-control ros-<distro-name>-ros2-controllers ros-<distro-name>-gazebo-ros2-control- SLAM Toolbox
sudo apt install ros-<distro-name>-slam-toolbox- Nav2 and Twist Mux
sudo apt install ros-<distro-name>-navigation2 sudo apt install ros-<distro-name>-nav2-bringup sudo apt install ros-<distro-name>-twist-muxAfter cloning this repository into your workspace’s src directory:
cd <your_ros2_ws>
colcon build
source install/setup.bash- Launch the Simulation Run the Gazebo simulation environment and spawn the robot:
ros2 launch auto_nav launch_sim.launch.py- Launch SLAM and Navigation In a new terminal (with the workspace sourced), launch the SLAM Toolbox and Nav2 bringup with Rviz:
ros2 launch auto_nav slam_navigation.launch.py use_sim_time:=true-
Use Rviz2 for Visualization: Rviz2 should start automatically from the second launch file. In Rviz2:
- You can visualize the robot’s pose, sensors, and the map being built.
- Interactively set navigation goals using the "2D Nav Goal" tool once the map and localization are stable.
-
Autonomous Navigation: Once you have a map (even partial), you can send navigation goals to the robot via Rviz. Nav2 will compute a path and command the robot to reach the desired destination.
- Launching the Simulation Environment
ros2 launch auto_nav launch_sim.launch.py- Starting the SLAM Toolbox (Online, Asynchronous Mode)
ros2 launch slam_toolbox online_async_launch.py use_sim_time:=true- Initializing the Navigation Stack
ros2 launch nav2_bringup navigation_launch.py use_sim_time:=True- Opening RViz with Navigation Visualization
ros2 run rviz2 rviz2 use_sim_time:=True -d /opt/ros/humble/share/nav2_bringup/rviz/nav2_default_view.rviz-
Simulation Issues: Ensure that Gazebo, ROS2 Control, and joint publisher packages are correctly installed.
-
TF or Robot Description Issues: Check the URDF/Xacro files and the rsp.launch.py to ensure the robot description is being published correctly.
-
Navigation Errors: Confirm that SLAM Toolbox is running and providing a map. Ensure that Nav2 parameters match your robot’s configuration (e.g., footprint, sensor sources).
- Robot Operating System (ROS 2 Humble)
- ROS 2 tf2
- ROS 2 Navigation Framework and System
- Slam Toolbox for lifelong mapping and localization in potentially massive maps with ROS
