Beispiel #1
0
def MC2TXX(rim_radius,
           wheel_radius,
           width,
           rot=[0, 0, 0],
           pos=[0, 0, 0],
           Fixed=False):
    density_tire = density['Steel Forged Concrete']

    [rim, wheel] = MiroAPI.add_TwoBodyTire(False,
                                           rim_radius,
                                           wheel_radius,
                                           width,
                                           pos,
                                           density_tire,
                                           texture='MITstol.jpg')

    COMPONENT_Rim = mc.MiroComponent(rim)
    COMPONENT_Wheel = mc.MiroComponent(wheel)

    COMPONENT_Rim.AddLinkPoint('A', [0, 0, 1], [0, 0, width / 2])
    COMPONENT_Rim.AddLinkPoint('B', [0, 0, -1], [0, 0, -width / 2])

    COMPONENT_Wheel.AddLinkPoint('A', [0, 0, 1], [0, 0, width / 2])
    COMPONENT_Wheel.AddLinkPoint('B', [0, 0, -1], [0, 0, -width / 2])

    COMPONENT_Rim.Rotate(rot)
    COMPONENT_Wheel.Rotate(rot)

    return [COMPONENT_Rim, COMPONENT_Wheel]
Beispiel #2
0
def MC907(rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    size_x = 0.8
    size_y = 0.1
    size_z = 0.9
    density_brick = density['Steel Forged Concrete']  # kg/m^3
    body_brick = MiroAPI.add_boxShape(False,
                                      size_x,
                                      size_y,
                                      size_z,
                                      pos,
                                      texture='white_bricks.jpg',
                                      density=density_brick,
                                      Fixed=Fixed)

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_brick)

    COMPONENT.AddLinkPoint('A', [0, 1, 0],
                           [3 * size_x / 8, size_y / 2, 3 * size_z / 8])
    COMPONENT.AddLinkPoint('B', [0, 1, 0],
                           [-3 * size_x / 8, size_y / 2, 3 * size_z / 8])
    COMPONENT.AddLinkPoint('C', [0, 1, 0],
                           [3 * size_x / 8, size_y / 2, -3 * size_z / 8])
    COMPONENT.AddLinkPoint('D', [0, 1, 0],
                           [-3 * size_x / 8, size_y / 2, -3 * size_z / 8])
    COMPONENT.AddLinkPoint('E', [0, 1, 0], [0, size_y / 2, 0])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #3
0
def MC5XX(M1, M2, M3, rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    '''Ellipsoid component, ABS plastic.\n
    M1 = radius in x\n 
    M2 = radius in y\n
    M3 = radius in z\n
    Linkpoints: A: +x, B: -x, C: +y, D: -y, E: +z, F: -z.'''
    size_rx = M1
    size_ry = M2
    size_rz = M3
    density_brick = density['ABS']  # kg/m^3

    body_ball = MiroAPI.add_ellipsoidShape(False,
                                           size_rx,
                                           size_ry,
                                           size_rz,
                                           pos,
                                           texture='test_texture.png',
                                           scale=[0.07, 0.07],
                                           Collide=False,
                                           density=density_brick)

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_ball)

    COMPONENT.AddLinkPoint('A', [1, 0, 0], [size_rx, 0, 0])
    COMPONENT.AddLinkPoint('B', [-1, 0, 0], [-size_rx, 0, 0])
    COMPONENT.AddLinkPoint('C', [0, 1, 0], [0, size_ry, 0])
    COMPONENT.AddLinkPoint('D', [0, -1, 0], [0, size_ry, 0])
    COMPONENT.AddLinkPoint('E', [0, 0, 1], [0, 0, size_rz])
    COMPONENT.AddLinkPoint('F', [0, 0, -1], [0, 0, -size_rz])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #4
