Smac planner 2d

From wimblerobotics/ros2-copilot-skills · View interactive version

Smac planner 2d is an AI agent skill from the GitHub repository wimblerobotics/ros2-copilot-skills. Configure Nav2 SMAC 2D planner. Use when using 8-connected grid search, setting maximum_iterations, or cost penalties.

How to use this skill

Skill file

<!--

SPDX-FileCopyrightText: 2026 Michael Wimble

SPDX-License-Identifier: Apache-2.0

-->


name: smac-planner-2d

description: 'Configure Nav2 SMAC 2D planner. Use when using 8-connected grid search, setting maximum_iterations, or cost penalties.'


SMAC Planner 2D

Plugin

nav2_smac_planner::SmacPlanner2D

Algorithm

A* search on an 8-connected 2D costmap grid with a Wavefront (breadth-first) heuristic. Operates directly on the occupancy grid without considering robot kinematics. Produces grid-aligned paths that follow cell centers, then applies an optional internal smoother.

The Wavefront heuristic precomputes exact grid distances from the goal, accounting for obstacles. This makes the heuristic admissible and consistent, guaranteeing optimal paths on the grid.

Key Parameters

| Parameter | Type | Default | Description |

|-----------|------|---------|-------------|

| tolerance | double | 0.25 | Goal tolerance in costmap cells (not meters). If the exact goal cell is occupied, the planner accepts a goal within this many cells. |

| max_iterations | int | 1000000 | Maximum A* expansion iterations before failure. Increase for very large maps. |

| max_on_approach_iterations | int | 1000 | After first finding a path within tolerance, how many more iterations to try improving it. |

| max_planning_time | double | 2.0 | Hard time limit in seconds. Planning fails if exceeded. |

| allow_unknown | bool | true | If true, treats unknown cells (NO_INFORMATION=255) as free space for planning. Set false if unknown space should block the robot. |

| use_final_approach_orientation | bool | false | If true, the final path segment orients the robot toward the goal position rather than using the goal's orientation. Useful for tasks where arrival direction doesn't matter (e.g., "go to room center"). |

| cost_travel_multiplier | double | 2.0 | Multiplier applied to costmap cell costs during A* expansion. Higher values make the planner more averse to high-cost areas. |

Downsampling

Reduces the costmap resolution before planning, trading precision for speed.

| Parameter | Type | Default | Description |

|-----------|------|---------|-------------|

| downsample_costmap | bool | false | Enable costmap downsampling. |

| downsampling_factor | int | 1 | Factor by which to reduce resolution. A factor of 2 on a 0.05m costmap plans at 0.10m resolution. |

Downsampling is effective on large outdoor maps where cell-level precision is unnecessary. For indoor robots with tight corridors, keep it disabled or use factor 2 at most.

Smoother Parameters

The built-in smoother runs after path planning to reduce jaggedness.

| Parameter | Type | Default | Description |

|-----------|------|---------|-------------|

| smoother.max_iterations | int | 1000 | Maximum smoothing iterations. |

| smoother.w_smooth | double | 0.3 | Smoothing weight. Higher = smoother path but may deviate from optimal. |

| smoother.w_data | double | 0.2 | Data fidelity weight. Higher = stay closer to the original A* path. |

| smoother.tolerance | double | 1e-10 | Convergence tolerance for the smoother. |

The smoother minimizes a cost function balancing path smoothness against fidelity to the original planned path. If w_smooth >> w_data, paths become very smooth but may cut corners near obstacles.

Complete YAML Configuration

planner_server:
  ros__parameters:
    expected_planner_frequency: 20.0
    planner_plugins: ["GridBased"]
    GridBased:
      plugin: "nav2_smac_planner::SmacPlanner2D"
      tolerance: 0.25
      max_iterations: 1000000
      max_on_approach_iterations: 1000
      max_planning_time: 2.0
      cost_travel_multiplier: 2.0
      allow_unknown: true
      use_final_approach_orientation: false
      downsample_costmap: false
      downsampling_factor: 1
      smoother:
        max_iterations: 1000
        w_smooth: 0.3
        w_data: 0.2
        tolerance: 1.0e-10

When To Use

Good fit:

Poor fit:

Comparison with NavFn

Both operate on the 2D costmap grid. Key differences:

Troubleshooting

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.