X2 Open-Source Navigation (Nav2)
An open-source navigation stack built on Nav2: global planning (SmacPlanner2D) + local obstacle avoidance (RPP controller) + recovery behavior tree, publishing /cmd_vel to the motion control through a bridge node. The source ships with the SDK under extra/pnc/ (a git submodule); localization is not included — it reuses an external map -> base_link TF (closed-source LIO or the open-source SLAM).
Note
Use this chapter when you need to inspect or modify the planning algorithms, tune navigation parameters, or do navigation-level development: replace the built-in navigation with open-source Nav2.
If you are using the robot’s built-in closed-source navigation interface (the /aima/te/pnc_task_request task request and /task_master/state status topic), see Navigation (optional). The two are independent stacks; use only one at a time.
Differences from the built-in navigation
The robot has two independent navigation stacks: the open-source Nav2 navigation in this chapter and the built-in closed-source navigation module. They are mutually exclusive through the MC input source (see “Motion-control input source takeover”). Key differences:
Aspect |
This chapter (open-source Nav2 navigation) |
Navigation (optional) (built-in module) |
|---|---|---|
Delivery form |
|
Built into the robot firmware, no source delivered |
Planning algorithms |
Nav2 (SmacPlanner2D global + RPP local + recovery behavior tree) |
Closed-source PnC implementation |
Localization source |
Not included; reuses an external |
Built-in LIO localization |
Map source |
Closed-source on-disk map or standard pgm/yaml (can consume open-source SLAM output) |
Built-in map management |
Command path |
|
Built-in task pipeline |
Intended users |
Users who need to inspect/modify planning algorithms, tune parameters, or do secondary development |
Users who only need navigation functionality |
Component overview
extra/pnc/ is a single-package layout (src/open_pnc_bringup); one launch file starts all components:
Component |
Role |
Enabled when |
|---|---|---|
|
Global static map source (disk: reads and merges the closed-source on-disk map / pcd: reads a standard pgm/yaml) → |
|
|
|
|
|
Closed-source 2.5D obstacles |
Automatic by |
Nav2 loop |
|
Always started (delayed by |
|
Subscribes the real-time |
Reserved: implemented but not embedded in the launch; start it manually (see “Integration with the open-source SLAM”) |
map_server/amcl are not started (localization reuses the external TF); velocity_smoother is not started (jerk smoothing is done inside cmd_vel_bridge).
Prerequisites
Confirm each software and runtime requirement below before you start — any unmet item will make the launch fail or behave abnormally:
Item |
Requirement |
|---|---|
OS |
Ubuntu 22.04 + ROS 2 Humble |
Nav2 |
|
Localization |
An external |
Closed-source PnC |
Must be stopped before real-robot motion (the two planners would fight over |
aimdk environment |
Baked in by the launch automatically ( |
Installing Nav2
ros-humble-desktop does not include the Nav2 executable nodes; installing only libraries such as nav2_costmap_2d is not enough either (they are transitive dependencies of other packages, and nodes like controller_server are still missing — the launch reports package 'nav2_controller' not found and exits):
sudo apt-get update
sudo apt-get install -y ros-humble-navigation2
After installation verify that all 7 nodes are present and versions match (when running the same parameter set on multiple machines, keep versions consistent, otherwise parameter names may not line up):
for p in nav2_controller nav2_planner nav2_bt_navigator nav2_behaviors \
nav2_lifecycle_manager nav2_smac_planner nav2_regulated_pure_pursuit_controller; do
printf "%-42s %s\n" "$p" "$(ls -d /opt/ros/humble/share/$p >/dev/null 2>&1 && echo OK || echo MISSING)"
done
Building
Once the dependencies are in place, build the workspace — it produces a single bringup package:
cd extra/pnc
colcon build --packages-select open_pnc_bringup
source install/setup.bash
Quick start
Prerequisite: have the robot localized onto the map and stay in localization mode — the check is that ros2 run tf2_ros tf2_echo map base_link prints the transform continuously.
cd extra/pnc && source install/setup.bash
# 2A) Closed-source localization + closed-source on-disk map (default disk mode)
ros2 launch open_pnc_bringup open_pnc.launch.py \
map_path:=/agibot/data/var/MapManagerModule/<map_id>
# 2B) Self-hosted localization + mapping-produced pgm/yaml (pcd mode; the map can come from the open-source SLAM output)
ros2 launch open_pnc_bringup open_pnc.launch.py map_source:=pcd \
map_path:=<map2d-dir>/<name>.yaml
# 2C) Software-only validation without touching the robot (watch plans in RViz)
ros2 launch open_pnc_bringup open_pnc.launch.py use_cmd_vel_bridge:=false
Map source
open_pnc needs a map_server-format 2D grid (.pgm + .yaml) as the global static map; the two values of map_source correspond to two sources:
disk — read the closed-source map package (default)
map_path points to the closed-source map directory /agibot/data/var/MapManagerModule/<map_id>/. static_map_bridge reads occupancy_map.png/yaml from the disk, merges the closed-source 2.5D obstacles (grid_map_bridge enabled automatically), and publishes /open_pnc/static_map. This is mandatory when using closed-source localization, and map_path must match the map_id currently used by the closed-source localization — otherwise the costmap and the localization TF end up in mismatched frames.
pcd — read a standard pgm/yaml
map_path points to a standard map_server-format .yaml (bottom-left origin convention). This is exactly what the open-source SLAM mapping flow produces (pgm/yaml under map2d/), so it plugs in without any conversion tool.
Integration with the open-source SLAM
rtabmap_map_bridge subscribes to RTAB-Map’s real-time /map (grows while mapping, with built-in ray clearing) as the Nav2 global static map, for navigate-while-mapping scenarios. The node is implemented but not embedded in the launch (reserved); start it manually outside the launch, and turn off the default static_map_bridge at the same time (both publish the same topic; only one may run):
# Terminal 1: start open_pnc in pcd mode (the static map now comes from rtabmap_map_bridge)
ros2 launch open_pnc_bringup open_pnc.launch.py map_source:=pcd \
use_static_map_bridge:=false map_path:=<placeholder>
# Terminal 2: start rtabmap_map_bridge manually (source the open-source SLAM workspace and its install space first)
ros2 run open_pnc_bringup rtabmap_map_bridge
Attention
rtabmap_map_bridge is a reserved feature; for parameter behavior refer to the comments in the source code. Validate it in simulation before on-robot use.
cmd_vel_bridge safety mechanisms
cmd_vel_bridge converts Nav2’s /cmd_vel output into motion-control velocity commands, with built-in multi-layer safety mechanisms (all parameters overridable in the launch):
Mechanism |
Default |
Behavior |
|---|---|---|
Watchdog |
0.3 s |
Zeroes the target when no new |
Deadzone |
0.005 |
Velocity components below the deadzone are zeroed |
Minimum speed |
forward/lateral 0.2, angular 0.1 |
Speeds between the deadzone and the minimum are raised to the minimum (otherwise the robot stalls inside the deadzone) |
Jerk limiting |
[2.5, 2.5, 10.0] |
Ruckig applies velocity-level jerk limiting on the three DOF (forward/lateral/angular) (control period 0.02 s) |
Motion-control input source takeover
The core mechanism of navigation taking over motion control, with its accompanying risks, is as follows — confirm each item before real-robot motion:
Warning
At startup cmd_vel_bridge takes over the MC input source via SetMcInputSource (priority 70); during real-robot motion the navigation commands own motion control:
Stop the closed-source PnC before taking over, otherwise the two planners fight over
/cmd_veland the MC input source with unpredictable behavior;The open-source SLAM cold-start flow (waist sweep etc.) and navigation contend for the input source in a strict order: finish the localization cold start first, then start navigation;
During validation, keep the robot suspended off the ground, or first watch the plans only with
use_cmd_vel_bridge:=false;When handing control back after navigation ends, mind the leftover-input-source issue (same as the open-source SLAM waist sweep).
Common launch parameters
The table lists common parameters; for Nav2 parameter details see the comments inside config/*.yaml, and for the recovery behavior-tree layout see behavior_trees/open_pnc_recovery.xml:
Parameter |
Default |
Description |
|---|---|---|
|
|
|
|
Closed-source map (built-in example id) |
disk = map directory / pcd = a |
|
|
Set |
|
|
Whether to take over the MC input source (only needed for real-robot motion; stop the closed-source PnC first) |
|
|
Static map bridge switch (mutually exclusive with |
|
empty (automatic) |
empty = automatic by |
|
empty (automatic) |
empty = selected by |
|
|
Seconds to delay the Nav2 start (lets the static map latch first, preventing the costmap from staying at the default 5×5) |
Troubleshooting
Locate common problems by symptom; each entry gives what to check and how to handle it:
The launch reports
package 'nav2_controller' not foundand exits: Nav2 is missing or only libraries were installed — installros-humble-navigation2per “Installing Nav2” and verify all 7 nodes with the loop command.The robot does not move and nothing reports an error: check whether
/cmd_velhas output (ros2 topic echo /cmd_vel) — no output means a Nav2-side problem (unreachable goal / abnormal costmap); output present but no motion means a motion-control-side problem (input source takeover failed, or a higher priority holds it).The costmap is only the default 5×5 patch: the static map did not latch in time — check that
nav2_start_delayis large enough (raise it for slow disks or large maps), and that the static map topic has data.The localization TF does not line up with the map (the robot “floats” outside the map in RViz): in disk mode
map_pathdoes not match the map_id currently used by the closed-source localization — the two must come from the same source.Abnormal behavior when the closed-source PnC is running too: the two planners fight over
/cmd_veland the MC input source — per “Motion-control input source takeover”, stop the closed-source PnC before starting this stack.
Upstream and license
This stack builds on the open-source Nav2 stack (Apache-2.0, installed via apt, not distributed inside the submodule); the code in the submodule is AgiBot’s in-house bridge and configuration layer. Nav2 upstream: https://github.com/ros-navigation/navigation2.