Populate LowState tick in the Python interface - #19
Open
tomasz-lewicki wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PyLowState.tickis always0, no matter what the robot is publishing. Thefield exists on the struct and is exposed to Python, but it is never filled in:
ProcessLowState(both the HG and GO2 overloads) copiesmotor_state,imu_state, andmode_machineout of the incoming DDSLowState_, but neverreads
low_state.tick().ConvertToPyLowStatesetspy_state.mode_machinebut neverpy_state.tick.So
tickstays at its default0while 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:tick_member,ProcessLowStateoverloads,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 callbackthread 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:
tickconstant at0. After:tickis monotonic andincrements on every
read_low_state()(IMU and joint fields unchanged, asexpected).
Note
Does not bump the package version — leaving the release/wheel bump to
maintainers.
~Claude