In this tutorial, you will learn how to perform autonomous navigation in ROS2 using the Nav2 stack with integrated Behavior Trees (BT). The Nav2 framework provides a powerful modular system that allows robots to navigate in a known map using planning, localization, and behavior control components.
Launch the full Nav2 stack including AMCL and map loading:
ros2 launch nav2_bringup bringup_launch.py use_sim_time:=True map:=/path/to/map.yaml
In RViz, click on the ‘Nav2 Goal’ tool and select a target pose. This will initiate the autonomous navigation behavior tree to begin planning and execution.
Nav2 uses a Behavior Tree (BT) to structure the navigation task. This BT includes conditions and actions like path planning, obstacle checking, controller execution, and recovery behaviors. You can visualize the current tree being executed by launching the Behavior Tree visualizer:
ros2 run nav2_bt_navigator bt_navigator_cli –print_tree
If all goes well, the robot should reach the target location while avoiding obstacles. You can monitor the result in RViz or through logs. On success, the BT transitions to an idle state.
– Robot doesn’t move:
ensure all Nav2 nodes are running (e.g., controller_server, planner_server).
– Planning failed:
check the map and robot pose accuracy.
– BT gets stuck:
verify the recovery behaviors are active and well defined in the XML tree.
– Localization drift:
use AMCL parameters tuning or re-initialize robot pose in RViz.