0
def MC906(rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    size_x = 0.8
    size_y = 0.8
    size_z = 0.6
    density_brick = density['Steel Forged Concrete']  # kg/m^3
    body_brick = MiroAPI.add_boxShape(False,
                                      size_x,
                                      size_y,
                                      size_z,
                                      pos,
                                      texture='white_bricks.jpg',
                                      density=density_brick,
                                      Fixed=Fixed)

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_brick)

    COMPONENT.AddLinkPoint('A', [0, 0, 1], [0, 0.9 * size_y / 2, size_z / 2])
    COMPONENT.AddLinkPoint('B', [0, 0, -1], [0, 0.9 * size_y / 2, -size_z / 2])

    # Bottom mounting sockets
    COMPONENT.AddLinkPoint('C', [0, -1, 0], [0, -size_y / 2, size_z / 4])
    COMPONENT.AddLinkPoint('D', [0, -1, 0], [0, -size_y / 2, -size_z / 4])

    # Top mounting sockets
    COMPONENT.AddLinkPoint('E', [0, 1, 0], [0, size_y / 2, size_z / 4])
    COMPONENT.AddLinkPoint('F', [0, 1, 0], [0, size_y / 2, -size_z / 4])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #5
0
def MC3XX(M1, M2, M3, rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    size_x = M1
    size_y = M3
    size_z = M2

    density_brick = density['PVC']  # kg/m^3
    body_brick = MiroAPI.add_boxShape(False,
                                      size_x,
                                      size_y,
                                      size_z,
                                      pos,
                                      texture='pvc_weave_brown.png',
                                      density=density_brick,
                                      Fixed=Fixed)

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_brick)

    COMPONENT.AddLinkPoint('A', [-1, 0, 0], [-size_x / 2, 0, 0])
    COMPONENT.AddLinkPoint('B', [1, 0, 0], [size_x / 2, 0, 0])
    COMPONENT.AddLinkPoint('C', [0, 0, -1], [0, 0, -size_z / 2])
    COMPONENT.AddLinkPoint('D', [0, 0, 1], [0, 0, size_z / 2])
    COMPONENT.AddLinkPoint('E', [0, -1, 0], [0, -size_y / 2, 0])
    COMPONENT.AddLinkPoint('F', [0, 1, 0], [0, size_y / 2, 0])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #6
0
def MC2XX(M1, M2, rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    size_h = M1
    size_r = M2
    density_brick = density['ABS']  # kg/m^3

    body_brick = MiroAPI.add_cylinderShape(False,
                                           size_r,
                                           size_h,
                                           density_brick,
                                           pos,
                                           Fixed=False,
                                           texture='MITstol.jpg')

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_brick)

    COMPONENT.AddLinkPoint('A', [0, 1, 0], [0, size_h / 2, 0])
    COMPONENT.AddLinkPoint('B', [0, -1, 0], [0, -size_h / 2, 0])
    COMPONENT.AddLinkPoint('C', [1, 0, 0], [size_r, 0, 0])
    COMPONENT.AddLinkPoint('D', [-1, 0, 0], [-size_r, 0, 0])
    COMPONENT.AddLinkPoint('E', [0, 0, 1], [0, 0, size_r])
    COMPONENT.AddLinkPoint('F', [0, 0, -1], [0, 0, -size_r])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #7
0
def MC1XX(M1, M2, M3, rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    size_x = M1
    size_y = M2
    size_z = M2

    density_brick = density['Aluminium']  # kg/m^3
    body_brick = MiroAPI.add_boxShape(False,
                                      size_x,
                                      size_y,
                                      size_z,
                                      pos,
                                      texture='brushsteel.jpg',
                                      density=density_brick,
                                      Fixed=Fixed)

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_brick)

    COMPONENT.AddLinkPoint('A', [-1, 0, 0], [-size_x / 2, 0, 0])
    COMPONENT.AddLinkPoint('B', [1, 0, 0], [size_x / 2, 0, 0])
    COMPONENT.AddLinkPoint('C', [0, 0, -1], [0, 0, -size_z / 2])
    COMPONENT.AddLinkPoint('D', [0, 0, 1], [0, 0, size_z / 2])
    COMPONENT.AddLinkPoint('E', [0, -1, 0],
                           [-(size_x / 2 - M3), -size_y / 2, 0])
    COMPONENT.AddLinkPoint('F', [0, -1, 0],
                           [(size_x / 2 - M3), -size_y / 2, 0])
    COMPONENT.AddLinkPoint('G', [0, 1, 0], [-(size_x / 2 - M3), size_y / 2, 0])
    COMPONENT.AddLinkPoint('H', [0, 1, 0], [(size_x / 2 - M3), size_y / 2, 0])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #8
