Skip to content
kalesha681Public

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

NavBench

ROS 2 Nav2 Path Planner Benchmark Suite

An automated, scientific benchmarking suite for evaluating, comparing, and extending path planning algorithms within the ROS 2 Navigation 2 stack — including a custom C++ A* planner plugin.

ROS 2 Humble C++17 Python License Platform

Overview

Selecting the right path planner is critical for autonomous mobile robotics. NavBench provides a reproducible framework to rigorously test and compare multiple global planners and local trajectory controllers in identical simulation conditions.

The suite features:

  • Six global planners: NavFn A*, Dijkstra, SMAC 2D, SMAC Hybrid-A*, State Lattice, and a custom-built C++ A* Nav2 plugin
  • Two local controllers: DWB and MPPI, with dynamic obstacle injection support
  • Full automation: a single shell script orchestrates the complete ROS 2 lifecycle — startup, goal execution, metric capture, and teardown — for every algorithm in sequence
  • Interactive dashboard: a Plotly HTML report with per-planner bar charts and a 2D trajectory overlay

Packages

This workspace contains two ROS 2 packages:

Package Type Purpose
navbench Python (ament_python) Benchmark orchestration, metric logging, and analysis
navbench_planners C++ (ament_cmake) Custom Nav2 global planner plugin (navbench_planners/CustomAStar)

Key Features

  • Custom C++ Planner: A production-style Nav2 GlobalPlanner plugin implementing A* with costmap-weighted edge costs, diagonal movement, and full pluginlib export — benchmarkable alongside the built-in Nav2 algorithms
  • Local Planner Benchmarking: Swap between DWB and MPPI controllers via a single launch argument; a dynamic obstacle node moves a cylinder across the robot's path to test reactive avoidance
  • End-to-End Automation: run_all_benchmarks.sh manages the full Nav2 lifecycle — monitoring /planner_server state transitions before proceeding to the next algorithm
  • Interactive Analytics: Pandas + Plotly generate a multi-panel HTML dashboard with mean ± std error bars and a 2D trajectory overlay per planner
  • Costmap Parameter Sweeping: run_costmap_sweep.sh sweeps inflation_radius across runs to find the mathematically optimal costmap configuration
  • Unit Tested Math: pytest / unittest verifies the curvature (mean κ) and Euclidean path length calculations against analytically known ground truth values
  • DevOps Ready: Multi-stage Dockerfile, GitHub Actions CI (lint + build + test), and flake8 code style enforcement

Tracked Metrics

Metric Source Description
Planning Time Action Server Time for the global planner to compute a path (ms)
Execution Time Action Server Total time for the robot to reach the goal (s)
Path Length nav_msgs/Path Euclidean arc length of the generated trajectory (m)
Mean Curvature Math Average change in path angle — lower is smoother (κ)
Recoveries /behavior_tree_log Count of recovery behaviors triggered (Spin, BackUp, etc.)
Mean/Peak CPU psutil CPU utilisation of the Nav2 planner server process (%)
Mean RAM psutil Resident memory footprint of the Nav2 planner server (MB)

System Architecture

NavBench Workspace
├── src/
│   ├── navbench/                        # Python package
│   │   ├── navbench/
│   │   │   ├── benchmark_node.py        # Async Action Client + metric capture
│   │   │   ├── metrics_logger.py        # Pandas + Plotly dashboard generator
│   │   │   └── obstacle_mover.py        # Sine-wave dynamic obstacle publisher
│   │   ├── launch/
│   │   │   ├── benchmark.launch.py      # Main launch: merges planner + controller YAMLs
│   │   │   ├── dynamic_obstacle.launch.py
│   │   │   └── bringup.launch.py
│   │   └── config/
│   │       ├── planners/                # Per-planner nav2 YAML overrides
│   │       └── controllers/             # Per-controller nav2 YAML overrides (DWB, MPPI)
│   │
│   └── navbench_planners/               # C++ package
│       ├── include/navbench_planners/
│       │   └── custom_astar_planner.hpp
│       ├── src/
│       │   └── custom_astar_planner.cpp # nav2_core::GlobalPlanner implementation
│       └── plugins.xml                  # pluginlib export
│
├── run_all_benchmarks.sh                # Orchestration entrypoint
├── run_costmap_sweep.sh                 # Parameter sweep entrypoint
├── Dockerfile
└── .github/workflows/ci.yml

Execution flow:

  1. run_all_benchmarks.sh loops over all planners, launching benchmark.launch.py for each
  2. The launch file merges nav2_params_base.yaml + the per-planner YAML and starts the full Nav2 stack
  3. benchmark_node.py (Action Client) sends waypoint goals, captures metrics via topic subscriptions and psutil, and saves timestamped CSVs
  4. After all algorithms complete, metrics_logger.py aggregates the CSVs and renders an interactive HTML dashboard

