sensor_fusion

sensor_fusion.py

Overview

sensor_fusion.py is a fusion node that synthesizes data from a planar LiDAR scanner and a single-beam sonar into a unified sensor_msgs/LaserScan. This lightweight placeholder lets sensor-fusion and obstacle-avoidance pipelines be exercised without complex probabilistic filters or real hardware.

Interfaces (strongly-typed, stateless)

Direction

Topic

Message type / Notes

Required (sub)

/{robot}/lidar

sensor_msgs/LaserScan – 180° planar scan

Required (sub)

/{robot}/sonar

sensor_msgs/Range – single-beam ultrasound

Provided (pub)

/{robot}/fused_scan

sensor_msgs/LaserScan – LiDAR + centred sonar reading fused

Contract

Pre-conditions

  • LiDAR and sonar topics publish at compatible rates (~10 Hz).

  • LiDAR ranges length matches the pseudo-scan length generated from sonar.

Post-conditions

  • Each call to publish_fused() emits exactly one fused LaserScan.

  • Fused ranges = element-wise sum of LiDAR ranges and the adapted sonar array.

Invariants

  • Sonar reading is placed at the centre index; all other beam values are unchanged.

Implementation notes

  • Fusion is attempted on every sonar callback and in a fixed-rate loop.

  • Adapter expands a scalar sonar reading into a zero-filled list with the value at the centre.

  • Holds no extra state beyond the last messages, ideal for hot-reload and tests.

Classes

Adapter()

Expand a scalar sonar range into a list matching the LiDAR beam count.

SensorFusionNode()

Merge LiDAR and sonar information into a single LaserScan.