88from compas .geometry import Scale
99from compas .geometry import Transformation
1010from compas .robots import Geometry
11- from compas .robots .model .link import Item
11+ from compas .robots .model .link import LinkItem
1212
1313
1414__all__ = [
@@ -79,7 +79,7 @@ def __init__(self, model):
7979 self .attached_items = {}
8080
8181 def attach_tool_model (self , tool_model ):
82- """Attach a tool to the robot artist.
82+ """Attach a tool to the robot artist for visualization .
8383
8484 Parameters
8585 ----------
@@ -117,7 +117,7 @@ def detach_tool_model(self):
117117 self .attached_tool_model = None
118118
119119 def attach_mesh (self , mesh , name , link = None , frame = None ):
120- """Rigidly attaches a compas mesh to a given link.
120+ """Rigidly attaches a compas mesh to a given link for visualization .
121121
122122 Parameters
123123 ----------
@@ -149,7 +149,7 @@ def attach_mesh(self, mesh, name, link=None, frame=None):
149149 init_transformation = transformation * sample_geometry .init_transformation
150150 self .transform (native_mesh , sample_geometry .current_transformation * init_transformation )
151151
152- item = Item ()
152+ item = LinkItem ()
153153 item .native_geometry = [native_mesh ]
154154 item .init_transformation = init_transformation
155155 item .current_transformation = sample_geometry .current_transformation
@@ -219,7 +219,7 @@ def create(self, link=None, context=None):
219219 for child_joint in link .joints :
220220 self .create (child_joint .child_link )
221221
222- def meshes (self , link = None , visual = True , collision = False ):
222+ def meshes (self , link = None , visual = True , collision = False , attached_meshes = True ):
223223 """Returns all compas meshes of the model.
224224
225225 Parameters
@@ -232,6 +232,9 @@ def meshes(self, link=None, visual=True, collision=False):
232232 collision : :obj:`bool`, optional
233233 Whether to include the robot's collision meshes. Defaults
234234 to ``False``.
235+ attached_meshes : :obj:`bool`, optional
236+ Whether to include the robot's attached meshes. Defaults
237+ to ``True``.
235238
236239 Returns
237240 -------
@@ -246,13 +249,15 @@ def meshes(self, link=None, visual=True, collision=False):
246249 items += link .visual
247250 if collision :
248251 items += link .collision
252+ if attached_meshes :
253+ items += list (self .attached_items .get (link .name , {}).values ())
249254 for item in items :
250255 new_meshes = Geometry ._get_item_meshes (item )
251256 for mesh in new_meshes :
252257 mesh .transform (item .current_transformation )
253258 meshes += new_meshes
254259 for child_joint in link .joints :
255- meshes += self .meshes (child_joint .child_link )
260+ meshes += self .meshes (child_joint .child_link , visual , collision , attached_meshes )
256261 return meshes
257262
258263 def scale (self , factor ):
0 commit comments