feat(mit): per-model torque coefficients for effort and command#86
feat(mit): per-model torque coefficients for effort and command#86JafarAbdi wants to merge 5 commits into
Conversation
Add joint_torque_coefficients(arm_type) with per-model torque constant k and gear ratio b. get_joint_efforts decodes true joint torque (current*k*b) instead of the SDK base-piper current*k. direct_scaling_factors takes arm_type and scales commanded torque per model relative to base piper (identity for base, b_base/b on >= S-V1.8-3, 1/b on <= S-V1.8-2).
Greptile SummaryThis PR adds per-model torque handling for Piper arms. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (5): Last reviewed commit: "fix(mit): scale commands by per-model k*..." | Re-trigger Greptile |
run_gravity_compensation.py defaulted GravityCompensationModel and PiperInterface to base piper, so a piper_h on >= S-V1.8-3 mis-scaled J5 (1.0 instead of 1/1.7). Add --arm-type and thread it into both.
| k, b = joint_torque_coefficients(self._piper_arm_type) | ||
| arm_msgs = self.piper.GetArmHighSpdInfoMsgs() | ||
| return [ | ||
| arm_msgs.motor_1.effort / 1e3, | ||
| arm_msgs.motor_2.effort / 1e3, | ||
| arm_msgs.motor_3.effort / 1e3, | ||
| arm_msgs.motor_4.effort / 1e3, | ||
| arm_msgs.motor_5.effort / 1e3, | ||
| arm_msgs.motor_6.effort / 1e3, | ||
| currents = [ | ||
| arm_msgs.motor_1.current, | ||
| arm_msgs.motor_2.current, | ||
| arm_msgs.motor_3.current, | ||
| arm_msgs.motor_4.current, | ||
| arm_msgs.motor_5.current, | ||
| arm_msgs.motor_6.current, | ||
| ] | ||
| return [currents[i] * k[i] * b[i] / 1e3 for i in range(6)] |
There was a problem hiding this comment.
Sample data uses base coefficients
get_joint_efforts() now depends on the configured arm type, but scripts/generate_samples.py still creates PiperInterface(args.can_port) with the implicit PIPER value and has no arm-type option. Recording samples from a Piper H/L/X therefore applies base-Piper coefficients—for example, Piper H J2 uses 1.18125 * 4 instead of 1.65375 * 2.5. The saved effort targets are then wrong for gravity-compensation training, so a correctly configured runner can still deploy a model trained on incorrect torques. Propagate arm type through sample generation.
direct_scaling_factors used base(b)/arm(b), which over-scaled joints whose torque constant k also differs from base piper (piper_h J2: 1.6 instead of 1.143). The gravity model is calibrated in the current*k*b feedback frame, so commands must scale by the k*b ratio. J4/J5 are unchanged (equal k); base piper unchanged.
Add joint_torque_coefficients(arm_type) with per-model torque constant k and gear ratio b. get_joint_efforts decodes true joint torque (currentkb) instead of the SDK base-piper current*k. direct_scaling_factors takes arm_type and scales commanded torque per model relative to base piper (identity for base, b_base/b on >= S-V1.8-3, 1/b on <= S-V1.8-2).