Skip to content

feat: one clock for the robot and the offset to NETRA's - #24

Merged
agus-darmawan merged 3 commits into
devfrom
feat/time-sync
Nov 1, 2026
Merged

agus-darmawan merged 3 commits into
devfrom
feat/time-sync

Conversation

@agus-darmawan

Copy link
Copy Markdown
Member

Timestamps differed between Pashupati and NETRA, and inside the robot between the LiDAR and the rest of the stack. This PR puts every stamp on one clock and measures what is left.

On the robot (scripts/timesync.sh, from Dharma's template, DarmawanRobotics/Dharma#8)

  • scripts/setup.sh install timesync: chrony makes the system clock follow TIME_SERVERS (e.g. NETRA's host; empty: Ubuntu's pool) and serves the robot's other computers in TIME_ALLOW.
  • scripts/setup.sh install ptp: ptp4l as PTP master on the LiDAR's interface (the route to LIVOX_IP, or PTP_IFACE), so the Mid-360 stamps its points with the same clock.
  • Both are in the default install. check shows the offset and whether the PTP master runs.
  • Health watches the offset on the robot (clock.enabled in stack.yaml, off in sim.yaml).
  • pashupati.env.example and the tuning guide list the new settings; the PDF is rebuilt.

Robot ↔ NETRA

  • The uplink sends time_sync {t0} after hello and every clock_sync_period_sec (10 s). NETRA answers {t0, t1, t2}, and the robot computes the offset NTP style (the shortest round trip of the last 8 answers wins).
  • The offset goes to telemetry.clock {offset_ms, rtt_ms, age_sec}, with a warning above clock_warn_ms (200 ms).
  • A server that does not answer time_sync yet keeps working (clock stays null). API.md, section "Clocks", is what netra-fleet-be needs to implement.
  • FakeNetra answers time_sync (--clock-offset simulates a server clock that differs).

Tests

  • Unit tests for the offset math.
  • A ROS test with FakeNetra 2.5 s ahead: telemetry.clock.offset_ms ≈ 2500.
  • Locally: pashupati 47 passed (e2e included), pashupati_fleet 25 passed.

Generated by Claude Code

@agus-darmawan
agus-darmawan merged commit c212090 into dev Nov 1, 2026
4 checks passed
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