0
def robotcourse(MiroSystem, target):
    course_comp = MC.MiroComponent()
        
    # Import .obj file from object_files directory and set color [R, G, B]
    course_comp.ImportObj('Bana_robottavlingen.obj', color = [0.7, 0.7, 0.7])

    course_comp.MoveToPosition([target[0], target[1], target[2]])

    MiroSystem.Add(course_comp.GetBody())
Beispiel #9
0
def DUMMY(rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False, radius=0.025):
    body_ball = MiroAPI.add_sphereShape(False,
                                        radius,
                                        pos,
                                        texture='test_texture.png',
                                        scale=[0.07, 0.07],
                                        Collide=False)

    # Generate MiroComponent with above body
    COMPONENT = mc.MiroComponent(body_ball)
    COMPONENT.AddLinkPoint('A', [0, 0, 0], [0, 0, 0])
    COMPONENT.Rotate(rot)
    COMPONENT.MoveToPosition(pos)

    return COMPONENT
Beispiel #10
0
def MC0XX(M1, M2, M3, rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    size_x = M1
    size_y = M3
    size_z = M2
    density_brick = density['ABS']  # kg/m^3
    body_brick = MiroAPI.add_boxShape(False,
                                      size_x,
                                      size_y,
                                      size_z,
                                      pos,
                                      texture='MITstol.jpg',
                                      density=density_brick,
                                      Fixed=Fixed)

    # Generate MiroComponent with above ChBody
    COMPONENT = mc.MiroComponent(body_brick)

    # Top
    COMPONENT.AddLinkPoint('A', [0, 1, 0], [(size_x / 2 - 0.02), size_y / 2,
                                            (size_z / 2 - 0.02)])
    COMPONENT.AddLinkPoint(
        'B', [0, 1, 0],
        [-(size_x / 2 - 0.02), size_y / 2, (size_z / 2 - 0.02)])
    COMPONENT.AddLinkPoint(
        'C', [0, 1, 0],
        [(size_x / 2 - 0.02), size_y / 2, -(size_z / 2 - 0.02)])
    COMPONENT.AddLinkPoint(
        'D', [0, 1, 0],
        [-(size_x / 2 - 0.02), size_y / 2, -(size_z / 2 - 0.02)])
    # Bottom
    COMPONENT.AddLinkPoint('E', [0, -1, 0], [0, -size_y / 2, 0])
    # Sides
    COMPONENT.AddLinkPoint('F', [0, 0, -1],
                           [-(size_x / 2 - 0.02), 0, -size_z / 2])
    COMPONENT.AddLinkPoint('G', [0, 0, -1],
                           [(size_x / 2 - 0.02), 0, -size_z / 2])
    COMPONENT.AddLinkPoint('H', [0, 0, 1],
                           [-(size_x / 2 - 0.02), 0, size_z / 2])
    COMPONENT.AddLinkPoint('I', [0, 0, 1],
                           [(size_x / 2 - 0.02), 0, size_z / 2])
    COMPONENT.AddLinkPoint('J', [-1, 0, 0], [-size_x / 2, 0, 0])
    COMPONENT.AddLinkPoint('K', [1, 0, 0], [size_x / 2, 0, 0])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #11
0
def MCTXX(radius_tire, width, rot=[0, 0, 0], pos=[0, 0, 0], Fixed=False):
    density_tire = density['Rubber']

    tire = MiroAPI.add_OneBodyTire(False,
                                   radius_tire,
                                   width,
                                   pos,
                                   density_tire,
                                   texture='MITstol.jpg')

    COMPONENT = mc.MiroComponent(tire)

    COMPONENT.AddLinkPoint('A', [0, 0, 1], [0, 0, width / 2])
    COMPONENT.AddLinkPoint('B', [0, 0, -1], [0, 0, -width / 2])

    COMPONENT.Rotate(rot)

    return COMPONENT
Beispiel #12
0
def MCB01(trigger_function,
          pulses=1,
          rot=[0, 0, 0],
          pos=[0, 0, 0],
          Fixed=False):
    '''A booster that emits a 0.5N, 0.4s pulse when the trigger function returns True.\n
    Can emit up to 5 consecutive pulses based on input argument.\n
    The trigger function must follow the form:\n
    def trigger_function(position, velocity, acceleration)'''
    if pulses > 5:
        pulses = 5
    if pulses < 0:
        pulses = 0
    pulses = np.round(pulses)

    size_h = 0.05
    size_r = 0.0075
    density_brick = 0.02 / (np.pi * size_r**2 * size_h)  # kg/m^3
    booster_body = MiroAPI.add_cylinderShape(False,
                                             size_r,
                                             size_h,
                                             density_brick,
                                             pos,
                                             'booster.png',
                                             scale=[1, -1],
                                             Fixed=False)

    # Generate MiroComponent with above ChBody
    BOOSTER = mc.MiroBooster(booster_body)
    BOOSTER.SetTrigger(trigger_function)
    BOOSTER.SetFuel(400 * pulses)
    BOOSTER.SetForce(0.5)

    BOOSTER.AddLinkPoint('A', [1, 0, 0], [size_r, size_h / 2 - 0.01, 0])
    BOOSTER.AddLinkPoint('B', [1, 0, 0], [size_r, -size_h / 2 + 0.01, 0])
    BOOSTER.AddLinkPoint('C', [0, 0, 1], [0, size_h / 2 - 0.01, size_r])
    BOOSTER.AddLinkPoint('D', [0, 0, 1], [0, -size_h / 2 + 0.01, size_r])

    BOOSTER.Rotate(rot)
    BOOSTER.MoveToPosition(pos)

    return BOOSTER
Beispiel #13
0
def MSL03(rot=[0, 0, 0]):
    size_x = 0.02
    size_y = 0.02
    size_z = 0.02

    sensor_body = MiroAPI.add_boxShape(False,
                                       size_x,
                                       size_y,
                                       size_z, [0, 0, 0],
                                       texture='MSA01.png',
                                       Fixed=False)

    # Generate MiroComponent based MiroSensor with above ChBody
    SENSOR = mc.MiroSensor_Lidar(sensor_body, 50, 90, 2)

    # Top
    SENSOR.AddLinkPoint('Linkpoint', [0, 1, 0], [0, size_y / 2, 0])
    SENSOR.Rotate(rot)

    return SENSOR
Beispiel #14
0
def MSO01(rot=[0, 0, 0]):
    size_x = 0.04
    size_y = 0.012
    size_z = 0.024
    # density_brick = 1000   # kg/m^3
    mass_brick = 0.040
    sensor_body = MiroAPI.add_boxShape(False,
                                       size_x,
                                       size_y,
                                       size_z, [0, 0, 0],
                                       texture='MSO01.png',
                                       Fixed=False,
                                       mass=mass_brick)

    # Generate MiroComponent based MiroSensor with above ChBody
    SENSOR = mc.MiroSensor_Odometer(sensor_body)

    # Top
    SENSOR.AddLinkPoint('Linkpoint', [0, 1, 0], [0, size_y / 2, 0])
    SENSOR.Rotate(rot)

    return SENSOR