def from_msg(cls, msg): kwargs = {} kwargs['header'] = Header.from_msg(msg['header']) kwargs['id'] = msg['id'] kwargs['type'] = ObjectType.from_msg(msg['type']) kwargs['pose'] = Pose.from_msg( msg['pose']) if 'pose' in msg else Pose() kwargs['primitives'] = [ SolidPrimitive.from_msg(i) for i in msg['primitives'] ] kwargs['primitive_poses'] = [ Pose.from_msg(i) for i in msg['primitive_poses'] ] kwargs['meshes'] = [Mesh.from_msg(i) for i in msg['meshes']] kwargs['mesh_poses'] = [Pose.from_msg(i) for i in msg['mesh_poses']] kwargs['planes'] = [Plane.from_msg(i) for i in msg['planes']] kwargs['plane_poses'] = [ Pose.from_frame(i) for i in msg['plane_poses'] ] kwargs['operation'] = msg['operation'] return cls(**kwargs)
def from_collision_mesh(cls, collision_mesh): """Creates a collision object from a :class:`compas_fab.robots.CollisionMesh` """ kwargs = {} kwargs['header'] = Header(frame_id=collision_mesh.root_name) kwargs['id'] = collision_mesh.id kwargs['meshes'] = [Mesh.from_mesh(collision_mesh.mesh)] kwargs['mesh_poses'] = [Pose.from_frame(collision_mesh.frame)] return cls(**kwargs)
def from_box(cls, box): """Creates a `BoundingVolume` from a :class:`compas.geometry.Box`. Parameters ---------- box: `compas.geometry.Box` """ primitive = SolidPrimitive.from_box(box) pose = Pose.from_frame(box.frame) return cls(primitives=[primitive], primitive_poses=[pose])