Skip to main content

Nav2 Path Planning for Bipedal Robots

Learning Objectives

After completing this chapter, you will be able to:

  • Configure Nav2 for humanoid robot navigation in complex environments
  • Implement path planning algorithms optimized for bipedal locomotion
  • Set up navigation parameters specific to humanoid robots
  • Integrate Nav2 with perception systems for autonomous navigation

Introduction

Navigation 2 (Nav2) is the latest navigation stack for ROS 2, designed to provide robust and flexible navigation capabilities for mobile robots. For humanoid robots, Nav2 requires special configuration to account for the unique challenges of bipedal locomotion, including balance constraints, limited turning ability, and the need for stable, predictable gait patterns.

In the context of Physical AI & Humanoid Robotics, Nav2 serves as the navigation middleware that transforms high-level goals into executable robot motion. The stack includes global planning for long-term pathfinding and local planning for obstacle avoidance and real-time adjustments, both of which must be tuned specifically for the kinematic and dynamic constraints of bipedal robots.

Core Concepts

Nav2 consists of multiple layers that work together to enable autonomous navigation:

Global Planner

  • Plans the overall path from start to goal
  • Considers static map and general obstacle locations
  • Outputs a sequence of waypoints
  • For humanoid robots, must account for step constraints and balance

Local Planner

  • Adjusts the path in real-time based on sensor data
  • Handles dynamic obstacles and unexpected situations
  • Controls low-level robot motion
  • For bipedal robots, ensures stable, step-by-step movement

Costmap

  • Maintains spatial representation of obstacles
  • Updates based on sensor data
  • Includes inflation layers for safety margins
  • For humanoid robots, may need special zones for step planning

Behavior Trees

  • Orchestrates navigation behaviors
  • Manages transitions between states
  • Handles recovery behaviors
  • Customizable for humanoid-specific needs

Hands-on Examples

Let's configure Nav2 for humanoid robot navigation:

# humanoid_nav2_params.yaml
amcl:
ros__parameters:
use_sim_time: True
alpha1: 0.2
alpha2: 0.2
alpha3: 0.2
alpha4: 0.2
alpha5: 0.2
base_frame_id: "base_footprint"
beam_skip_distance: 0.5
beam_skip_error_threshold: 0.9
beam_skip_threshold: 0.3
do_beamskip: false
global_frame_id: "map"
lambda_short: 0.1
laser_likelihood_max_dist: 2.0
laser_max_range: 10.0
laser_min_range: -1.0
laser_model_type: "likelihood_field"
max_beams: 60
max_particles: 2000
min_particles: 500
odom_frame_id: "odom"
pf_err: 0.05
pf_z: 0.5
recovery_alpha_fast: 0.0
recovery_alpha_slow: 0.0
resample_interval: 1
robot_model_type: "nav2_amcl::DifferentialMotionModel"
save_pose_rate: 0.5
sigma_hit: 0.2
tf_broadcast: true
transform_tolerance: 1.0
update_min_a: 0.2
update_min_d: 0.25
z_hit: 0.5
z_max: 0.05
z_rand: 0.5
z_short: 0.05
scan_topic: scan

amcl_map_client:
ros__parameters:
use_sim_time: True

amcl_rclcpp_node:
ros__parameters:
use_sim_time: True

bt_navigator:
ros__parameters:
use_sim_time: True
global_frame: map
robot_base_frame: base_link
odom_topic: /odom
bt_loop_duration: 10
default_server_timeout: 20
enable_groot_monitoring: True
groot_zmq_publisher_port: 1666
groot_zmq_server_port: 1667
# Custom humanoid behavior tree
plugin_lib_names:
- nav2_compute_path_to_pose_action_bt_node
- nav2_follow_path_action_bt_node
- nav2_back_up_action_bt_node
- nav2_spin_action_bt_node
- nav2_wait_action_bt_node
- nav2_clear_costmap_service_bt_node
- nav2_is_stuck_condition_bt_node
- nav2_have_docking_goals_condition_bt_node
- nav2_is_battery_low_condition_bt_node
- nav2_is_battery_charging_condition_bt_node
- nav2_recharge_battery_action_bt_node
- nav2_dock_robot_action_bt_node
- nav2_is_docked_condition_bt_node
- nav2_initial_pose_received_condition_bt_node
- nav2_docking_reached_condition_bt_node
- nav2_is_path_valid_condition_bt_node

