Skip to content

Conversation

@p-shg
Copy link
Contributor

@p-shg p-shg commented Sep 18, 2025

All Submissions:

  • Have you followed the guidelines in our Contributing document [docs/contribution.md]?
  • Have you checked to ensure there aren't other open [Pull Requests] for the same update/change?
  • Have you opened/linked the issue related to your pull request?
  • Have you used the tag [WIP] for on-going changes, and removed it when the pull request was ready?
  • When ready to merge, have you sent a comment pinging @pariterre in it?

New Feature Submissions:

  1. Does your submission pass the tests (if not please explain why this is intended)?
  2. Did you write a proper documentation (docstrings and ReadMe)
  3. Have you linted your code locally prior to submission (using the command: black . -l120 --exclude "external/*")?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new examples for your core changes, as applicable?
  • Have you written new tests for your core changes, as applicable?

This fixes a bug in the dynamics of Holonomic Torque Driven
Bug was not covered by tests since example uses RK4 not COLLOCATION
As such, changed the example to collocation
Also commented out a lot of the compute_all_states because it has been unreliable lately and we only need q in this example. This last point should be discussed
@Ipuch


This change is Reviewable

p-shg added 2 commits September 18, 2025 21:05
Modified the corresponding example so it uses collocation and actually covers the code
Also commented out a lot of the compute_all_states function which was unrealiable and not used in the example. We should discuss what to do with this
Copy link
Collaborator

@Ipuch Ipuch left a comment

Choose a reason for hiding this comment

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

Modify the related test that is failing
add the decorator @pytest.parametrize("ode_solver", [OdeSolver.Rk4, OdeSolver.COLLOCATION])
add a if for the collocation values.

@Ipuch reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @p-shg)


bioptim/examples/holonomic_constraints/two_pendulums.py line 84 at r1 (raw file):

        # )

    return q  # , qdot, qddot, lambdas

Decomment

Code quote:

        # qdot[:, i] = bio_model.compute_qdot()(q[:, i], states["qdot_u"][:, i]).toarray().squeeze()
        # qddot_u_i = (
        #     bio_model.partitioned_forward_dynamics()(
        #         states["q_u"][:, i], states["qdot_u"][:, i], q_v_init[:, i], tau[:, i]
        #     )
        #     .toarray()
        #     .squeeze()
        # )
        # qddot[:, i] = bio_model.compute_qddot()(q[:, i], qdot[:, i], qddot_u_i).toarray().squeeze()
        # lambdas[:, i] = (
        #     bio_model.compute_the_lagrangian_multipliers()(
        #         states["q_u"][:, i][:, np.newaxis], states["qdot_u"][:, i], q_v_init[:, i], tau[:, i]
        #     )
        #     .toarray()
        #     .squeeze()
        # )

    return q  # , qdot, qddot, lambdas

bioptim/examples/holonomic_constraints/two_pendulums.py line 91 at r1 (raw file):

    n_shooting: int = 30,
    final_time: float = 1,
    expand_dynamics: bool = False,

add ode_solvers: odeSolver = OdeSolver.RK4,

Code quote:

expand_dynamics: bool = False,

bioptim/examples/holonomic_constraints/two_pendulums.py line 140 at r1 (raw file):

    # Dynamics
    dynamics = DynamicsOptionsList()
    dynamics.add(DynamicsOptions(ode_solver=OdeSolver.COLLOCATION(), expand_dynamics=expand_dynamics))

RK4

@p-shg
Copy link
Contributor Author

p-shg commented Sep 25, 2025

All comments should have been taken into account @Ipuch @pariterre

pariterre
pariterre previously approved these changes Sep 26, 2025
Copy link
Member

@pariterre pariterre left a comment

Choose a reason for hiding this comment

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

:lgtm:

@pariterre reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @p-shg)

@pariterre
Copy link
Member

@p-shg please merge with master and resolve the conflict, then its RTM for me :)

@pariterre pariterre changed the title [RTR] Bug fix in holonomic torque dynamics [RTM when merged with master] Bug fix in holonomic torque dynamics Sep 26, 2025
p-shg added 2 commits September 26, 2025 22:46
Specifically using more objects, or more than one constraint, on different objects or on the same object pair. This should help newer users of holonomic constraints understand this better
@codecov
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.28%. Comparing base (0b6be62) to head (71dcb2e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1021      +/-   ##
==========================================
+ Coverage   77.26%   77.28%   +0.02%     
==========================================
  Files         184      184              
  Lines       20339    20339              
==========================================
+ Hits        15714    15720       +6     
+ Misses       4625     4619       -6     
Flag Coverage Δ
unittests 77.28% <100.00%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@p-shg
Copy link
Contributor Author

p-shg commented Sep 26, 2025

I think we're good
Tests related to the new examples are in another PR. Working on it

pariterre
pariterre previously approved these changes Sep 29, 2025
Copy link
Member

@pariterre pariterre left a comment

Choose a reason for hiding this comment

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

:lgtm:

@pariterre reviewed 13 of 13 files at r3, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @p-shg)

@pariterre
Copy link
Member

@p-shg
Can you add tests to these examples, then we can merge both PR associated with the examples

@pariterre pariterre changed the title [RTM when merged with master] Bug fix in holonomic torque dynamics Bug fix in holonomic torque dynamics Sep 29, 2025
@p-shg
Copy link
Contributor Author

p-shg commented Jan 8, 2026

Tests should be ok on my side
RTM ?

@p-shg p-shg changed the title Bug fix in holonomic torque dynamics [RTM?] Bug fix in holonomic torque dynamics Jan 9, 2026
@Ipuch
Copy link
Collaborator

Ipuch commented Jan 14, 2026

handled in #1024

@Ipuch Ipuch closed this Jan 14, 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.

3 participants