Skip to content

Commit

Permalink
Implemented initial reviews from ami-iit#156
Browse files Browse the repository at this point in the history
- Restructured mesh_collision creation method
- Removed unnecessary hash inheritance
  • Loading branch information
lorycontixd committed Jul 5, 2024
1 parent e60daee commit b0c4d12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/jaxsim/parsers/descriptions/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class MeshCollision(CollisionShape):
def __hash__(self) -> int:
return hash(
(
hash(super()),
hash(tuple(self.center.tolist())),
hash(self.collidable_points),
)
Expand Down
9 changes: 5 additions & 4 deletions src/jaxsim/parsers/rod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import jaxsim.typing as jtp
from jaxsim import logging
from jaxsim.math.inertia import Inertia
from jaxsim.math.adjoint import Adjoint
from jaxsim.math.inertia import Inertia
from jaxsim.parsers import descriptions


Expand Down Expand Up @@ -249,17 +249,18 @@ def create_mesh_collision(

points = mesh.vertices
H = collision.pose.transform() if collision.pose is not None else np.eye(4)
center_of_collision_wrt_link = (H @ np.hstack([0, 0, 0, 1.0]))[0:-1]
# Extract translation from transformation matrix
center_of_collision_wrt_link = H[:3, 3]
mesh_points_wrt_link = (
H @ np.hstack([points, np.vstack([1.0] * points.shape[0])]).T
)[0:3, :]
)[0:3, :].T
collidable_points = [
descriptions.CollidablePoint(
parent_link=link_description,
position=point,
enabled=True,
)
for point in mesh_points_wrt_link.T
for point in mesh_points_wrt_link
]
return descriptions.MeshCollision(
collidable_points=collidable_points, center=center_of_collision_wrt_link
Expand Down

0 comments on commit b0c4d12

Please sign in to comment.