Skip to content

Commit 6e21ddf

Browse files
committed
Use JAX NumPy to build contact frame
1 parent ae43a2d commit 6e21ddf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/jaxsim/rbda/contacts/detection.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ def _contact_frame(normal: jtp.Vector, position: jtp.Vector) -> jtp.Matrix:
1717

1818
R = jnp.stack([t1, t2, n], axis=1)
1919

20-
return jaxsim.math.Transform.from_rotation_and_translation(
21-
rotation=R,
22-
translation=position,
20+
return jnp.block(
21+
[
22+
[R[0, 0], R[0, 1], R[0, 2], position[0]],
23+
[R[1, 0], R[1, 1], R[1, 2], position[1]],
24+
[R[2, 0], R[2, 1], R[2, 2], position[2]],
25+
[0.0, 0.0, 0.0, 1.0],
26+
]
2327
)
2428

2529

src/jaxsim/rbda/contacts/soft.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import jax
66
import jax.numpy as jnp
77
import jax_dataclasses
8+
import numpy as np
89

910
import jaxsim.api as js
1011
import jaxsim.math
@@ -429,10 +430,10 @@ def compute_contact_forces(
429430
model.kin_dyn_parameters.contact_parameters.shape_type,
430431
model.kin_dyn_parameters.contact_parameters.shape_size,
431432
data._link_transforms[
432-
jnp.array(model.kin_dyn_parameters.contact_parameters.body)
433+
np.array(model.kin_dyn_parameters.contact_parameters.body)
433434
],
434435
data._link_velocities[
435-
jnp.array(model.kin_dyn_parameters.contact_parameters.body)
436+
np.array(model.kin_dyn_parameters.contact_parameters.body)
436437
],
437438
)
438439

0 commit comments

Comments
 (0)