Skip to content

fix: call normalize_state_quaternions() before applying it in TRAPEZOIDAL - #1112

Merged
pariterre merged 10 commits into
pyomeca:masterfrom
Ipuch:fix/normalize-state-quaternions-call
Oct 15, 2026
Merged

pariterre merged 10 commits into
pyomeca:masterfrom
Ipuch:fix/normalize-state-quaternions-call

Conversation

@Ipuch

@Ipuch Ipuch commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Building any OCP with quaternions and OdeSolver.TRAPEZOIDAL crashed while the integrator was being constructed. normalize_state_quaternions is a cache_function-decorated method that returns a casadi Function, but TRAPEZOIDAL.next_x passed the state vector to the method itself instead of to the returned Function. cache_function then tried to use the symbolic (SX/MX) as part of its cache key, which fails (a TypeError on the biorbd model here, a hash error on other symbolic types).

Add the missing "()" so the Function is retrieved first and then called. The RK integrator already did it correctly and is unchanged.

Add a regression test building a TRAPEZOIDAL OCP on the quaternion model; construction alone triggers the bug, so no solve is needed.


This change is Reviewable

@Ipuch Ipuch added bug Something isn't working 15 minutes review A 15 minutes PR, including careful reading of the code by a human and revision guidelines. labels Oct 14, 2026

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:lgtm:

@pariterre reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

@pariterre pariterre added the ready to merge The pull request is ready to merge by the auto merger label Oct 14, 2026
…IDAL

Building any OCP with quaternions and OdeSolver.TRAPEZOIDAL crashed while
the integrator was being constructed. normalize_state_quaternions is a
cache_function-decorated method that returns a casadi Function, but
TRAPEZOIDAL.next_x passed the state vector to the method itself instead of
to the returned Function. cache_function then tried to use the symbolic
(SX/MX) as part of its cache key, which fails (a TypeError on the
biorbd model here, a hash error on other symbolic types).

Add the missing "()" so the Function is retrieved first and then called.
The RK integrator already did it correctly and is unchanged.

Add a regression test building a TRAPEZOIDAL OCP on the quaternion model;
construction alone triggers the bug, so no solve is needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Ipuch
Ipuch force-pushed the fix/normalize-state-quaternions-call branch from b605e7d to cbd7f66 Compare October 15, 2026 15:47
@Ipuch
Ipuch requested a review from pariterre October 15, 2026 15:48
pariterre
pariterre previously approved these changes Oct 15, 2026

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pariterre reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

@pariterre
pariterre self-requested a review October 15, 2026 15:51
Removed 'review_requested' from pull request trigger types.
@pariterre
pariterre enabled auto-merge October 15, 2026 16:07
pariterre
pariterre previously approved these changes Oct 15, 2026

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:lgtm:

@pariterre reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

pariterre
pariterre previously approved these changes Oct 15, 2026

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pariterre reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

@pariterre
pariterre disabled auto-merge October 15, 2026 16:37
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.25%. Comparing base (1fef177) to head (de775a5).
⚠️ Report is 100 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1112      +/-   ##
==========================================
+ Coverage   78.09%   78.25%   +0.15%     
==========================================
  Files         198      198              
  Lines       21694    21747      +53     
==========================================
+ Hits        16942    17018      +76     
+ Misses       4752     4729      -23     
Flag Coverage Δ
unittests 78.25% <100.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@pariterre
pariterre enabled auto-merge October 15, 2026 17:34
pariterre
pariterre previously approved these changes Oct 15, 2026

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pariterre reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

pariterre
pariterre previously approved these changes Oct 15, 2026

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pariterre reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

@pariterre
pariterre disabled auto-merge October 15, 2026 17:50
@pariterre
pariterre enabled auto-merge October 15, 2026 17:50
@pariterre
pariterre disabled auto-merge October 15, 2026 17:52

@pariterre pariterre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pariterre reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Ipuch).

@pariterre
pariterre merged commit 6e68062 into pyomeca:master Oct 15, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

15 minutes review A 15 minutes PR, including careful reading of the code by a human and revision guidelines. bug Something isn't working ready to merge The pull request is ready to merge by the auto merger

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants