def _initialize(self, **kwargs): """ :param kwargs: :return: """ # Call super to initialize the cylinder part of the wheel super(Wheel, self)._initialize(**kwargs) # Create the small box that serves as the motor box_size = self.MOTOR_SIZE self.attachment = self.create_component( BoxGeom(box_size, box_size, box_size, 0.01), "cylinder-attach") # Get attachment position and axis of the motor joint anchor = Vector3(0, 0, 0.5 * self.LENGTH) axis = Vector3(0, 0, 1) # Size and position the box self.attachment.set_position(anchor + Vector3(0, 0, 0.5 * box_size)) # Create revolute joint. Remember: joint position is in child frame motor_joint = Joint( joint_type="revolute", parent=self.component, child=self.attachment, axis=axis) motor_joint.set_position(Vector3(0, 0, -0.5 * box_size)) # Set a force limit on the joint motor_joint.axis.limit = Limit(effort=0.01) self.add_joint(motor_joint) # Register a joint motor with a maximum velocity of # 50 rounds per minute (the speed is in radians per second) # We also give it a simple PID controller pid = PID(proportional_gain=1.0, integral_gain=0.1) max_speed = 2 * math.pi * 50.0 / 60 self.motors.append(VelocityMotor( part_id=self.id, motor_id="rotate", joint=motor_joint, pid=pid, min_velocity=-max_speed, max_velocity=max_speed)) self.apply_color()
def _initialize(self, **kwargs): """ Initialize method to generate the hinge. Inheriting from "box" makes sure there is a box of the given size in `self.link`. """ super(PassiveHinge, self)._initialize(**kwargs) # Create the variable size block. `create_link` is the recommended # way of doing this, because it sets some non-default link properties # (such as self_collide) which you generally need. length = kwargs["length"] self.var_block = self.create_component( BoxGeom(length, self.y, self.z, 0.1), "var-block") # We move the block in the x-direction so that it # just about overlaps with the other block (to # make it seem like a somewhat realistic joint) self.var_block.translate( Vector3(0.5 * (length + self.x) - self.JOINT_OFFSET, 0, 0)) # Now create a revolute joint at this same position. The # joint axis is in the y-direction. axis = Vector3(0, 1, 0) passive_joint = Joint( joint_type="revolute", parent=self.component, child=self.var_block, axis=axis) # Set some movement limits on the joint passive_joint.axis.limit = Limit( lower=math.radians(-45), upper=math.radians(45), effort=1.0) # Set the joint position - in the child frame! passive_joint.set_position( Vector3(-0.5 * length + self.JOINT_OFFSET, 0, 0)) # Don't forget to add the joint and the link self.add_joint(passive_joint) # Apply the generated color self.apply_color()
def _sensor_helper(self, label, x_sensors, y_sensor): """ :return: """ # Visual is provided by the mesh in the root sensor_component = self.create_component(BoxGeom( SENSOR_THICKNESS, SENSOR_WIDTH, SENSOR_HEIGHT, MASS), label, visual=False) sensor_component.set_position(Vector3(x_sensors, y_sensor, 0)) # Anchor and axis are in child frame self.fix(self.component, sensor_component) # Create and add the SDF sensor contact = SdfSensor(label + "_sensor", "contact", update_rate=self.conf.sensor_update_rate) contact.add_element('<contact><collision>' + sensor_component.collision.name + '</collision></contact>') sensor_component.add_sensor(contact, "touch")
def _initialize(self, **kwargs): """ :param kwargs: :return: """ self.mass = MASS self.x = SENSOR_BASE_THICKNESS self.y = self.z = SENSOR_BASE_WIDTH x_sensors = 0.5 * (SENSOR_BASE_THICKNESS + SENSOR_THICKNESS) y_left_sensor = -0.5 * SENSOR_WIDTH - SEPARATION y_right_sensor = 0.5 * SENSOR_WIDTH + SEPARATION visual = Visual("touch_visual", Mesh("model://rg_robot/meshes/TouchSensor.dae")) visual.translate(Vector3(0.5 * SENSOR_THICKNESS, 0, 0)) self.component = self.create_component(BoxGeom(self.x, self.y, self.z, self.mass), "box", visual=visual) self._sensor_helper("left", x_sensors, y_left_sensor) self._sensor_helper("right", x_sensors, y_right_sensor) self.apply_color()
def _initialize(self, **kwargs): self.component = self.create_component( BoxGeom(self.x, self.y, self.z, self.mass), "box", visual=Mesh("model://rg_robot/meshes/FixedBrick.dae")) self.apply_color()
def _initialize(self, **kwargs): """ :param kwargs: :return: """ self.component = self.create_component(BoxGeom(self.x, self.y, self.z, self.mass), "box")