예제 #1
0
    def to_sdf(self, tree_depth='', parent_link=None, child_link=None):
        assert (parent_link is not None)
        assert (child_link is not None)
        name_frame = 'component_{}_{}__frame'.format(tree_depth, self.TYPE)
        name_joint = 'component_{}_{}__joint'.format(tree_depth, self.TYPE)
        name_servo = 'component_{}_{}__servo'.format(tree_depth, self.TYPE)
        name_servo2 = 'component_{}_{}__servo2'.format(tree_depth, self.TYPE)

        visual_frame = SDF.Visual(name_frame, self.rgb)
        geometry = SDF.MeshGeometry(self.VISUAL_MESH_FRAME)
        visual_frame.append(geometry)

        collision_frame = SDF.Collision(name_frame, self.MASS_FRAME)
        geometry = SDF.BoxGeometry(self.COLLISION_BOX_FRAME)
        collision_frame.append(geometry)

        visual_servo = SDF.Visual(name_servo, self.rgb)
        geometry = SDF.MeshGeometry(self.VISUAL_MESH_SERVO)
        visual_servo.append(geometry)

        collision_servo = SDF.Collision(name_servo, self.MASS_SERVO)
        collision_servo.translate(SDF.math.Vector3(0.002375, 0, 0))
        geometry = SDF.BoxGeometry(self.COLLISION_BOX_SERVO)
        collision_servo.append(geometry)

        collision_servo_2 = SDF.Collision(name_servo2, 0)
        collision_servo_2.translate(SDF.math.Vector3(0.01175, 0.001, 0))
        geometry = SDF.BoxGeometry(self.COLLISION_BOX_SERVO_2)
        collision_servo_2.append(geometry)

        joint = SDF.Joint(self.id,
                          name_joint,
                          parent_link,
                          child_link,
                          axis=SDF.math.Vector3(0, 1, 0),
                          coordinates=self.substrate_coordinates,
                          motorized=True)

        joint.set_position(SDF.math.Vector3(-0.0085, 0, 0))

        return visual_frame, \
               [collision_frame], \
               visual_servo, \
               [collision_servo, collision_servo_2], \
               joint
예제 #2
0
    def to_sdf(self, tree_depth='', parent_link=None, child_link=None):
        assert (parent_link is not None)
        name = 'component_{}_{}'.format(tree_depth, self.TYPE)
        name_sensor = 'sensor_{}_{}'.format(tree_depth, self.TYPE)

        visual = SDF.Visual(name, self.rgb)
        geometry = SDF.MeshGeometry(self.VISUAL_MESH)
        visual.append(geometry)

        collision = SDF.Collision(name, self.MASS)
        geometry = SDF.BoxGeometry(self.COLLISION_BOX)
        # collision.translate(SDF.math.Vector3(0.01175, 0.001, 0))
        collision.append(geometry)

        sensor = SDF.TouchSensor(name_sensor, collision, parent_link, self)
        parent_link.append(sensor)

        return visual, collision, sensor
예제 #3
0
    def to_sdf(self, tree_depth='', parent_link=None, child_link=None):
        """
        Transform the module in sdf elements.

        IMPORTANT: It does not append VISUAL and COLLISION elements to the parent link
        automatically. It does append automatically the SENSOR element.
        TODO: make the append automatic for VISUAL AND COLLISION AS WELL.

        :param tree_depth: current tree depth as string (for naming)
        :param parent_link: link of the parent (may be needed for certain modules)
        :param child_link: link of the child (may be needed for certain modules, like hinges)
        :return: visual SDF element, collision SDF element, sensor SDF element.
        Sensor SDF element may be None.
        """
        name = 'component_{}_{}__box'.format(tree_depth, self.TYPE)
        visual = SDF.Visual(name, self.rgb)
        geometry = SDF.MeshGeometry(self.VISUAL_MESH)
        visual.append(geometry)

        collision = SDF.Collision(name, self.MASS)
        geometry = SDF.BoxGeometry(self.COLLISION_BOX)
        collision.append(geometry)

        return visual, collision, None