Denoise layer

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

Denoise layer is an AI agent skill from the GitHub repository wimblerobotics/ros2-copilot-skills. Configure Nav2 denoise costmap layer. Use when filtering spurious single-cell obstacles or noise in the costmap.

How to use this skill

Skill file

<!--

SPDX-FileCopyrightText: 2026 Michael Wimble

SPDX-License-Identifier: Apache-2.0

-->


name: denoise-layer

description: 'Configure Nav2 denoise costmap layer. Use when filtering spurious single-cell obstacles or noise in the costmap.'


DenoiseLayer

Purpose

DenoiseLayer removes salt-and-pepper noise from the costmap — isolated single-pixel or small-cluster lethal marks that aren't real obstacles. These appear from sensor noise, multipath reflections, or transient electrical interference, and cause unnecessary path deviations and replanning.

Plugin Configuration

denoise_layer:
  plugin: "nav2_costmap_2d::DenoiseLayer"
  enabled: true
  minimal_group_size: 2

Parameters

minimal_group_size

The minimum number of connected lethal cells that must form a cluster to survive denoising. Groups smaller than this threshold are removed (set to free).

| Value | Effect |

|---|---|

| 1 | No denoising (every cell survives) |

| 2 | Removes isolated single-pixel obstacles (most common setting) |

| 3 | Removes single pixels AND pairs |

| 4+ | Aggressive — may remove real small obstacles |

Recommended: 2 for most robots. This catches single-pixel noise without masking real obstacles.

enabled

true/false to enable/disable without removing from plugins list.

Algorithm

The denoising algorithm performs connected-component analysis on lethal cells:

  1. Scan the costmap for all cells with cost = 254 (lethal)
  2. Group connected lethal cells using 4-connectivity (up, down, left, right neighbors)
  3. For each connected group with fewer than minimal_group_size cells, set those cells to free (0)
  4. Larger groups are left untouched

This is done during the layer's updateCosts() phase, before inflation runs.

Plugin Order

DenoiseLayer MUST be placed:

plugins: ["voxel_layer", "obstacle_layer", "denoise_layer", "inflation_layer"]

If denoise is placed after inflation, it would try to remove lethal cells that are already surrounded by inflation gradient — and the inflation wouldn't be recalculated.

When to Use

Use DenoiseLayer when:

Don't use DenoiseLayer when:

Complete Example

local_costmap:
  local_costmap:
    ros__parameters:
      plugins: ["voxel_layer", "denoise_layer", "inflation_layer"]

      voxel_layer:
        plugin: "nav2_costmap_2d::VoxelLayer"
        enabled: true
        combination_method: 1
        observation_sources: scan
        scan:
          topic: /scan
          data_type: "LaserScan"
          marking: true
          clearing: true
          obstacle_range: 3.5
          raytrace_range: 5.0

      denoise_layer:
        plugin: "nav2_costmap_2d::DenoiseLayer"
        enabled: true
        minimal_group_size: 2

      inflation_layer:
        plugin: "nav2_costmap_2d::InflationLayer"
        cost_scaling_factor: 3.0
        inflation_radius: 0.55

Risks

Debugging

Alternative: Sensor-Level Filtering

Before adding DenoiseLayer, consider filtering noise at the source:

Sensor-level filtering is preferred when possible because it reduces noise before it enters the costmap pipeline. DenoiseLayer is the fallback when sensor-level filtering is insufficient or impractical.

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.