Skip to content

Populate LowState tick in the Python interface - #19

Open
tomasz-lewicki wants to merge 1 commit into
devfrom
tomasz/lowstate-tick
Open

Populate LowState tick in the Python interface#19
tomasz-lewicki wants to merge 1 commit into
devfrom
tomasz/lowstate-tick

Conversation

@tomasz-lewicki

@tomasz-lewicki tomasz-lewicki commented Aug 18, 2026

Copy link
Copy Markdown

Problem

PyLowState.tick is always 0, no matter what the robot is publishing. The
field exists on the struct and is exposed to Python, but it is never filled in:

  • ProcessLowState (both the HG and GO2 overloads) copies motor_state,
    imu_state, and mode_machine out of the incoming DDS LowState_, but never
    reads low_state.tick().
  • ConvertToPyLowState sets py_state.mode_machine but never py_state.tick.

So tick stays at its default 0 while every other field updates correctly —
making it unusable for timing / staleness / drop-detection on the reader side.

Fix

Carry the tick through, mirroring the existing mode_machine_ passthrough:

  • add a tick_ member,
  • set it in both ProcessLowState overloads,
  • surface it in ConvertToPyLowState.

Four lines of real change; no API or behavior change beyond the field now being
populated. tick_ is a 32-bit aligned scalar written from the DDS callback
thread and read from the caller thread — the same benign lock-free pattern
already used for mode_machine_.

Testing

Built the extension and read a live G1 low-state stream over a network
interface. Before: tick constant at 0. After: tick is monotonic and
increments on every read_low_state() (IMU and joint fields unchanged, as
expected).

Note

Does not bump the package version — leaving the release/wheel bump to
maintainers.

~Claude

ProcessLowState copied motor/imu/mode_machine out of the DDS LowState_
message but never read tick(), and ConvertToPyLowState never set
py_state.tick — so PyLowState.tick stayed at its default 0 regardless of
the incoming stream, making it useless for timing/staleness checks.

Store the tick from both the HG and GO2 ProcessLowState overloads and
surface it in ConvertToPyLowState, mirroring the existing mode_machine_
passthrough. Verified against a live G1: tick is now monotonic and
increments on every read.
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