Skip to content

Commit b47a157

Browse files
committed
Change the ACM generation of Tool to a property
1 parent 6f6f6ee commit b47a157

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/compas_fab/robots/tool.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,25 @@ class Tool(object):
3737
def __init__(self, visual, frame_in_tool0_frame, collision=None,
3838
name="attached_tool", link_name=None):
3939
self.tool_model = ToolModel(visual, frame_in_tool0_frame, collision, name, link_name)
40-
self.attached_collision_meshes = self.get_attached_collision_meshes()
4140

4241
@classmethod
4342
def from_tool_model(cls, tool_model):
4443
tool = cls(None, None)
4544
tool.tool_model = tool_model
46-
tool.attached_collision_meshes = tool.get_attached_collision_meshes()
4745
return tool
4846

49-
def get_attached_collision_meshes(self):
50-
tool_attached_collision_meshes = []
47+
@property
48+
def attached_collision_meshes(self):
49+
acms = []
5150
for link in self.tool_model.iter_links():
5251
for i, item in enumerate(link.collision):
5352
meshes = Geometry._get_item_meshes(item)
5453
for mesh in meshes:
5554
collision_mesh_name = '{}_collision_{}'.format(link.name, i)
5655
collision_mesh = CollisionMesh(mesh, collision_mesh_name)
5756
attached_collision_mesh = AttachedCollisionMesh(collision_mesh, self.link_name, [self.link_name])
58-
tool_attached_collision_meshes.append(attached_collision_mesh)
59-
return tool_attached_collision_meshes
57+
acms.append(attached_collision_mesh)
58+
return acms
6059

6160
@property
6261
def link_name(self):
@@ -65,7 +64,6 @@ def link_name(self):
6564
@link_name.setter
6665
def link_name(self, link_name):
6766
self.tool_model.link_name = link_name
68-
self.attached_collision_meshes = self.get_attached_collision_meshes() # rebuild ACMs
6967

7068
@property
7169
def frame(self):

0 commit comments

Comments
 (0)