Esempio n. 1
0
    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        self.mass = MASS
        self.x = SENSOR_BASE_THICKNESS
        self.y = self.z = SENSOR_BASE_WIDTH
        super(LightSensor, self)._initialize(**kwargs)

        # Add the SDF camera sensor
        camera = SdfSensor("%s_light_sensor" % self.id, "camera",
                           update_rate=self.conf.sensor_update_rate)

        # TODO Set field of view
        cam_details = "<camera>" \
                      "<image>" \
                      "<width>1</width><height>1</height>" \
                      "</image>" \
                      "<clip><near>%s</near><far>%s</far></clip>" \
                      "</camera>" % (nf(in_mm(1)), nf(in_mm(50000)))
        camera.add_element(cam_details)
        camera.set_position(Vector3(0.5 * self.x, 0, 0))
        self.component.add_sensor(camera, "light")

        if self.conf.visualize_sensors:
            camera.add_element("<visualize>1</visualize>")

        self.apply_color()
    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        # Variable shorthands
        mass = self.MASS_SLOT
        thickness = self.SLOT_THICKNESS
        width = self.SLOT_WIDTH
        conn_width = self.CONNECTION_PART_WIDTH
        conn_thickness = self.CONNECTION_PART_THICKNESS
        mass_per_cm = self.MASS_CONNECTION_PER_CM
        sep = self.SEPARATION

        # Connection length is in mm
        self.conn_length = conn_length = in_mm(kwargs['connection_length'])

        # Initialize root
        self.root = self.create_component(Box(thickness, width, width, mass), "root")

        # Initialize connection
        x_connection = 0.5 * (thickness + conn_length) + sep
        connection = self.create_component(
            Box(conn_length, conn_width, conn_thickness, 10 * mass_per_cm * conn_length), "connection")
        connection.set_position(Vector3(x_connection, 0, 0))

        # Tail
        x_slot_b = x_connection + 0.5 * (conn_length + thickness) + sep
        self.tail = self.create_component(Box(thickness, width, width, mass), "tail")
        self.tail.set_position(Vector3(x_slot_b, 0, 0))

        # Create fixed joints between the parts
        # root <> connection
        self.fix(self.root, connection)

        # connection <> tail
        self.fix(connection, self.tail)

        # Now perform the rotations. `BodyPart` guarantees
        # that it has origin position and zero orientation
        # at initialisation time, as to avoid confusion with
        # `relative_to_child`.
        self.tilt = tilt = kwargs['alpha']
        self.rotation = rotation = kwargs['beta']

        # First rotate the connection and the tail over beta
        rotation_axis = Vector3(1, 0, 0)
        connection.rotate_around(rotation_axis, rotation,
                                 relative_to_child=False)
        self.tail.rotate_around(rotation_axis, rotation,
                                relative_to_child=False)

        # First tilt the tail over alpha
        self.tail.rotate_around(Vector3(0, 1, 0), tilt,
                                relative_to_child=True)

        # Trigger color mixin
        self.apply_color()
Esempio n. 3
0
def get_poses(n, z=in_mm(24.5), spacing=0.4, row_limit=5):
    x = 0
    y = 0
    poses = []

    for i in range(n):
        poses.append(Pose(position=Vector3(x, y, z)))

        x += spacing
        if (i % row_limit) == 0:
            y += spacing
            x = 0

    return poses
Esempio n. 4
0
def get_poses(n, z=in_mm(24.5), spacing=0.4, row_limit=5):
    x = 0
    y = 0
    poses = []

    for i in range(n):
        poses.append(Pose(position=Vector3(x, y, z)))

        x += spacing
        if (i % row_limit) == 0:
            y += spacing
            x = 0

    return poses
Esempio n. 5
0
    def _initialize(self, **kwargs):
        self.radius = in_mm(kwargs['radius'])

        wheel = self.create_component(Cylinder(self.radius, WHEEL_THICKNESS, MASS_WHEEL), "wheel")
        self.root = self.create_component(Box(SLOT_WIDTH, SLOT_WIDTH, SLOT_THICKNESS, MASS_SLOT))

        # Create the wheel
        z_wheel = 0.5 * SLOT_THICKNESS - (SLOT_THICKNESS + SLOT_CONNECTION_THICKNESS - SLOT_WHEEL_OFFSET)
        wheel.set_position(Vector3(0, 0, z_wheel))

        # Attach the wheel and the root with a revolute joint
        joint = Joint("revolute", self.root, wheel, axis=Vector3(0, 0, -1))

        # TODO Adequate force limit for passive wheel
        joint.axis.limit = Limit(effort=constants.MAX_SERVO_TORQUE_ROTATIONAL)
        self.add_joint(joint)

        # Call color mixin
        self.apply_color()
Esempio n. 6
0
    def _initialize(self, **kwargs):
        self.radius = in_mm(kwargs['radius'])

        wheel = self.create_component(
            Cylinder(self.radius, WHEEL_THICKNESS, MASS_WHEEL), "wheel")
        self.root = self.create_component(
            Box(SLOT_WIDTH, SLOT_WIDTH, SLOT_THICKNESS, MASS_SLOT))

        # Create the wheel
        z_wheel = 0.5 * SLOT_THICKNESS - (
            SLOT_THICKNESS + SLOT_CONNECTION_THICKNESS - SLOT_WHEEL_OFFSET)
        wheel.set_position(Vector3(0, 0, z_wheel))

        # Attach the wheel and the root with a revolute joint
        joint = Joint("revolute", self.root, wheel, axis=Vector3(0, 0, -1))

        # TODO Adequate force limit for passive wheel
        joint.axis.limit = Limit(effort=constants.MAX_SERVO_TORQUE_ROTATIONAL)
        self.add_joint(joint)

        # Call color mixin
        self.apply_color()
Esempio n. 7
0
    def _initialize(self, **kwargs):
        self.radius = in_mm(kwargs['radius'])

        # Create the root
        self.root = self.create_component(
            Box(SLOT_WIDTH, SLOT_WIDTH, SLOT_THICKNESS, MASS_SLOT), "root")

        # Create the servo
        servo = self.create_component(Box(SERVO_HEIGHT, SERVO_WIDTH, SERVO_LENGTH, MASS_SERVO), "servo")
        servo.set_position(Vector3(0, 0, X_SERVO))

        # Create the wheel
        wheel = self.create_component(Cylinder(self.radius, WHEEL_THICKNESS, MASS_WHEEL), "wheel")
        wheel.set_position(Vector3(0, 0, X_WHEEL))

        # Fix the root to the servo
        self.fix(self.root, servo)

        # Attach the wheel and the root with a revolute joint
        self.joint = Joint("revolute", servo, wheel, axis=Vector3(0, 0, -1))
        self.joint.set_position(Vector3(0, 0, -WHEEL_THICKNESS))
        self.joint.axis.limit = Limit(
            effort=constants.MAX_SERVO_TORQUE_ROTATIONAL,
            velocity=constants.MAX_SERVO_VELOCITY
        )
        self.add_joint(self.joint)

        # Now we add a motor that powers the joint. This particular servo
        # targets a velocity. Use a simple PID controller initially.
        pid = constants.SERVO_VELOCITY_PID
        self.motors.append(VelocityMotor(
            self.id, "rotate", self.joint, pid=pid,
            max_velocity=constants.MAX_SERVO_VELOCITY,
            min_velocity=-constants.MAX_SERVO_VELOCITY
        ))

        # Call color mixin
        self.apply_color()
Esempio n. 8
0
from revolve.build.sdf import BodyPart, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(2)
MASS_FRAME = in_grams(3)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
CONNECTION_PART_LENGTH = in_mm(24)
CONNECTION_PART_HEIGHT = in_mm(10)

# Computed from the outermost corner of the connection part
CONNECTION_PART_OFFSET = in_mm(18.5)
SEPARATION = in_mm(0.1)


class Cardan(BodyPart, ColorMixin):
    """
    A passive cardan
    """

    def _initialize(self, **kwargs):
Esempio n. 9
0
# Revolve / sdfbuilder imports
from revolve.build.sdf import Box
from revolve.build.util import in_grams, in_mm
from sdfbuilder.structure import Box as BoxGeom, Mesh
from sdfbuilder.math import Vector3

# Local imports
from .util import ColorMixin

WIDTH = in_mm(41)
HEIGHT = in_mm(35.5)
MASS = in_grams(10.2)


class FixedBrick(Box, ColorMixin):
    """
    Brick - same size as the core component, but
    without any sensors. We can conveniently model this
    as a box.
    """
    X = WIDTH
    Y = WIDTH
    Z = HEIGHT
    MASS = MASS

    def _initialize(self, **kwargs):
        self.component = self.create_component(
            BoxGeom(self.x, self.y, self.z, self.mass), "box",
            visual=Mesh("model://tol_robot/meshes/FixedBrick.dae"))
        self.apply_color()
Esempio n. 10
0
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.joint import Limit
from sdfbuilder.structure import Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SERVO = in_grams(7)
MASS_SLOT = in_grams(2)
MASS_CROSS = in_grams(3)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
CONNECTION_PART_WIDTH = in_mm(12.5)
CONNECTION_PART_LENGTH = in_mm(24.5)
CONNECTION_PART_HEIGHT = in_mm(21)
CROSS_WIDTH = in_mm(10)
CROSS_HEIGHT = in_mm(34)
CROSS_THICKNESS = in_mm(3)

# Outer to inner (was: left to right)
CONNECTION_PART_ROTATION_OFFSET = in_mm(20.5)

# Offset of the cross center from the rotation axis
CROSS_CENTER_OFFSET = in_mm(17)

# Offset of the cross center w.r.t. the center of the connection part
Esempio n. 11
0
    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        # Variable shorthands
        mass = self.MASS_SLOT
        thickness = self.SLOT_THICKNESS
        width = self.SLOT_WIDTH
        conn_width = self.CONNECTION_PART_WIDTH
        conn_thickness = self.CONNECTION_PART_THICKNESS
        mass_per_cm = self.MASS_CONNECTION_PER_CM
        sep = self.SEPARATION

        # Connection length is in mm
        self.conn_length = conn_length = in_mm(kwargs['connection_length'])

        # Initialize root
        self.root = self.create_component(Box(thickness, width, width, mass),
                                          "root")

        # Initialize connection
        x_connection = 0.5 * (thickness + conn_length) + sep
        connection = self.create_component(
            Box(conn_length, conn_width, conn_thickness,
                10 * mass_per_cm * conn_length), "connection")
        connection.set_position(Vector3(x_connection, 0, 0))

        # Tail
        x_slot_b = x_connection + 0.5 * (conn_length + thickness) + sep
        self.tail = self.create_component(Box(thickness, width, width, mass),
                                          "tail")
        self.tail.set_position(Vector3(x_slot_b, 0, 0))

        # Create fixed joints between the parts
        # root <> connection
        self.fix(self.root, connection)

        # connection <> tail
        self.fix(connection, self.tail)

        # Now perform the rotations. `BodyPart` guarantees
        # that it has origin position and zero orientation
        # at initialisation time, as to avoid confusion with
        # `relative_to_child`.
        self.tilt = tilt = kwargs['alpha']
        self.rotation = rotation = kwargs['beta']

        # First rotate the connection and the tail over beta
        rotation_axis = Vector3(1, 0, 0)
        connection.rotate_around(rotation_axis,
                                 rotation,
                                 relative_to_child=False)
        self.tail.rotate_around(rotation_axis,
                                rotation,
                                relative_to_child=False)

        # First tilt the tail over alpha
        self.tail.rotate_around(Vector3(0, 1, 0), tilt, relative_to_child=True)

        # Trigger color mixin
        self.apply_color()
Esempio n. 12
0
class ParametricBarJoint(BodyPart, ColorMixin):
    """
    The parametric bar joint allows the introduction of fix
    angles into your robot and can also be useful
    depending on the needs to space components of your robot.
    Three parameters can be controlled:

    - The length of the joint (H, between 2 and 10 centimeters),
    - its tilt (alpha, between -pi/2 and pi/2) and
    - its rotation (beta, between 0 and pi).

    Compared to the fixed brick or core component, the parametric bar joint
    is somewhat frail and should not be exposed to too much mechanical stress.
    """
    MASS_SLOT = in_grams(1)
    MASS_CONNECTION_PER_CM = in_grams(2)
    SLOT_WIDTH = in_mm(34)
    SLOT_THICKNESS = in_mm(1.5)
    CONNECTION_PART_WIDTH = in_mm(20)
    CONNECTION_PART_THICKNESS = in_mm(2)
    SEPARATION = in_mm(0)

    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        # Variable shorthands
        mass = self.MASS_SLOT
        thickness = self.SLOT_THICKNESS
        width = self.SLOT_WIDTH
        conn_width = self.CONNECTION_PART_WIDTH
        conn_thickness = self.CONNECTION_PART_THICKNESS
        mass_per_cm = self.MASS_CONNECTION_PER_CM
        sep = self.SEPARATION

        # Connection length is in mm
        self.conn_length = conn_length = in_mm(kwargs['connection_length'])

        # Initialize root
        self.root = self.create_component(Box(thickness, width, width, mass),
                                          "root")

        # Initialize connection
        x_connection = 0.5 * (thickness + conn_length) + sep
        connection = self.create_component(
            Box(conn_length, conn_width, conn_thickness,
                10 * mass_per_cm * conn_length), "connection")
        connection.set_position(Vector3(x_connection, 0, 0))

        # Tail
        x_slot_b = x_connection + 0.5 * (conn_length + thickness) + sep
        self.tail = self.create_component(Box(thickness, width, width, mass),
                                          "tail")
        self.tail.set_position(Vector3(x_slot_b, 0, 0))

        # Create fixed joints between the parts
        # root <> connection
        self.fix(self.root, connection)

        # connection <> tail
        self.fix(connection, self.tail)

        # Now perform the rotations. `BodyPart` guarantees
        # that it has origin position and zero orientation
        # at initialisation time, as to avoid confusion with
        # `relative_to_child`.
        self.tilt = tilt = kwargs['alpha']
        self.rotation = rotation = kwargs['beta']

        # First rotate the connection and the tail over beta
        rotation_axis = Vector3(1, 0, 0)
        connection.rotate_around(rotation_axis,
                                 rotation,
                                 relative_to_child=False)
        self.tail.rotate_around(rotation_axis,
                                rotation,
                                relative_to_child=False)

        # First tilt the tail over alpha
        self.tail.rotate_around(Vector3(0, 1, 0), tilt, relative_to_child=True)

        # Trigger color mixin
        self.apply_color()

    def get_slot(self, slot_id):
        self.check_slot(slot_id)
        return self.root if slot_id == 0 else self.tail

    def get_slot_position(self, slot_id):
        self.check_slot(slot_id)
        offset = 0.5 * self.SLOT_THICKNESS

        if slot_id == 0:
            # Root has no relative pose so this is easy
            return Vector3(-offset, 0, 0)
        else:
            # This is a posable group, so we must use
            # sibling conversion.
            return self.tail.to_sibling_frame(Vector3(offset, 0, 0), self)

    def get_slot_tangent(self, slot_id):
        self.check_slot(slot_id)
        vec = Vector3(0, 1, 0)
        return vec if slot_id == 0 else self.tail.to_sibling_direction(
            vec, self)

    def get_slot_normal(self, slot_id):
        self.check_slot(slot_id)

        if slot_id == 0:
            return Vector3(-1, 0, 0)
        else:
            return self.tail.to_sibling_direction(Vector3(1, 0, 0), self)
Esempio n. 13
0
import math
from revolve.build.sdf import BodyPart, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box, Mesh, Visual

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(2)
MASS_FRAME = in_grams(1)
SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
CONNECTION_PART_LENGTH = in_mm(20.5)
CONNECTION_PART_HEIGHT = in_mm(20)
CONNECTION_PART_THICKNESS = in_mm(2)
CONNECTION_ROTATION_OFFSET = in_mm(18.5)
""" Computed from the left corner of the connection part. """

SEPARATION = in_mm(0.1)


class Hinge(BodyPart, ColorMixin):
    """
    A passive hinge
    """
Esempio n. 14
0
# Revolve imports
from revolve.build.sdf import BodyPart, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

from sdfbuilder.joint import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Cylinder, Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(2.5)
MASS_WHEEL = in_grams(4)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(10.75)
SLOT_CONNECTION_THICKNESS = in_mm(1.5)
SLOT_WHEEL_OFFSET = in_mm(7.5)
WHEEL_THICKNESS = in_mm(3)

class Wheel(BodyPart, ColorMixin):
    """
    Passive wheel
    """

    def _initialize(self, **kwargs):
        self.radius = in_mm(kwargs['radius'])

        wheel = self.create_component(Cylinder(self.radius, WHEEL_THICKNESS, MASS_WHEEL), "wheel")
        self.root = self.create_component(Box(SLOT_WIDTH, SLOT_WIDTH, SLOT_THICKNESS, MASS_SLOT))
Esempio n. 15
0
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.joint import Limit
from sdfbuilder.structure import Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SERVO = in_grams(7)
MASS_SLOT = in_grams(2)
MASS_CROSS = in_grams(3)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
CONNECTION_PART_WIDTH = in_mm(12.5)
CONNECTION_PART_LENGTH = in_mm(24.5)
CONNECTION_PART_HEIGHT = in_mm(21)
CROSS_WIDTH = in_mm(10)
CROSS_HEIGHT = in_mm(34)
CROSS_THICKNESS = in_mm(3)

# Outer to inner (was: left to right)
CONNECTION_PART_ROTATION_OFFSET = in_mm(20.5)

# Offset of the cross center from the rotation axis
CROSS_CENTER_OFFSET = in_mm(17)

# Offset of the cross center w.r.t. the center of the connection part
Esempio n. 16
0
from __future__ import print_function

from revolve.build.util import in_grams, in_mm
from sdfbuilder import Link, SDF, Model
from sdfbuilder.structure import Collision, Visual, Box, StructureCombination
from sdfbuilder.math import Vector3
import math

from tol.build.builder import apply_surface_parameters

MASS = in_grams(3)
SENSOR_BASE_WIDTH = in_mm(34)
SENSOR_BASE_THICKNESS = in_mm(1.5)
SENSOR_THICKNESS = in_mm(9)
SENSOR_WIDTH = in_mm(18.5)
SENSOR_HEIGHT = in_mm(16)
SEPARATION = in_mm(1)

m = Model(name="mybot")
sdf = SDF(elements=[m])

geom = Box(SENSOR_BASE_THICKNESS, SENSOR_BASE_WIDTH, SENSOR_BASE_WIDTH, MASS)
base = StructureCombination("base", geom)

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

left = StructureCombination("left", Box(SENSOR_THICKNESS, SENSOR_WIDTH, SENSOR_HEIGHT, MASS))
left.set_position(Vector3(x_sensors, y_left_sensor, 0))
Esempio n. 17
0
# Revolve imports
from revolve.build.sdf import BodyPart, VelocityMotor, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

from sdfbuilder.joint import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Cylinder, Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(4)
MASS_SERVO = in_grams(9)
MASS_WHEEL = in_grams(5)
SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
SERVO_WIDTH = in_mm(14)
WHEEL_THICKNESS = in_mm(3)
SERVO_LENGTH = in_mm(36.8) - WHEEL_THICKNESS
SERVO_HEIGHT = in_mm(14)
SEPARATION = in_mm(1.0)
X_SERVO = -SLOT_THICKNESS + SEPARATION + 0.5 * SERVO_LENGTH
X_WHEEL = X_SERVO + 0.5 * SERVO_LENGTH

class ActiveWheel(BodyPart, ColorMixin):
    """
    Active wheel
    """

    def _initialize(self, **kwargs):
Esempio n. 18
0
from revolve.build.sdf import BodyPart, PositionMotor, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

from sdfbuilder.joint import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(4)
MASS_SERVO = in_grams(9)
MASS_CONNECTION_SLOT = in_grams(2)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
SERVO_Z_OFFSET = in_mm(0)
SERVO_WIDTH = in_mm(14)
SERVO_LENGTH = in_mm(36.8)
SERVO_HEIGHT = in_mm(14)
JOINT_CONNECTION_THICKNESS = in_mm(7.5)
JOINT_CONNECTION_WIDTH = in_mm(34)
SEPARATION = in_mm(0.1)


class ActiveRotator(BodyPart, ColorMixin):
    """
    Active wheel
    """
Esempio n. 19
0
from revolve.build.sdf import BodyPart, PositionMotor, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.joint import Limit
from sdfbuilder.structure import Box, Mesh, Visual

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(7)
MASS_SERVO = in_grams(9)
MASS_FRAME = in_grams(1.2)
SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)

FRAME_LENGTH = in_mm(18)
FRAME_HEIGHT = in_mm(10)
FRAME_ROTATION_OFFSET = in_mm(14)
""" Left to right """

SERVO_LENGTH = in_mm(24.5)
SERVO_HEIGHT = in_mm(10)
SERVO_ROTATION_OFFSET = in_mm(20.5)
""" Right to left """

SEPARATION = in_mm(0.1)

Esempio n. 20
0
from revolve.build.sdf import BodyPart, VelocityMotor, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm
from sdfbuilder.joint import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box, Cylinder

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(4)
MASS_SERVO = in_grams(9)
MASS_WHEG = in_grams(3)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
WHEG_BASE_RADIUS = in_mm(9)
WHEG_THICKNESS = in_mm(4)
WHEG_WIDTH = in_mm(4)

# z-center shift w.r.t. slot z-center
SERVO_Z_OFFSET = in_mm(9)
SERVO_WIDTH = in_mm(14)

# Take of wheg thickness because they overlap in reality
SERVO_LENGTH = in_mm(36.8) - WHEG_THICKNESS
SERVO_HEIGHT = in_mm(14)

SEPARATION = in_mm(1.0)
X_SERVO = 0.5 * SERVO_LENGTH - SLOT_THICKNESS + SEPARATION
Esempio n. 21
0
from revolve.build.sdf import BodyPart, PositionMotor, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.joint import Limit
from sdfbuilder.structure import Box, Mesh, Visual

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(7)
MASS_SERVO = in_grams(9)
MASS_FRAME = in_grams(1.2)
SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)

FRAME_LENGTH = in_mm(18)
FRAME_HEIGHT = in_mm(10)
FRAME_ROTATION_OFFSET = in_mm(14)
""" Left to right """

SERVO_LENGTH = in_mm(24.5)
SERVO_HEIGHT = in_mm(10)
SERVO_ROTATION_OFFSET = in_mm(20.5)
""" Right to left """

SEPARATION = in_mm(0.1)

