Skip to content

Commit

Permalink
Merge pull request #910 from p-shg/muscle_driven_with_friction
Browse files Browse the repository at this point in the history
[WIP] Added with_friction support for muscle driven dynamics. Ported funtionalities from torque driven dynamics (#910)

Co-Authored-By: p-shg <[email protected]>
  • Loading branch information
Ipuch and p-shg authored Feb 4, 2025
2 parents a1cc28c + 7cddbff commit 1e11152
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bioptim/dynamics/configure_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ def muscle_driven(
with_contact: bool = False,
with_passive_torque: bool = False,
with_ligament: bool = False,
with_friction: bool = False,
numerical_data_timeseries: dict[str, np.ndarray] = None,
):
"""
Expand Down Expand Up @@ -736,6 +737,8 @@ def muscle_driven(
If the dynamic with passive torque should be used
with_ligament: bool
If the dynamic with ligament should be used
with_friction: bool
If the dynamic with joint friction should be used (friction = coefficients * qdot)
numerical_data_timeseries: dict[str, np.ndarray]
A list of values to pass to the dynamics at each node. Experimental external forces should be included here.
"""
Expand Down Expand Up @@ -764,6 +767,7 @@ def muscle_driven(
with_residual_torque=with_residual_torque,
with_passive_torque=with_passive_torque,
with_ligament=with_ligament,
with_friction=with_friction,
)

if with_contact:
Expand Down
4 changes: 4 additions & 0 deletions bioptim/dynamics/dynamics_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ def muscles_driven(
with_contact: bool,
with_passive_torque: bool = False,
with_ligament: bool = False,
with_friction: bool = False,
with_residual_torque: bool = False,
fatigue=None,
) -> DynamicsEvaluation:
Expand Down Expand Up @@ -727,6 +728,8 @@ def muscles_driven(
If the dynamic with passive torque should be used
with_ligament: bool
If the dynamic with ligament should be used
with_friction: bool
If the dynamic with friction should be used
fatigue: FatigueDynamicsList
To define fatigue elements
with_residual_torque: bool
Expand Down Expand Up @@ -781,6 +784,7 @@ def muscles_driven(
tau = muscles_tau + residual_tau if residual_tau is not None else muscles_tau
tau = tau + nlp.model.passive_joint_torque()(q, qdot, nlp.parameters.cx) if with_passive_torque else tau
tau = tau + nlp.model.ligament_joint_torque()(q, qdot, nlp.parameters.cx) if with_ligament else tau
tau = tau - nlp.model.friction_coefficients @ qdot if with_friction else tau

dq = DynamicsFunctions.compute_qdot(nlp, q, qdot)

Expand Down

0 comments on commit 1e11152

Please sign in to comment.