# System imports 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",
# 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))
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))
# Revolve imports 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 """
# Revolve imports from __future__ import print_function import itertools import math 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
# 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):
# 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()
# Revolve imports 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 """
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)
# Revolve imports 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 # 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)
# 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")
from __future__ import absolute_import # Revolve imports 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 """
from __future__ import print_function 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: """
# Revolve imports from __future__ import absolute_import 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
# System imports 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),