Skip to content

Commit d1f81b9

Browse files
committed
Map Coriolis matrix over velocity representation
1 parent b38ff1d commit d1f81b9

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/jaxsim/high_level/model.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -960,22 +960,27 @@ def coriolis_matrix(self) -> jtp.Matrix:
960960
xfb=self.data.model_state.xfb(),
961961
)
962962

963-
if self.velocity_representation is VelRepr.Inertial:
964-
return C
965-
966-
elif self.velocity_representation is VelRepr.Body:
963+
def body(C):
967964
W_H_B = self.base_transform()
968965
B_X_W = sixd.se3.SE3.from_matrix(W_H_B).inverse().adjoint()
969-
return B_X_W.T @ C @ B_X_W
966+
C = B_X_W.T @ C @ B_X_W
970967

971-
elif self.velocity_representation is VelRepr.Mixed:
968+
def mixed(C):
972969
W_H_B = self.base_transform()
973970
W_H_BW = W_H_B.at[0:3, 0:3].set(jnp.eye(3))
974971
BW_X_W = sixd.se3.SE3.from_matrix(W_H_BW).inverse().adjoint()
975-
return BW_X_W.T @ C @ BW_X_W
972+
C = BW_X_W.T @ C @ BW_X_W
976973

977-
else:
978-
raise ValueError(self.velocity_representation)
974+
to_active = {
975+
VelRepr.Body: body,
976+
VelRepr.Mixed: mixed,
977+
VelRepr.Inertial: lambda x: x,
978+
}
979+
980+
try:
981+
C = to_active[self.velocity_representation](C)
982+
except ValueError as e:
983+
raise e
979984

980985
return M, M_dot, C
981986

0 commit comments

Comments
 (0)