Skip to content

feat(mit): firmware-band MIT torque limits and wire scaling#85

Open
JafarAbdi wants to merge 1 commit into
mainfrom
feature/v188-firmware-parse
Open

feat(mit): firmware-band MIT torque limits and wire scaling#85
JafarAbdi wants to merge 1 commit into
mainfrom
feature/v188-firmware-parse

Conversation

@JafarAbdi

Copy link
Copy Markdown
Contributor

mit_torque_limits returns per-joint (physical limit, wire divisor) for the <=1.8-2, 1.8-3..1.8-7, and >=1.8-8 bands. MitJointPositionController clamps physical torque then divides by the wire divisor before commanding. Gear ratios are injectable and default to the base Piper arm.

Depends on Reimagine-Robotics/piper_sdk#7

mit_torque_limits returns per-joint (physical limit, wire divisor) for the <=1.8-2, 1.8-3..1.8-7, and >=1.8-8 bands. MitJointPositionController clamps physical torque then divides by the wire divisor before commanding. Gear ratios are injectable and default to the base Piper arm.
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds firmware-aware MIT torque conversion. The main changes are:

  • Per-joint physical torque limits and wire divisors.
  • Optional gear-ratio injection for older firmware.
  • Tests for the three firmware version bands.

Confidence Score: 4/5

The v1.8-8 command path and custom ratio configuration can fail during hardware control.

  • Values above 8 Nm can reach an SDK encoder without an enforced 12-bit frame contract.
  • Invalid injected ratios can raise while the controller is issuing commands.

src/piper_control/piper_control.py

Important Files Changed

Filename Overview
src/piper_control/piper_control.py Adds firmware-dependent torque scaling and configurable old-firmware gear ratios; the new paths need codec compatibility and ratio validation.
tests/mit_torque_limit_test.py Covers helper return values for firmware bands but not SDK encoding or invalid ratio inputs.

Fix All in Claude Code Fix All in Codex

Reviews (1): Last reviewed commit: "feat(mit): firmware-band MIT torque limi..." | Re-trigger Greptile

Comment on lines 135 to +136
if parsed is not None and parsed >= _MIT_12BIT_FRAME_VERSION:
raise NotImplementedError(
f"Firmware {firmware_version} uses the 12-bit / no-CRC MIT torque "
"frame (S-V1.8-8+). This driver only encodes the 8-bit + CRC frame, "
"which this firmware misdecodes. Add the 12-bit codec before "
"commanding torques on this firmware."
)
return 8.0
return [16.0] * 6, [1.0] * 6

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unverified 12-bit Frame Path

For firmware >= 1.8-8, this replaces the former safe rejection with wire values up to 16 Nm, but both command paths still pass the value directly to piper_sdk.JointMitCtrl. The installed dependency is not pinned to a codec that emits the required 12-bit, no-CRC frame; an SDK still using the documented 8-bit [-8, 8] encoding can send invalid or rejected frames for values above 8 Nm, causing torque commands to be ignored or applied incorrectly on affected arms.

Fix in Claude Code Fix in Codex

Comment on lines 269 to +272
rest_position: (
Sequence[float] | None
) = ArmOrientations.upright.rest_position,
joint_torque_gear_ratios: Sequence[float] = _PIPER_MIT_GEAR_RATIOS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Invalid Ratio Reaches Control Loop

The new injectable ratio sequence is not checked before its values become per-joint limits and divisors. On pre-1.8-3 or unknown firmware, a sequence shorter than six raises IndexError while commanding a later joint, and a zero entry raises ZeroDivisionError in _to_wire_torque; either failure occurs during active torque control and can stop the command loop.

Fix in Claude Code Fix in Codex

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