Skip to content

Commit 2865c55

Browse files
committed
adds meshes method to BaseRobotModelArtist
1 parent bce3fbb commit 2865c55

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
* Added `compas.data.is_sequence_of_uint`.
1515
* Added general plotter for geometry objects and data structures based on the artist registration mechanism.
1616
* Added support for multimesh files to OBJ reader/writer.
17+
* Added `meshes` method to artists of `compas.robots.RobotModel`.
1718

1819
### Changed
1920

src/compas/robots/base_artist/_artist.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,42 @@ def create(self, link=None, context=None):
162162
for child_joint in link.joints:
163163
self.create(child_joint.child_link)
164164

165+
def meshes(self, link=None, visual=True, collision=False):
166+
"""Returns all compas meshes of the model.
167+
168+
Parameters
169+
----------
170+
link : :class:`compas.robots.Link`, optional
171+
Base link instance. Defaults to the robot model's root.
172+
visual : :obj:`bool`, optional
173+
Whether to include the robot's visual meshes. Defaults
174+
to ``True``.
175+
collision : :obj:`bool`, optional
176+
Whether to include the robot's collision meshes. Defaults
177+
to ``False``.
178+
179+
Returns
180+
-------
181+
:obj:`list` of :class:`compas.datastructures.Mesh`
182+
"""
183+
if link is None:
184+
link = self.model.root
185+
186+
meshes = []
187+
items = []
188+
if visual:
189+
items += link.visual
190+
if collision:
191+
items += link.collision
192+
for item in items:
193+
new_meshes = Geometry._get_item_meshes(item)
194+
for mesh in new_meshes:
195+
mesh.transform(item.current_transformation)
196+
meshes += new_meshes
197+
for child_joint in link.joints:
198+
meshes += self.meshes(child_joint.child_link)
199+
return meshes
200+
165201
def scale(self, factor):
166202
"""Scales the robot model's geometry by factor (absolute).
167203

0 commit comments

Comments
 (0)