Skip to content

Expose ServoDefinition.refuses on Python - #156

Merged
pierre-rouanet merged 1 commit into
developfrom
feat/python-status-refusal
Oct 14, 2026
Merged

pierre-rouanet merged 1 commit into
developfrom
feat/python-status-refusal

Conversation

@nicolas-rabault

Copy link
Copy Markdown
Contributor

Follow-up of #152: the last piece LeRobot needs from rustypot for its rustypot-based bus (huggingface/lerobot#4672).

The problem

#152 taught the Rust side to tell a refusal from an alarm, with ServoDefinition::refuses, but Python only got the status_alarms_only property. LeRobot reads the error field through read_register_with_error, write_register_with_error and sync_read_register_with_error, and must not fail an access on an alarm. With only status_alarms_only, it would have to repeat the protocol rules (the v2 error number, the v1 instruction, checksum and range bits) that rustypot already owns.

What changes

  • ServoDefinition.refuses(status) on Python, the Rust method under the same name, taking the error field as the *_with_error calls return it.

Tests

  • ServoDefinition::refuses is covered on the Rust side since Check the error field of setup and torque answers #152; the Python method only converts the integer.
  • Checked from Python with a wheel built from this branch: refuses gives the expected answer on the STS3215, SCS0009, SM8512BL, XL330 and XL430 definitions, and LeRobot's motor, robot and teleoperator tests pass against it with its own copy of the rule removed (311 passed).
  • cargo test (96 + 11), the Python build, and no new clippy warning.

With this, LeRobot needs no other change in rustypot for that work.

A Python caller reads the error field of an answer through the *_with_error reads and
writes, and needs to tell a refusal from an alarm before failing an access, as the Rust
side does since #152. ServoDefinition.refuses(status) gives it the same answer, from
the definition, so the caller does not repeat the protocol and family rules.
@pierre-rouanet
pierre-rouanet merged commit 54f51e3 into develop Oct 14, 2026
15 checks passed
@pierre-rouanet
pierre-rouanet deleted the feat/python-status-refusal branch October 14, 2026 15:07
@pierre-rouanet pierre-rouanet mentioned this pull request Oct 14, 2026
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.

2 participants