Setup & Installation

Prerequisites

sudo apt install \
  ros-humble-navigation2 \
  ros-humble-nav2-bringup \
  ros-humble-turtlebot3-gazebo

pip3 install -r requirements.txt

Build

cd ~/Documents/NavBench
source /opt/ros/humble/setup.bash
colcon build
source install/setup.bash

Usage

1. Configure Your Map & Waypoints

Point the benchmark at your map by setting the NAV_MAP_PATH environment variable:

export NAV_MAP_PATH=~/my_map.yaml

Define goal waypoints in src/navbench/config/waypoints.yaml:

/**:
  ros__parameters:
    waypoints:
      - "0.0,-2.0,0.0"   # X, Y, Yaw (radians)
      - "2.0,0.0,1.57"

2. Run All Benchmarks

./run_all_benchmarks.sh

This will sequentially benchmark all six planners (A*, Dijkstra, SMAC 2D, SMAC Hybrid, Lattice, Custom A*) and save CSVs to src/navbench/results/.

3. Run with a Specific Planner & Controller

ros2 launch navbench benchmark.launch.py \
    planner:=custom_astar \
    controller:=mppi \
    map:=$NAV_MAP_PATH

Available planners: astar | dijkstra | smac_2d | smac_hybrid | lattice | custom_astar
Available controllers: dwb | mppi

4. Dynamic Obstacle Benchmarking

In a second terminal, launch the moving cylinder obstacle while your benchmark is running:

ros2 launch navbench dynamic_obstacle.launch.py

This spawns a cylinder in Gazebo and runs obstacle_mover.py, which publishes a sinusoidal velocity to move it across the robot's path — stressing the local controller's reactive avoidance.

5. Costmap Parameter Sweep

./run_costmap_sweep.sh

Sweeps inflation_radius across a range of values to find the mathematically optimal costmap configuration for your environment.

6. Generate the Dashboard

python3 src/navbench/navbench/metrics_logger.py

Opens src/navbench/results/benchmark_dashboard.html — an interactive multi-panel Plotly report with per-planner comparisons and a 2D trajectory overlay.

7. Docker

Run the complete suite in an isolated, reproducible container:

docker build -t navbench .
docker run -it navbench

Custom C++ Planner (navbench_planners/CustomAStar)

The navbench_planners package implements a Nav2 GlobalPlanner plugin in C++17 — demonstrating how to write and integrate a custom algorithm into the Nav2 stack at the plugin level.

Key implementation details:

Aspect Implementation
Algorithm Priority-queue A* with closed-set bitmap
Heuristic Euclidean distance (admissible, optimal)
Edge cost Move cost + costmap cell cost scaled to [0, 1]
Obstacle handling Skips LETHAL_OBSTACLE and INSCRIBED_INFLATED_OBSTACLE cells
Diagonal movement Configurable via use_diagonal ROS parameter
Safety Signed-arithmetic bounds checking prevents unsigned integer underflow at map edges
Integration pluginlib export via plugins.xml — drop-in compatible with nav2_bringup

Build only the C++ package:

source /opt/ros/humble/setup.bash
colcon build --packages-select navbench_planners

Running Tests

source /opt/ros/humble/setup.bash
source install/setup.bash
colcon test --packages-select navbench
colcon test-result --verbose

Tests validate the analytical correctness of _path_length (3-4-5 triangle → 7 m) and _smoothness (90° turn → κ = √2, straight line → κ = 0).


Troubleshooting

Warning

Benchmark node hangs at startup Ensure NAV_MAP_PATH points to a valid YAML map file. Nav2 will not reach the active lifecycle state if the map cannot be loaded.

Caution

CPU / RAM metrics show 0.0 If Nav2 is not running in composition mode, component_container_isolated will not exist. Update the _find_planner_process regex in benchmark_node.py to match the process name on your system.

Note

"Goal rejected" during execution Your waypoints.yaml coordinates may land inside an obstacle or outside the map bounds. Verify them against your map using RViz.

Note

custom_astar planner not found Ensure you have built navbench_planners and sourced install/setup.bash before launching.


Future Work

  • Kinematic Constraints: Extend the custom planner to enforce a minimum turning radius for Ackermann-steering vehicles (car-like robot path planning)
  • Hardware Deployment: Extend orchestration scripts to run on a physical TurtleBot3 over Wi-Fi
  • Algorithmic Profiling: Add Valgrind / perf flamegraph analysis of the C++ planner to characterise memory allocation and cache behaviour
  • RRT* / D* Lite Plugin: Implement additional sampling-based and incremental planners as further navbench_planners plugins

License

This project is licensed under the Apache 2.0 License — see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages