Skip to content

fix(trajectory): solve the quintic in normalized time, Hermite form behind method= - #805

Merged
petercorke merged 6 commits into
mainfrom
fix/quintic-time-scaling
Oct 15, 2026
Merged

petercorke merged 6 commits into
mainfrom
fix/quintic-time-scaling

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

quintic(1, 2, 1000) started near zero instead of 1. The boundary-condition matrix has entries from 1 to T⁵, so its condition number is ~10¹⁵ at T=1000 and ~10¹⁶ at T=0.001, and the least-squares solver silently drops a boundary condition.

This solves the same linear system in normalized time τ = t/T: the matrix is the book's matrix with T = 1 (condition number 762, the same for every trajectory), the velocity boundary values are scaled by T, and the derivatives by 1/T and 1/T². The closed-form Hermite basis from #736 is kept as method="hermite" and used as an independent check.

  • quintic_func(..., method="lstsq" | "hermite"); quintic() uses the default, so the book's call signatures are unchanged.
  • ValueError for a zero or non-finite duration, and for a trajectory of fewer than two samples (previously a degenerate result).
  • quintic_hermite_func is not a public name.
  • Tests: independent polynomial reference over durations 10⁻³ to 10⁶ and negative durations, agreement of the two methods, long-duration regression, quintic/mtraj/jtraj consistency, and the bdsim Traj block.

Found and first fixed by @Afloat16 in #736, whose commits are included here with their authorship.

Co-authored-by: Afloat [email protected]

Related issue

Supersedes #736.

Checklist

  • PR title follows Conventional Commits
  • Tests pass locally; the 9 test_ERobot/test_fknm_fallback failures are identical on main with a stale compiled extension
  • Added tests for this change
  • Docstrings updated, versionchanged notes added
  • mypy clean (164 files), ruff format clean

🤖 Generated with Claude Code

Afloat16 and others added 5 commits October 16, 2026 08:58
Restore the six-equation teaching solver with a numerical-rank guard.
Export the normalized-time Hermite function and use it for sampled quintic trajectories.
Cover caller routing, endpoint derivatives and representable duration scaling.
…ehind method=

The quintic boundary-condition matrix has entries from 1 to T**5, so its
condition number is 1e15 at T=1000 and 1e16 at T=0.001, and lstsq silently
drops a boundary condition: quintic(1, 2, 1000) started near zero.

quintic_func now solves the same linear system in normalized time tau = t/T,
where the matrix is that of the docstring with T = 1 (condition number 762,
the same for every trajectory), scales the velocity boundary values by T and
the derivatives by 1/T and 1/T**2.  The closed-form Hermite basis contributed
in #736 is kept, as method="hermite", and is used as an independent check.

Raise ValueError for a zero or non-finite duration, and for a trajectory of
fewer than two samples, instead of returning a degenerate result.
quintic_hermite_func is not a public name.

Triggered by #736 from Afloat16.

Co-authored-by: Afloat <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 32 complexity · -2 duplication

Metric Results
Complexity 32
Duplication -2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (fe51972) to head (9cd8081).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/roboticstoolbox/tools/trajectory.py 0.00% 30 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #805   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        144     144           
  Lines      14853   14856    +3     
=====================================
- Misses     14853   14856    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@petercorke
petercorke merged commit 97c6c0f into main Oct 15, 2026
26 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
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.

2 participants