Skip to content

Commit

Permalink
Pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lorycontixd committed Jun 13, 2024
1 parent 3b77b12 commit 1b2bcc8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/jaxsim/parsers/descriptions/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ class MeshCollision(CollisionShape):
def __eq__(self, other: Any) -> bool:
if not isinstance(other, MeshCollision):
return False
return len(self.collidable_points) == len(
other.collidable_points
) and super().__eq__(other) and (self.center == other.center).all()
return (
len(self.collidable_points) == len(other.collidable_points)
and super().__eq__(other)
and (self.center == other.center).all()
)
2 changes: 1 addition & 1 deletion src/jaxsim/parsers/rod/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def extract_model_data(
mesh_collision = utils.create_mesh_collision(
collision=collision,
link_description=links_dict[link.name],
method=utils.MeshMappingMethods.UniformSurfaceSampling
method=utils.MeshMappingMethods.UniformSurfaceSampling,
)
if mesh_collision is not None:
collisions.append(mesh_collision)
Expand Down
13 changes: 3 additions & 10 deletions src/jaxsim/parsers/rod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,13 @@ def create_mesh_collision(
case MeshMappingMethods.RandomSurfaceSampling:
points = mesh.sample(nsamples)
case MeshMappingMethods.UniformSurfaceSampling:
points = trimesh.sample.sample_surface_even(
mesh=mesh,
count=nsamples
)
points = trimesh.sample.sample_surface_even(mesh=mesh, count=nsamples)
case _:
raise ValueError("Invalid mesh mapping method")

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
]
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]
mesh_points_wrt_link = (
H @ np.hstack([points, np.vstack([1.0] * points.shape[0])]).T
)[0:3, :]
Expand Down

0 comments on commit 1b2bcc8

Please sign in to comment.