Skip to content

fix: replace the factory calibration with the re-measured geometry - #61

Merged
cao-xiao-hao merged 1 commit into
mainfrom
fix/factory-calibration-remeasure
Oct 13, 2026
Merged

cao-xiao-hao merged 1 commit into
mainfrom
fix/factory-calibration-remeasure

Conversation

@cao-xiao-hao

Copy link
Copy Markdown
Contributor

Summary

The shipped default calibration — what a no-argument load_calibration() reads — is replaced with the geometry re-measured on the shipped unit. It carried zero_position_rad 0.052071, max_position_rad -1.357481, rad_to_mm 61.01229326764816; the unit now reads 0.029564, -1.141184, 73.45731105242119.

Both the old and the new file span the same 86 mm (travel_range_rad * rad_to_mm == 86.0), so neither is self-inconsistent and reading one file alone cannot say which is wrong. Only the absolute values separate them, which is why the shipped geometry is pinned by test rather than checked for internal consistency.

This changes behaviour for anything sitting on the old default. rad_to_mm rises by a factor of 1.204, so every mm-based target (goto, move_to, open at work_stroke_mm 80.0) and the clamp_to_calibrated limits move with it: open() lands at a different angle than before. That is what a recalibration is for, but under this repository's version policy it publishes as a patch (fix:), not a major.

The two sibling repositories still carry the old geometry — litegrip-cpp/calibration/factory_calibration.json and litegrip-studio/src/litegrip/factory_calibration.json are both unchanged, and the test docstring has until now named the cpp file as the origin of the factory values. They need the same update or the three repos disagree.

Changes

  • src/litegrip/factory_calibration.json — new geometry. It now carries "calibrated": true; the loader treats a missing key as true (gripper.py:1218), so behaviour is unchanged.
  • src/litegrip/calibration_normal.json, src/litegrip/calibration_reverse.json — move to the same geometry, so all three shipped files keep describing one unit. Direction ordering is unchanged (normal closes at the larger rad value, reverse at the smaller one).
  • src/litegrip/constants.py — the GripperGeometry docstring quotes the factory pair as its worked example; updated to 1.170748 rad -> 86 mm at 73.45731105242119 mm/rad, and 85 mm at 72.604.
  • tests/test_calibration.py — re-pinned the factory geometry constants, plus the two fixture fixes below.

Two test-code edits, neither of which weakens coverage:

  • test_deriving_from_the_jaw_travel_alone_would_be_short bounded the shortfall with a magic 0.8. On the new geometry the shortfall is 1 / 1.170748 = 0.854, so the bound would break on every recalibration. Replaced with the exact identity rad_to_mm - 85/travel == STOP_INSET_MM/travel, which is stricter than the bound it replaces and no longer needs re-tuning.
  • test_old_file_without_the_flag_counts_as_calibrated used the factory file as its example of a pre-calibrated-flag file. The shipped file now carries the flag, so the test writes its own fixture. The fallback it covers — a missing key means calibrated — is untouched.

Testing

$ python3 -m unittest discover -s tests -t tests
Ran 437 tests in 9.847s

OK (skipped=12)

Also loaded all three files out of band to confirm they agree:

load -> True
closed 0.029564 open -1.141184
rad_to_mm 73.45731105242119 mount normal calibrated True
travel_mm 86.0
normal True 0.029564 -1.141184 73.45731105242119 normal
reverse True -1.141184 0.029564 73.45731105242119 reverse

Issues

No issue. gh issue list --state all shows no open issue and none about the factory geometry; the closest historical one is #43 (shipped calibration files agreeing on kp), which is closed and about a different field.

The shipped default calibration is what a no-argument load_calibration()
reads, so it drives the travel clamp and every mm-based target.  It
carried zero_position_rad 0.052071, max_position_rad -1.357481 and
rad_to_mm 61.01229326764816; the shipped unit reads 0.029564,
-1.141184 and 73.45731105242119.

Both files span the same 86 mm (travel_range_rad * rad_to_mm == 86.0),
so neither is self-inconsistent and reading one file alone cannot say
which is wrong.  Only the absolute values separate them, which is why
the shipped geometry is pinned by test rather than checked for
internal consistency.

rad_to_mm rises by a factor of 1.204, so every mm-based target and the
clamp_to_calibrated limits move with it: open() at work_stroke_mm 80.0
lands at a different angle than before.  That is what a recalibration
is for, not a side effect to be worked around, but it does change the
behaviour of anything pinned to the old default.

The two direction templates move to the same geometry, so the three
shipped files keep describing one unit.  The test that used the factory
file as its example of a pre-`calibrated`-flag file now writes its own,
because the shipped file carries the flag and the fallback it covers is
about a missing key, not about that file.
@cao-xiao-hao
cao-xiao-hao merged commit c187b78 into main Oct 13, 2026
1 check passed
@cao-xiao-hao
cao-xiao-hao deleted the fix/factory-calibration-remeasure branch October 13, 2026 08:58
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released Shipped in a release label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant