Skip to content

Commit

Permalink
Integrate quaternions in SO(3) also in RK stages
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Mar 22, 2024
1 parent b177ead commit 1d2049f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/jaxsim/integrators/fixed_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jaxlie

import jaxsim.api as js
from jaxsim.math import Quaternion

from .common import ExplicitRungeKutta, PyTreeType, Time, TimeStep

Expand Down Expand Up @@ -103,11 +104,18 @@ def integrate_rk_stage(
op = lambda x0_leaf, k_leaf: x0_leaf + dt * k_leaf
xf: js.ode_data.ODEState = jax.tree_util.tree_map(op, x0, k)

W_Q_B_t0 = x0.physics_model.base_quaternion
W_ω_WB_t0 = x0.physics_model.base_angular_velocity

return xf.replace(
physics_model=xf.physics_model.replace(
base_quaternion=xf.physics_model.base_quaternion
/ jnp.linalg.norm(xf.physics_model.base_quaternion)
),
base_quaternion=Quaternion.integration(
quaternion=W_Q_B_t0,
dt=dt,
omega=W_ω_WB_t0,
omega_in_body_fixed=False,
),
)
)

@classmethod
Expand Down

0 comments on commit 1d2049f

Please sign in to comment.