Integrate the squared jerk in closed form rather than sampling it - #1
Open
Eelis03 wants to merge 1 commit into
Open
Integrate the squared jerk in closed form rather than sampling it#1Eelis03 wants to merge 1 commit into
Eelis03 wants to merge 1 commit into
Conversation
The jerk cost was a Simpson quadrature of a sampled trace, whose error falls only as the reciprocal of the sample count when the integrand is discontinuous: the S-curve of the README costs 240.0 analytically and the quadrature reported 240.3600 at 4001 samples. The design notes named the remedy and this is it. On one segment the jerk of one joint is a polynomial, so its square is a polynomial too and the integral over the segment is a quadratic form in the jerk coefficients. PiecewisePolynomialTrajectory.jerk_cost sums that form over every segment and joint, certify_jerk_cost is the analysis-layer entry point, and the scaling and synchronisation wrappers forward it: scaling divides by the fifth power of its factor, synchronisation adds its components. Both raise TypeError when what they wrap cannot answer, as they already do for the peaks. The same S-curve now reports 239.99999999999994 at any sample count, and the time-optimal minimum-jerk move reports its closed form 720 d^2 / T^5 to fourteen digits. Opaque moves to conftest so both tiers of the fallback path share it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The jerk cost was only ever a Simpson quadrature of a sampled trace, and the design notes recorded that as a known limitation with its own remedy: integrate the coefficient table segment by segment. On one segment the jerk of one joint is a polynomial, so its square is a polynomial too and the integral over that segment is a quadratic form in the jerk coefficients, which makes the objective exact for every trajectory this package produces. The S-curve of the README costs 240.0 analytically; the quadrature reported 240.3600 at 4001 samples and the integral reports 239.99999999999994 at any sample count, because it reads none.
PiecewisePolynomialTrajectory.jerk_costsums the quadratic form over every segment and joint, andIntegrableTrajectoryis the protocol that names the capability, alongsideCertifiedTrajectory.certify_jerk_costis the analysis-layer entry point, next tocertify_limits, and refuses with aTypeErrorthat points atcompute_metricswhen the trajectory cannot be integrated.TimeScaledTrajectoryforwards by dividing by the fifth power of its scale andSynchronisedTrajectoryby adding its components, both raisingTypeErrorwhen what they wrap cannot answer.tests/test_jerk_cost.pypins the value against a hand-computed integral, against720 d^2 / T^5and400 * 4 * 0.15, against the quadrature at 4001, 40001 and 400001 samples, and against the claim that the natural quintic spline is the minimum-jerk interpolant of its via points.Opaquemoves toconftest.pyso both suites share it.Local gates: 218 tests pass, coverage 97.15 percent of 1230 statements against the 95 percent gate,
ruff check .andmypyclean.🤖 Generated with Claude Code