Esempio n. 22
0
    def _initialize(self, **kwargs):
        self.radius = in_mm(kwargs['radius'])

        # Because of the cylinder shapes, x axis is swapped with z axis
        # as compared to the Robogen code.
        # Initialize root
        self.root = self.create_component(Box(SLOT_WIDTH, SLOT_WIDTH, SLOT_THICKNESS, MASS_SLOT), "root")

        # Initialize servo
        z_servo = 0
        servo = self.create_component(Box(SERVO_HEIGHT, SERVO_WIDTH, SERVO_LENGTH, MASS_SERVO), "servo")
        servo.set_position(Vector3(z_servo, 0, X_SERVO))

        # Initialize the base
        spoke_mass = MASS_WHEG / 4.0
        wheg_base_radius = WHEG_BASE_RADIUS
        wheg_base = self.create_component(Cylinder(wheg_base_radius, WHEG_THICKNESS, spoke_mass), "wheg_base")
        wheg_base.set_position(Vector3(z_servo, 0, X_WHEG_BASE))

        # Initialize the spokes
        spoke1 = self.create_component(Box(self.radius, WHEG_WIDTH, WHEG_THICKNESS, spoke_mass), "spoke1")
        spoke2 = self.create_component(Box(self.radius, WHEG_WIDTH, WHEG_THICKNESS, spoke_mass), "spoke2")
        spoke3 = self.create_component(Box(self.radius, WHEG_WIDTH, WHEG_THICKNESS, spoke_mass), "spoke3")

        # Rotate the spokes
        spokes = [spoke1, spoke2, spoke3]
        """ :type : list[Posable] """
        rotations = [60, 180, 300]
        axis = Vector3(0, 0, 1)
        r = wheg_base_radius + 0.5 * self.radius

        for spoke, rotation in itertools.izip(spokes, rotations):
            spoke.rotate_around(axis, math.radians(rotation))
            rotate_radians = math.radians(rotation)
            x = r * math.cos(rotate_radians)
            y = r * math.sin(rotate_radians)
            spoke.set_position(Vector3(z_servo + x, y, X_WHEG_BASE))

        # Create the connecting joints
        self.fix(self.root, servo)

        for spoke in spokes:
            self.fix(wheg_base, spoke)

        # Revolute joint of the servo
        self.joint = Joint("revolute", servo, wheg_base, axis=Vector3(0, 0, 1))
        self.joint.axis.limit = Limit(
            effort=constants.MAX_SERVO_TORQUE_ROTATIONAL,
            velocity=constants.MAX_SERVO_VELOCITY
        )
        self.add_joint(self.joint)

        # Now we add a motor that powers the joint. This particular servo
        # targets a velocity. Use a simple PID controller initially.
        pid = constants.SERVO_VELOCITY_PID
        self.motors.append(VelocityMotor(
            self.id, "rotate", self.joint, pid=pid,
            max_velocity=constants.MAX_SERVO_VELOCITY,
            min_velocity=-constants.MAX_SERVO_VELOCITY
        ))

        # Call color mixin
        self.apply_color()
Esempio n. 23
0
# Revolve imports
from revolve.build.sdf import Box, Sensor
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.sensor import Sensor as SdfSensor
from sdfbuilder.structure import Box as BoxGeom, Mesh, Visual

# Local imports
from .util import ColorMixin

MASS = in_grams(3)
SENSOR_BASE_WIDTH = in_mm(34)
SENSOR_BASE_THICKNESS = in_mm(1.5)
SENSOR_THICKNESS = in_mm(9)
SENSOR_WIDTH = in_mm(18.5)
SENSOR_HEIGHT = in_mm(16)
""" Of each left / right sensors """

SEPARATION = in_mm(1)


