Repository navigation
Expose ServoDefinition.refuses on Python - #156
Merged
Merged
Conversation
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
approved these changes
Oct 14, 2026
Merged
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.
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 thestatus_alarms_onlyproperty. LeRobot reads the error field throughread_register_with_error,write_register_with_errorandsync_read_register_with_error, and must not fail an access on an alarm. With onlystatus_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_errorcalls return it.Tests
ServoDefinition::refusesis covered on the Rust side since Check the error field of setup and torque answers #152; the Python method only converts the integer.refusesgives 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.