Skip to content

fix(ars408): fix latency and thread safety issues in the radar driver - #8

Merged
skyegalaxy merged 5 commits into
mainfrom
skyegalaxy/ars408-latency
Nov 12, 2026
Merged

skyegalaxy merged 5 commits into
mainfrom
skyegalaxy/ars408-latency

Conversation

@skyegalaxy

@skyegalaxy skyegalaxy commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Publish each ARS408 object list when its last frame arrives, instead of one radar cycle later when the next list starts.
The driver held every list until the next Obj_0_Status, so each RadarTracks message reached its consumers about one cycle late.
This PR also fixes two thread-safety bugs in the same path and moves the driver to C++20.

  • Publish a list once its last expected frame is in, which RadarState tells the driver from the quality and extended-info flags. A list that loses a frame is still published when the next one starts.
  • Stamp each list with the kernel receive time of its Obj_0_Status frame, falling back to the node clock under sim time or when the frame has no receive time.
  • Publish RadarTracks first and by unique_ptr, and send the delete-all marker and the track markers in one MarkerArray.
  • Guard vehicle_odometry_ with a mutex, because the executor writes it and the CAN reception thread reads it.
  • Stop the CAN reception thread before the context shuts down and in the destructor, so it never publishes into a dead context. Previously, the driver aborted on SIGINT when run in a component container.
  • Build as C++20.
  • Remove ament_target_dependencies so that the driver builds on lyrical

Benchmark

Synthetic traffic on vcan0: 4 radars on a 72 ms cycle, frames 250 µs apart, every object a 4 × 2 m box with quality and extended info on.
The driver runs composed with four radar_tracks_to_pointcloud converters in one component_container_events_cbg_isolated with intra-process comms.
Latency is the time from the last CAN frame of a list to the PointCloud2 for that list arriving on /<link>/points.
3 runs of 20 s per cell, alternating before and after, 940 lists per run after warm-up, no lists lost in any run.
Cells are the median over runs, with the range in parentheses.

Objects per list (~points per cloud) Driver p50 (ms) p99 (ms) max (ms) Header stamp age at arrival, p50 (ms)
10 (~1540) main 64.66 (64.65–64.67) 64.77 (64.71–64.78) 64.84 (64.83–65.00) 0.15
10 (~1540) this PR 0.14 (0.13–0.15) 0.23 (0.21–0.28) 0.30 (0.26–0.36) 7.64
30 (~4600) main 49.68 (49.68–49.69) 49.75 (49.75–49.83) 49.90 (49.85–49.90) 0.17
30 (~4600) this PR 0.16 (0.16–0.17) 0.26 (0.23–0.30) 0.35 (0.29–0.41) 22.66
  • On main the wait for the next list is the cycle minus the time the list takes on the bus, which is why the 30-object lists wait less.
  • The header stamp age is the age of a cloud by its stamp when it arrives, which is what collision_monitor's base_shift_correction and source_timeout see.
    On main the stamp is the publish time, so the age is about 0 and the hold is invisible.
    With this PR the stamp is when the radar started the list, so the age includes the time the list took to arrive (7.6 ms and 22.7 ms here) and is no longer hidden.
  • Unit tests, including the new "Object list publishing" test for the complete-list and lost-frame cases, pass on vcan.

Limits: vcan on a desktop, synthetic traffic, no radar hardware.
The receiver is rclpy, so a few tens of µs of its wake-up are in every number, before and after alike.

Migration Guide

None.
Consumers see RadarTracks, ObjectList and marker header stamps that are older than before by the time a list takes to arrive. The stamps now mark when the radar started the list rather than when the driver published it.

Skyler added 5 commits November 12, 2026 09:40
Signed-off-by: Skyler <skye@polymathrobotics.com>
…tdown

Signed-off-by: Skyler <skye@polymathrobotics.com>
Signed-off-by: Skyler <skye@polymathrobotics.com>
Signed-off-by: Skyler <skye@polymathrobotics.com>
Signed-off-by: Skyler <skye@polymathrobotics.com>
@skyegalaxy
skyegalaxy merged commit e451f4d into main Nov 12, 2026
3 of 4 checks passed
@skyegalaxy
skyegalaxy deleted the skyegalaxy/ars408-latency branch November 12, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant