Skip to content

5.4 Nav2 Integration

AntBot can perform autonomous navigation using Nav2, the official ROS 2 navigation framework. To run in simulation, 5.3 Simulation Environment Setup must be completed first.

Nav2 Pipeline


The Nav2, SLAM Toolbox, robot localization, MPPI, and RPP controller dependencies are declared in antbot_navigation/package.xml, so they can be installed with rosdep from the workspace root.

Terminal window
rosdep install --from-paths src --ignore-src -r -y

To install them manually, use:

Terminal window
sudo apt install ros-humble-navigation2 ros-humble-nav2-bringup \
ros-humble-slam-toolbox ros-humble-robot-localization \
ros-humble-nav2-mppi-controller \
ros-humble-nav2-regulated-pure-pursuit-controller

Terminal window
cd ~/ros2_ws
colcon build --symlink-install --packages-up-to antbot_navigation
source install/setup.bash

Launch filePurposeFeatures
navigation.launch.pyAutonomous driving with saved mapAMCL + full Nav2 stack
slam.launch.pyBuild map while navigatingSLAM Toolbox (no pre-built map needed)
localization.launch.pyLocalization onlyNo path planning

All launch files accept a mode argument to switch between simulation and real robot:

Terminal window
ros2 launch antbot_navigation slam.launch.py mode:=sim # Simulation
ros2 launch antbot_navigation slam.launch.py mode:=real # Real robot

  1. Start Gazebo simulation

    Terminal window
    # Terminal 1
    ros2 launch antbot_gazebo gazebo.launch.py world:=depot
  2. Start Nav2 navigation

    Terminal window
    # Terminal 2
    ros2 launch antbot_navigation navigation.launch.py mode:=sim world:=depot
  3. RViz visualization

    Terminal window
    # Terminal 3
    rviz2 -d $(ros2 pkg prefix antbot_navigation --share)/rviz/navigation.rviz \
    --ros-args -p use_sim_time:=true

Save a map generated in SLAM mode:

Terminal window
ros2 run nav2_map_server map_saver_cli -f ~/maps/my_map

To navigate using the saved map:

Terminal window
ros2 launch antbot_navigation navigation.launch.py mode:=sim \
map:=/path/to/my_map.yaml

  1. Start AntBot bringup

    Terminal window
    # Terminal 1
    ros2 launch antbot_bringup bringup.launch.py
  2. Start Nav2 navigation

    Terminal window
    # Terminal 2
    ros2 launch antbot_navigation navigation.launch.py mode:=real
  3. RViz visualization (from remote PC)

    Terminal window
    # Terminal 3
    rviz2 -d $(ros2 pkg prefix antbot_navigation --share)/rviz/navigation.rviz

Save a map generated in SLAM mode:

Terminal window
ros2 run nav2_map_server map_saver_cli -f ~/maps/my_map

To navigate using the saved map:

Terminal window
ros2 launch antbot_navigation navigation.launch.py mode:=real \
map:=/path/to/my_map.yaml

Single Goal

  1. In RViz, click 2D Pose Estimate to set the initial position

  2. Click Nav2 Goal to specify the target position

Multi-Waypoint Following

  1. Open RViz

  2. Panels → Add New Panel → select nav2_rviz_plugins/Navigation2

  3. Check Waypoint Mode and click multiple goals on the map

  4. Click Start Waypoint Following

Goal via CLI

Terminal window
# Send navigation goal to coordinates (x: 5.0, y: 3.0) in map frame
ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose \
"{pose: {header: {frame_id: 'map'}, pose: {position: {x: 5.0, y: 3.0}}}}"

© 2026 ROBOTIS AI. All rights reserved.