Skip to content

Commit

Permalink
Address the issues in the Review from Chen and Gonzalo
Browse files Browse the repository at this point in the history
  • Loading branch information
yck011522 committed Nov 20, 2024
1 parent 0ff399a commit 3328c4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/compas_robots/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ def scale(self, factor):
"""
self.point = self.point * factor

def to_compas_frame(self):
return Frame(self.point, self.xaxis, self.yaxis)


class ColorProxy(ProxyObject):
"""Proxy class that adds URDF functionality to an instance of :class:`Color`.
Expand Down
10 changes: 5 additions & 5 deletions src/compas_robots/model/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,21 +1027,18 @@ def _extract_link_meshes(self, link_elements, meshes_at_link_origin=True):
-------
list of :class:`~compas.datastructures.Mesh`
A list of meshes belonging to the link elements.
If there are no meshes, an empty list is returned.
Notes
-----
Only MeshDescriptor in `element.geometry.shape` is supported. Other shapes are ignored.
"""
if not link_elements:
return None

meshes = []
# Note: Each Link can have multiple visual nodes
for element in link_elements:
# Some elements may have a non-identity origin frame
origin = element.origin.to_compas_frame() if element.origin else Frame.worldXY()
t_origin = Transformation.from_frame(origin)
t_origin = Transformation.from_frame(element.origin or Frame.worldXY())
# If `meshes_at_link_origin` is False, we use an identity transformation
t_origin = t_origin if meshes_at_link_origin else Transformation()

Expand All @@ -1052,6 +1049,7 @@ def _extract_link_meshes(self, link_elements, meshes_at_link_origin=True):
for mesh in shape.meshes:
# Transform the mesh (even if t_origin is identity) so we always get a new mesh object
meshes.append(mesh.transformed(t_origin))
# Add support for other shapes here if needed, e.g. Box, Cylinder, Sphere, Capsule etc.

return meshes

Expand All @@ -1071,6 +1069,7 @@ def get_link_visual_meshes(self, link):
-------
list of :class:`~compas.datastructures.Mesh`
A list of visual meshes belonging to the link
The list is empty if no visual meshes are found.
Notes
-----
Expand Down Expand Up @@ -1131,6 +1130,7 @@ def get_link_collision_meshes(self, link):
-------
list of :class:`~compas.datastructures.Mesh`
A list of collision meshes belonging to the link
The list is empty if no collision meshes are found.
Notes
-----
Expand Down
11 changes: 11 additions & 0 deletions tests/test_model_frame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas_fab.robots import RobotCellLibrary

rc, rcs = RobotCellLibrary.ur10e()
model = rc.robot_model
for link in model.iter_links():
print(link.name)
print(model.get_link_visual_meshes(link))
print(model.get_link_collision_meshes(link))
print(model.get_link_visual_meshes_joined(link))
print(model.get_link_collision_meshes_joined(link))
print("---------------------")

0 comments on commit 3328c4a

Please sign in to comment.