class TouchSensor(Box, ColorMixin):
    """
    Simple light sensor. This extends `Box` for convenience,
    make sure you set the arity to 1 in the body specification.
    """

    def _initialize(self, **kwargs):
        """
Esempio n. 24
0
# Revolve imports
from revolve.build.sdf import BodyPart, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

from sdfbuilder.joint import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Cylinder, Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(2.5)
MASS_WHEEL = in_grams(4)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(10.75)
SLOT_CONNECTION_THICKNESS = in_mm(1.5)
SLOT_WHEEL_OFFSET = in_mm(7.5)
WHEEL_THICKNESS = in_mm(3)


class Wheel(BodyPart, ColorMixin):
    """
    Passive wheel
    """
    def _initialize(self, **kwargs):
        self.radius = in_mm(kwargs['radius'])

        wheel = self.create_component(
            Cylinder(self.radius, WHEEL_THICKNESS, MASS_WHEEL), "wheel")
Esempio n. 25
0
import sys

# Revolve imports
from revolve.build.sdf import Box
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.sensor import Sensor as SdfSensor
from sdfbuilder.util import number_format as nf

# Local imports
from .util import ColorMixin

MASS = in_grams(2)
SENSOR_BASE_WIDTH = in_mm(34)
SENSOR_BASE_THICKNESS = in_mm(1.5)


class LightSensor(Box, ColorMixin):
    """
    Simple light sensor. This extends `Box` for convenience,
    make sure you set the arity to 1 in the body specification.
    """

    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        self.mass = MASS
Esempio n. 26
0
from __future__ import absolute_import

# SDF builder imports
from sdfbuilder.sensor import Sensor as SdfSensor
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box, Mesh

# Revolve imports
from revolve.build.sdf import BodyPart
from revolve.build.util import in_grams, in_mm

# Local imports
from .util import ColorMixin

MASS = in_grams(90.0)
WIDTH = in_mm(90)
HEIGHT = in_mm(45)


class CoreComponent(BodyPart, ColorMixin):
    """
    The core component of the robot, basically a box with an IMU sensor.
    """

    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        self.link = self.create_component(Box(WIDTH, WIDTH, HEIGHT, MASS), "box",
                                          visual=Mesh("model://tol_robot/meshes/CoreComponent.dae"))
Esempio n. 27
0
from revolve.build.sdf import BodyPart, PositionMotor, ComponentJoint as Joint
from revolve.build.util import in_grams, in_mm

from sdfbuilder.joint import Limit
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box

# Local imports
from .util import ColorMixin
from ..config import constants

MASS_SLOT = in_grams(4)
MASS_SERVO = in_grams(9)
MASS_CONNECTION_SLOT = in_grams(2)

SLOT_WIDTH = in_mm(34)
SLOT_THICKNESS = in_mm(1.5)
SERVO_Z_OFFSET = in_mm(0)
SERVO_WIDTH = in_mm(14)
SERVO_LENGTH = in_mm(36.8)
SERVO_HEIGHT = in_mm(14)
JOINT_CONNECTION_THICKNESS = in_mm(7.5)
JOINT_CONNECTION_WIDTH = in_mm(34)
SEPARATION = in_mm(0.1)


class ActiveRotator(BodyPart, ColorMixin):
    """
    Active wheel
    """
    def _initialize(self, **kwargs):
Esempio n. 28
0
from __future__ import absolute_import

# SDF builder imports
from sdfbuilder.sensor import Sensor as SdfSensor
from sdfbuilder.math import Vector3
from sdfbuilder.structure import Box, Mesh

# Revolve imports
from revolve.build.sdf import BodyPart
from revolve.build.util import in_grams, in_mm

# Local imports
from .util import ColorMixin

MASS = in_grams(90.0)
WIDTH = in_mm(90)
HEIGHT = in_mm(45)


class CoreComponent(BodyPart, ColorMixin):
    """
    The core component of the robot, basically a box with an IMU sensor.
    """
    def _initialize(self, **kwargs):
        """
        :param kwargs:
        :return:
        """
        self.link = self.create_component(
            Box(WIDTH, WIDTH, HEIGHT, MASS),
            "box",
Esempio n. 29
0
# Revolve imports
from revolve.build.sdf import Box, Sensor
from revolve.build.util import in_grams, in_mm

# SDF builder imports
from sdfbuilder.math import Vector3
from sdfbuilder.sensor import Sensor as SdfSensor
from sdfbuilder.structure import Box as BoxGeom, Mesh, Visual

# Local imports
from .util import ColorMixin

MASS = in_grams(3)
SENSOR_BASE_WIDTH = in_mm(34)
SENSOR_BASE_THICKNESS = in_mm(1.5)
SENSOR_THICKNESS = in_mm(9)
SENSOR_WIDTH = in_mm(18.5)
SENSOR_HEIGHT = in_mm(16)
""" Of each left / right sensors """

SEPARATION = in_mm(1)


class TouchSensor(Box, ColorMixin):
    """
    Simple light sensor. This extends `Box` for convenience,
    make sure you set the arity to 1 in the body specification.
    """
    def _initialize(self, **kwargs):
        """
        :param kwargs: