Lidar

lidar.py

Overview

lidar.py is a synthetic 2-D LiDAR publisher that emits planar laser scan messages at 10 Hz. It lets navigation, SLAM, and obstacle-avoidance stacks run without real hardware or recorded bags.

Interfaces (strongly-typed, stateless)

Direction

Topic

Message type / Notes

Provided

/{robot}/lidar

sensor_msgs/LaserScan – 10 Hz, 180 beams spanning –90° to +90°.

Contract

Pre-conditions

  • Node launched with positional robot_id argument.

  • Downstream subscribers expect LaserScan at ~10 Hz.

Post-conditions

  • Publishes exactly one LaserScan per loop iteration.

  • ranges list length = 181, each entry fixed at _FIXED_RANGE (5.0 m).

  • Header frame_id = “laser”, stamp = rospy.Time.now().

Invariants

  • angle_max – angle_min = π radians, angle_increment = π/180.

  • range_min = 0.1 m, range_max = 10.0 m.

Quality-of-Service KPIs

Metric

Target

Rationale

Message rate

10 Hz ± 0.5 Hz

Keeps real-time filters stable.

Latency

< 50 ms

Avoids stale obstacle data.

CPU load

< 1 %

Safe on embedded CPUs.

Implementation notes

  • Uses rospy.Rate(_RATE) for loop timing.

  • All scan parameters defined as module-level constants for easy tweaking.

  • No state beyond the loop – perfect for hot-reload or unit tests.

lidar.publish()[source]

Advertise /lidar and stream constant LaserScan messages until shutdown.