bt_navigator_rclcpp_node:
ros__parameters:
use_sim_time: True

controller_server:
ros__parameters:
use_sim_time: True
controller_frequency: 20.0
min_x_velocity_threshold: 0.05
min_y_velocity_threshold: 0.05
min_theta_velocity_threshold: 0.1
# Humanoid-specific controller
progress_checker_plugin: "progress_checker"
goal_checker_plugin: "goal_checker"
controller_plugins: ["FollowPath"]

# Humanoid FollowPath Controller
FollowPath:
plugin: "nav2_mppi_controller::MppiController" # Or use DWB with humanoid constraints
time_steps: 20
control_freq: 20
discr_time: 0.2
reference_scale: 1.0
cmd_timeout: 1.0
# Humanoid-specific parameters
max_speed: 0.5 # Lower for stability
min_speed: 0.1
max_accel: 0.5 # Lower for balance
max_decel: 0.5
max_angular_velocity: 0.5 # Limited turning for bipedal stability
max_linear_velocity: 0.4 # Slower for balance
min_linear_velocity: 0.05
# Humanoid step constraints
step_width: 0.1 # Distance between feet
step_length: 0.2 # Max step length

progress_checker:
plugin: "nav2_controller::SimpleProgressChecker"
required_movement_radius: 0.5
movement_time_allowance: 10.0

goal_checker:
plugin: "nav2_controller::SimpleGoalChecker"
xy_goal_tolerance: 0.2
yaw_goal_tolerance: 0.2
stateful: True

controller_server_rclcpp_node:
ros__parameters:
use_sim_time: True

# Global costmap for humanoid navigation
global_costmap:
global_costmap:
ros__parameters:
update_frequency: 1.0
publish_frequency: 1.0
global_frame: map
robot_base_frame: base_link
use_sim_time: True
# Humanoid-specific parameters
rolling_window: false
width: 20
height: 20
resolution: 0.05 # Higher resolution for precise foot placement
origin_x: -10.0
origin_y: -10.0
# Plugins
plugins: ["static_layer", "obstacle_layer", "inflation_layer"]
obstacle_layer:
plugin: "nav2_costmap_2d::ObstacleLayer"
enabled: True
observation_sources: scan
scan:
topic: /scan
max_obstacle_height: 2.0
clearing: True
marking: True
data_type: "LaserScan"
raytrace_max_range: 10.0
raytrace_min_range: 0.0
obstacle_max_range: 8.0
obstacle_min_range: 0.0
static_layer:
plugin: "nav2_costmap_2d::StaticLayer"
map_subscribe_transient_local: True
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 3.0
inflation_radius: 0.5 # Larger for humanoid safety
always_send_full_costmap: True

global_costmap_rclcpp_node:
ros__parameters:
use_sim_time: True

# Local costmap for humanoid navigation
local_costmap:
local_costmap:
ros__parameters:
update_frequency: 5.0
publish_frequency: 2.0
global_frame: odom
robot_base_frame: base_link
use_sim_time: True
# Humanoid-specific parameters
rolling_window: True
width: 5 # Smaller for humanoid immediate area
height: 5
resolution: 0.05 # Higher resolution for foot placement
# Plugins
plugins: ["obstacle_layer", "voxel_layer", "inflation_layer"]
obstacle_layer:
plugin: "nav2_costmap_2d::ObstacleLayer"
enabled: True
observation_sources: scan
scan:
topic: /scan
max_obstacle_height: 2.0
clearing: True
marking: True
data_type: "LaserScan"
raytrace_max_range: 5.0
raytrace_min_range: 0.0
obstacle_max_range: 4.0
obstacle_min_range: 0.0
voxel_layer:
plugin: "nav2_costmap_2d::VoxelLayer"
enabled: True
publish_voxel_map: True
origin_z: 0.0
z_resolution: 0.2
z_voxels: 8
max_obstacle_height: 2.0
mark_threshold: 0
observation_sources: scan
scan:
topic: /scan
max_obstacle_height: 2.0
clearing: True
marking: True
data_type: "LaserScan"
raytrace_max_range: 5.0
raytrace_min_range: 0.0
obstacle_max_range: 4.0
obstacle_min_range: 0.0
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 5.0 # Higher for safety
inflation_radius: 0.4 # Adjusted for humanoid
always_send_full_costmap: True

local_costmap_rclcpp_node:
ros__parameters:
use_sim_time: True

# Planner server for global path planning
planner_server:
ros__parameters:
expected_planner_frequency: 2.0
use_sim_time: True
planner_plugins: ["GridBased"]
GridBased:
plugin: "nav2_navfn_planner::NavfnPlanner"
tolerance: 0.5
use_astar: false
allow_unknown: true
# Humanoid-specific constraints
downsample_costmap: false
downsampling_factor: 1
# Ensure path follows walkable surfaces
use_final_approach_orientation: false

planner_server_rclcpp_node:
ros__parameters:
use_sim_time: True

# Recovery server for handling navigation failures
recoveries_server:
ros__parameters:
costmap_topic: local_costmap/costmap_raw
footprint_topic: local_costmap/published_footprint
cycle_frequency: 10.0
recovery_plugins: ["spin", "backup", "wait"]
recovery_plugin_types: ["nav2_recoveries::Spin", "nav2_recoveries::BackUp", "nav2_recoveries::Wait"]
spin:
plugin: "nav2_recoveries::Spin"
# Humanoid-specific parameters
spin_dist: 0.5 # Reduced for stability
time_allowance: 10
backup:
plugin: "nav2_recoveries::BackUp"
# Humanoid-specific parameters
backup_dist: 0.3 # Reduced for safety
backup_speed: 0.05
time_allowance: 10
wait:
plugin: "nav2_recoveries::Wait"
wait_duration: 5

robot_state_publisher:
ros__parameters:
use_sim_time: True

Expected Output:

[INFO] [1678882844.123456789] [bipedal_controller]: Bipedal Controller initialized
[INFO] [1678882844.123456789] [bipedal_controller]: Received path with 15 waypoints
[INFO] [1678882844.123456789] [bipedal_controller]: Executing step, phase: 0
[INFO] [1678882844.923456789] [bipedal_controller]: Executing step, phase: 1
[INFO] [1678882845.723456789] [bipedal_controller]: Executing step, phase: 0
[INFO] [1678882850.123456789] [bipedal_controller]: Reached navigation goal

Exercises

Complete the following exercises to reinforce your understanding:

  1. Gait Optimization: Implement different walking gaits for various situations

    • Create a stable walking gait for normal conditions
    • Implement a cautious gait for narrow passages
    • Design a faster gait for open areas (with stability checks)
    • Test gait transitions and smoothness
  2. Balance Control: Add balance control to the navigation system

    • Integrate IMU data for balance feedback
    • Implement corrective actions for balance recovery
    • Add step placement optimization for stability
    • Test navigation on uneven terrain

Common Pitfalls and Solutions

  • Pitfall 1: Instability during turning - Bipedal robots are prone to falling during turns
    • Solution: Reduce turning speed and implement step-by-step rotation
  • Pitfall 2: Navigation failures in narrow spaces - Standard planners don't account for bipedal constraints
    • Solution: Configure costmaps with appropriate inflation and footprint
  • Pitfall 3: Timing issues with step control - Steps not synchronized properly
    • Solution: Implement precise timing control and phase tracking
  • Pitfall 4: Inefficient path planning - Paths don't consider bipedal movement patterns
    • Solution: Use path optimization that considers step constraints

Summary

  • Nav2 requires special configuration for humanoid robots
  • Bipedal locomotion constraints affect path planning and execution
  • Step-by-step control is essential for stability
  • Balance and gait considerations are critical for humanoid navigation
  • Proper tuning of navigation parameters improves performance

Further Reading