예제 #1
0
def podium(MiroSystem, pos, spin=0):
    foot_h = 0.01
    foot_r = 0.9
    leg_h = 0.005
    leg_r = 0.02
    podium_r= 0.9
    podium_h = 0.01

    foot_pos = [pos[0], pos[1]+foot_h/2, pos[2]]
    leg_pos = [pos[0], pos[1]+foot_h+leg_h/2, pos[2]]
    podium_pos = [pos[0], pos[1]+foot_h+leg_h+podium_h/2, pos[2]]

    # Foot
    foot = MiroAPI.add_cylinderShape(MiroSystem, foot_r, foot_h, 1000, foot_pos, texture='black.jpg', Fixed=False)
    # Pole
    leg = MiroAPI.add_cylinderShape(MiroSystem, leg_r, leg_h, 500, leg_pos, texture='gammal5kr.png', Fixed=False)
    # Sign
    podium = MiroAPI.add_cylinderShape(MiroSystem, podium_r, podium_h, 1000, podium_pos, texture='podium-logo.jpg', Fixed=False)
    # Hinges
    h1 = [pos[0], pos[1]+foot_h, pos[2]]
    h2 = [pos[0], pos[1]+foot_h+leg_h, pos[2]]
    MiroAPI.LinkBodies_Hinge(foot, leg, h1, [0,1,0], MiroSystem)
    MiroAPI.LinkBodies_Hinge(leg, podium, h2, [0,1,0], MiroSystem)
    if spin:
        MiroAPI.SetBodyAngularFrequency(podium, spin)
예제 #2
0
def add_stairPosts(system, center, stair_r, h, theta_f, theta_b):

    width = 1.53

    dir_f = np.array([np.cos(theta_f), 0,
                      np.sin(theta_f)])  # Direction front of step
    pos_f = center + dir_f * stair_r + np.array([0, h, 0])

    dir_b = np.array([np.cos(theta_b), 0,
                      np.sin(theta_b)])  # Direction back of step
    pos_b = center + dir_b * stair_r + np.array([0, h, 0])

    # Add rail pole for stair
    post_r = 0.02  # Radius
    post_h = 1.3  # Height
    post_d = 1  # Density
    texture = 'textures/white concrete.jpg'
    dir_f = width * dir_f / np.linalg.norm(dir_f)
    dir_b = width * dir_b / np.linalg.norm(dir_b)
    pos_pole = (pos_f + pos_b) / 2 + (dir_f + dir_b) / 2 + np.array(
        [0, post_h / 2, 0])  # Position

    MiroAPI.add_cylinderShape(system,
                              post_r,
                              post_h,
                              post_d,
                              pos_pole,
                              texture,
                              rotDegrees=False)
예제 #3
0
def sponsorFlag(MiroSystem, pos, logo, spin=0):
    foot_h = 0.08
    foot_r = 0.3
    leg_h = 0.4
    leg_r = 0.02
    sign_h = 1.6
    sign_w = 0.6
    sign_t = 0.03

    foot_pos = [pos[0], pos[1]+foot_h/2, pos[2]]
    leg_pos = [pos[0], pos[1]+foot_h+leg_h/2, pos[2]]
    sign_pos = [pos[0], pos[1]+foot_h+leg_h+sign_h/2, pos[2]]

    # Foot
    foot = MiroAPI.add_cylinderShape(MiroSystem, foot_r, foot_h, 1000, foot_pos, texture='black_smere.jpg', Fixed=False, scale=[1,-1])
    # Pole
    leg = MiroAPI.add_cylinderShape(MiroSystem, leg_r, leg_h, 500, leg_pos, texture='black_smere.jpg', Fixed=False, scale=[1,-1])
    # Sign
    sign = MiroAPI.add_boxShape(MiroSystem, sign_w, sign_h, sign_t, sign_pos, density=30, texture=logo, Fixed=False)
    # Hinges
    h1 = [pos[0], pos[1]+foot_h, pos[2]]
    h2 = [pos[0], pos[1]+foot_h+leg_h, pos[2]]
    MiroAPI.LinkBodies_Hinge(foot, leg, h1, [0,1,0], MiroSystem)
    MiroAPI.LinkBodies_Hinge(leg, sign, h2, [0,1,0], MiroSystem)
    if spin:
        MiroAPI.SetBodyAngularFrequency(sign, spin)
예제 #4
0
def dartboard(MiroSystem, target):
    h = 0.15
    eps = 0.0025
    size = 1
    pos_a = np.array([target[0], target[1]-eps, target[2]])
    pos_b = np.array([target[0], target[1]-(h+2*eps)/2, target[2]])
    
    # Create dartboard layer
    MiroAPI.add_cylinderShape(MiroSystem, size, eps, 1000, pos_a, 'target_dart.png', Collide=False, scale=[-1,1])

    # Create Hitbox
    MiroAPI.add_cylinderShape(MiroSystem, size, h, 1000, pos_b, 'black_smere.jpg', scale=[8,-1])
예제 #5
0
def trialsurface(MiroSystem, target):
    nx = 10
    dz = 1.4
    diag = 0.2
    eps = 0.008
    
    box_side = diag/np.sqrt(2)
    h = diag/2

    for i in range(nx):
        pos = np.array([target[0] - (nx - 1 - 2*i)*diag/2, target[1]-h, target[2]])
        MiroAPI.add_boxShape(MiroSystem, box_side, box_side, dz, pos, rotZ=45, texture='white concrete.jpg')

    th = 1.2*h
    pos = np.array([target[0], target[1]-h-th/2, target[2]])
    MiroAPI.add_boxShape(MiroSystem, nx*diag+2*eps, th, dz+2*eps, pos, texture='wood_ikea_style.png')

    r = 0.03
    h = target[1]-th-h
    d = 0.1
    # [+, +]
    pos = np.array([target[0] + nx*diag/2 - d, h/2, target[2] + dz/2 -d])
    MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2])

    # [-, +]
    pos = np.array([target[0] - nx*diag/2 + d, h/2, target[2] + dz/2 -d])
    MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2])

    # [-, -]
    pos = np.array([target[0] - nx*diag/2 + d, h/2, target[2] - dz/2 +d])
    MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2])

    # [+, -]
    pos = np.array([target[0] + nx*diag/2 - d, h/2, target[2] - dz/2 +d])
    MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2])    
예제 #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
예제 #7
0
def sodacan(MiroSystem, target, text = 'schrodbull.png', angle = 0, SPEEDMODE = False):
    h = 0.22
    r = 0.04
    eps = 0.003
    epsvec = np.array([0, eps/2, 0])
    
    pos_can = np.array([target[0], target[1]+h/2+eps, target[2]])

    # Create Can Hitbox
    can = MiroAPI.add_cylinderShape(MiroSystem, r, h, 50, pos_can, rotY=angle, texture=text, Fixed=False, scale=[1,-1])

    # Create lid and bottom
    pos_lid = np.array([target[0], target[1]+eps*3/2+h, target[2]])
    lid = MiroAPI.add_cylinderShape(MiroSystem, r, eps, 150, pos_lid, rotY=angle, texture='sodacan_lid.png', Fixed=False, scale=[1,1])
    
    pos_bot = np.array([target[0], target[1]+eps/2, target[2]])
    bot = MiroAPI.add_cylinderShape(MiroSystem, r, eps, 200, pos_bot, rotY=angle, texture='sodacan_bot.png', Fixed=False, scale=[1,1])

    MiroSystem.Add(MiroAPI.LinkBodies_Hinge(can, lid, pos_lid-epsvec, [0, 1,0]))
    MiroSystem.Add(MiroAPI.LinkBodies_Hinge(can, bot, pos_bot+epsvec, [0,-1,0]))
예제 #8
0
def add_stairHandle(system, width, dir_f, pos_f, dir_b, pos_b, dh, i, stepNum):
    # Add spiral rail for stair
    handle_r = 0.0175  # Radius
    handle_l = 0.445  # Length
    handle_d = 1  # Density
    texture_handle = 'textures/wood_floor.jpg'
    rail_r = 0.025  # Radius
    rail_l = 0.45  # Length
    rail_d = 1  # Density
    texture_rail = 'textures/white concrete.jpg'

    dir_f = width * dir_f / np.linalg.norm(dir_f)
    dir_b = width * dir_b / np.linalg.norm(dir_b)
    n = (dir_f + dir_b) / 2

    pos_handle = (pos_f + pos_b) / 2 + (dir_f + dir_b) / 2 + np.array(
        [0, 1.3, 0])  # Handle rail
    pos_rail_1 = (pos_f + pos_b) / 2 + (dir_f + dir_b) / 2 + np.array(
        [0, 1, 0])  # Upper support rail
    pos_rail_2 = (pos_f + pos_b) / 2 + (dir_f + dir_b) / 2 + np.array(
        [0, 0.3, 0])  # Lower support rail

    dist = np.sqrt(
        (dir_f[0] - dir_b[0])**2 + (dir_f[1] - dir_b[1])**2 +
        (dir_f[2] - dir_b[2])**2)  # Calculate distance between dir_f and dir_b
    alpha = np.pi / 2
    if dh > 0:
        alpha = np.arctan((dist + 0.07) / dh)

    MiroAPI.add_cylinderShape(system,
                              handle_r,
                              handle_l,
                              handle_d,
                              pos_handle,
                              texture_handle,
                              rotAngle=alpha,
                              rotAxis=n,
                              rotDegrees=False)

    if 0 < i and i < stepNum - 1:
        MiroAPI.add_cylinderShape(system,
                                  rail_r,
                                  rail_l,
                                  rail_d,
                                  pos_rail_1,
                                  texture_rail,
                                  rotAngle=alpha,
                                  rotAxis=n,
                                  rotDegrees=False)
        MiroAPI.add_cylinderShape(system,
                                  rail_r,
                                  rail_l,
                                  rail_d,
                                  pos_rail_2,
                                  texture_rail,
                                  rotAngle=alpha,
                                  rotAxis=n,
                                  rotDegrees=False)
예제 #9
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
예제 #10
0
def floorvent(MiroSystem, target, SPEEDMODE = False):
    h = 0.85
    r = 0.30

    h1 = 0.20
    h3 = 0.04
    h2 = h - h1 - h3
    
    pos_base = np.array([target[0], target[1]+h1/2, target[2]])
    pos_vent = np.array([target[0], target[1]+h2/2+h1, target[2]])
    pos_topp = np.array([target[0], target[1]+h3/2+h1+h2, target[2]])

    MiroAPI.add_cylinderShape(MiroSystem, r-0.02, h1, 1500, pos_base, texture='vents_surface.jpg')
    MiroAPI.add_cylinderShape(MiroSystem, r, h2, 1500, pos_vent, texture='vents.jpg')
    MiroAPI.add_cylinderShape(MiroSystem, r, h3, 1500, pos_topp, texture='vents_surface.jpg')
예제 #11
0
def add_fence(system, H, postNum, floor_w, floor_w_2, floor, floor_t,
              handle_l):

    # Add fence post, as a cylinder
    fence_r = 0.02  # Radius
    fence_h = 1.04  # Hight
    fence_d = 1  # Density
    texture = 'textures/white concrete.jpg'
    fence_corr = np.array([0, fence_h / 2,
                           0])  # Correction for fence post postition

    # Add handle for each floor
    handle_r = 0.0175  # Radius
    # handle_d = 1            # Density
    n_x = np.array([1, 0, 0])  # Normalvector in x direction
    n_z = np.array([0, 0, 1])  # Normalvector in z direction
    # Handle
    pos_rail_1 = np.array([-0.75, H + fence_h * 0.925,
                           6.58 - floor_w])  # Fence 3rd floor left of stair
    pos_rail_2 = np.array(
        [10.45 + 2.11 - floor_w_2, H + fence_h * 0.925,
         -4.4])  # Fence 3rd floor
    pos_rail_3 = np.array(
        [10.45 + 2.11 - floor_w_2, 2 * H + fence_h * 0.925,
         -4.4])  # Fence 4th floor
    pos_rail_4 = np.array([6.5, 2 * H + fence_h * 0.925,
                           4.2])  # Fence by the stair 4th floor
    # Rail
    pos_rail_5 = np.array([-0.75, H + 3 / 4 * fence_h,
                           6.58 - floor_w])  # Fence 3rd floor left of stair
    pos_rail_6 = np.array(
        [10.45 + 2.11 - floor_w_2, H + 3 / 4 * fence_h,
         -4.4])  # Fence 3rd floor
    pos_rail_7 = np.array(
        [10.45 + 2.11 - floor_w_2, 2 * H + 3 / 4 * fence_h,
         -4.4])  # Fence 4th floor
    pos_rail_8 = np.array([6.5, 2 * H + 3 / 4 * fence_h,
                           4.2])  # Fence by the stair 4th floor

    pos_h = [pos_rail_1, pos_rail_2, pos_rail_3, pos_rail_4]
    pos_r = [pos_rail_5, pos_rail_6, pos_rail_7, pos_rail_8]
    dirr = [n_z, n_x, n_x, n_x]
    handle_length = [handle_l, handle_l, handle_l, 2]
    dl = (handle_l) / postNum  # Delta lenght between each post

    # Handle rail
    for num in range(len(pos_h)):
        pos_rail = pos_h[num]
        n = dirr[num]
        length = handle_length[num]

        MiroAPI.add_cylinderShape(system,
                                  handle_r,
                                  length,
                                  1,
                                  pos_rail,
                                  'textures/wood_floor.jpg',
                                  rotAngle=np.pi / 2,
                                  rotAxis=n,
                                  rotDegrees=False)

    # Support rail
    for num in range(len(pos_r)):
        pos_rail = pos_r[num]
        n = dirr[num]
        length = handle_length[num]

        MiroAPI.add_cylinderShape(system,
                                  fence_r,
                                  length,
                                  1,
                                  pos_rail,
                                  'textures/white concrete.jpg',
                                  rotAngle=np.pi / 2,
                                  rotAxis=n,
                                  rotDegrees=False)

    for post in range(postNum):
        y_pos = floor * H - floor_t
        pos_l = np.array([(-0.7 - handle_l / 2) + post * dl, H - floor_t,
                          6.58 - floor_w]) + fence_corr  # Left side stair
        pos_r = np.array([
            10.45 + 2.11 - floor_w_2, y_pos, (-4.4 - handle_l / 2) + post * dl
        ]) + fence_corr  # Right side stair

        MiroAPI.add_cylinderShape(system, fence_r, fence_h, fence_d, pos_r,
                                  texture)
        MiroAPI.add_cylinderShape(system, fence_r, fence_h, fence_d, pos_l,
                                  texture)

    for post in range(3):
        pos = np.array([6.5, 2 * H - floor_t, 3.5 + post * dl]) + fence_corr

        MiroAPI.add_cylinderShape(system, fence_r, fence_h, fence_d, pos,
                                  texture)
예제 #12
0
def MIT_stair(system, center, H, SPEEDMODE):
    stair_r = 0.3  # Radius
    stair_h = 2 * H + 1  # Hight
    stair_d = 1  # Density
    stepNum = 21  # Number of steps
    dh = (H - 0.1) / stepNum  # Heigth between each step
    rad = 1 / 360 * 2 * np.pi  # Degrees to radians
    texture = 'textures/white concrete.jpg'
    pos_stair = center + np.array([
        0, stair_h / 2, 0
    ])  #chrono.ChVectorD(0, stair_h/2, 0)  # Correction for stair position
    pos_disk = center + np.array([0, stair_h + 0.025, 0
                                  ])  #chrono.ChVectorD(0, stair_h+0.025, 0)

    # Add center cylinder of stair
    MiroAPI.add_cylinderShape(system, stair_r, stair_h, stair_d, pos_stair,
                              texture, [10, 10])

    # If SPEEDMODE is activated, stop here
    if SPEEDMODE:
        return

    # Top disk
    MiroAPI.add_cylinderShape(system, stair_r + 0.01, 0.05, 1, pos_disk,
                              'textures/MIT_stone_floor.jpg', [1 / 8, 1 / 8])
    # Add fake stair to base floor
    MiroAPI.add_cylinderShape(system, stair_r + 1.7, 0.001, stair_d, center,
                              'textures/black.jpg', [1, 1])

    # Add steps to 3rd floor
    for step in range(stepNum):
        h = step * dh
        theta_f = rad * (90 + 270 * step / stepNum
                         )  # Angle between each front step
        theta_b = rad * (90 + 270 *
                         (step + 1) / stepNum)  # Angle between each back step

        add_stairStep(system, center, stair_r, h, theta_f, theta_b, dh, step,
                      stepNum, True)
        add_stairStep(system, center, stair_r, 0, theta_f, theta_b, 0, step,
                      stepNum, False)

        # Add fence post for stair
        if step % 2 == 0:
            add_stairPosts(system, center, stair_r, h, theta_f, theta_b)
            add_stairPosts(system, center, stair_r, 0, theta_f, theta_b)

    # Add steps to 4th floor
    for step in range(stepNum):
        h = step * dh
        theta_f = rad * (90 + 270 * step / stepNum
                         )  # Angle between each front step
        theta_b = rad * (90 + 270 *
                         (step + 1) / stepNum)  # Angle between each back step
        pos = center + np.array([0, H, 0])

        add_stairStep(system, pos, stair_r, h, theta_f, theta_b, dh, step,
                      stepNum, True)

        # Add fence post for stair
        if step % 2 == 0:
            add_stairPosts(system, pos, stair_r, h, theta_f, theta_b)
예제 #13
0
def coin(MiroSystem, target, angle = 0):
    h = 0.0012
    r = 0.012
    
    pos_coin = np.array([target[0], target[1]+h/2, target[2]])
    MiroAPI.add_cylinderShape(MiroSystem, r, h, 150, pos_coin, rotY=angle, texture='gammal5kr.png', Fixed=False, scale=[1,-1])
예제 #14
0
def normal_door(MiroSystem, d, l, spin, pos):
    top = pos[1]
    mid = pos[1] / 2 + d / 4
    bot = d / 2
    # vertical frame poles
    pos[1] = mid
    greenpole(MiroSystem, d, top - bot + d, spin, 0, pos)
    p = [
        pos[0] + np.cos(np.deg2rad(spin)) * (l - d / 2), mid,
        pos[2] - np.sin(np.deg2rad(spin)) * (l - d / 2)
    ]
    greenpole(MiroSystem, d, top - bot + d, spin, 0, p)

    # top and bottom frame
    p = [
        pos[0] + (1 / 2) * np.cos(np.deg2rad(spin)) * (l - d / 2), top,
        pos[2] - (1 / 2) * np.sin(np.deg2rad(spin)) * (l - d / 2)
    ]
    greenpole(MiroSystem, d, l - d, spin, 90, p)
    p[1] = bot
    greenpole(MiroSystem, d, l - d, spin, 90, p)

    # handle
    r = 0.02
    h = 0.40
    dist = 0.30

    # poles through door
    pb = [
        pos[0] + np.cos(np.deg2rad(spin)) * (l - d / 2) * 0.86,
        mid + h * (1 / 3),
        pos[2] - np.sin(np.deg2rad(spin)) * (l - d / 2) * 0.86
    ]
    MiroAPI.add_cylinderShape(MiroSystem,
                              r / 2,
                              dist,
                              2500,
                              pb,
                              'textures/chrome.png',
                              rotY=spin - 90,
                              rotZ=90,
                              rotOrder=['x', 'z', 'y'],
                              Collide=False,
                              scale=[2, 2],
                              color=[0.9, 0.9, 0.9])
    pb[1] = mid - h * (1 / 3)  # rotY=-spin, rotX=90
    MiroAPI.add_cylinderShape(MiroSystem,
                              r / 2,
                              dist,
                              2500,
                              pb,
                              'chrome.png',
                              rotY=spin - 90,
                              rotZ=90,
                              rotOrder=['z', 'y'],
                              Collide=False,
                              scale=[2, 2],
                              color=[0.9, 0.9, 0.9])

    # disks on door
    MiroAPI.add_cylinderShape(MiroSystem,
                              r * 1.2,
                              0.01,
                              2500,
                              pb,
                              'brushsteel.png',
                              rotY=spin - 90,
                              rotZ=90,
                              rotOrder=['z', 'y'],
                              Collide=False,
                              scale=[2, 2],
                              color=[0.85, 0.85, 0.85])
    pb[1] = mid + h * (1 / 3)
    MiroAPI.add_cylinderShape(MiroSystem,
                              r * 1.2,
                              0.01,
                              2500,
                              pb,
                              'brushsteel.png',
                              rotY=spin - 90,
                              rotZ=90,
                              rotOrder=['z', 'y'],
                              Collide=False,
                              scale=[2, 2],
                              color=[0.85, 0.85, 0.85])

    # handle bars
    ph1 = [
        pb[0] + np.cos(np.deg2rad(spin + 90)) * (dist / 2), mid,
        pb[2] - np.sin(np.deg2rad(spin + 90)) * (dist / 2)
    ]
    ph2 = [
        pb[0] - np.cos(np.deg2rad(spin + 90)) * (dist / 2), mid,
        pb[2] + np.sin(np.deg2rad(spin + 90)) * (dist / 2)
    ]

    MiroAPI.add_cylinderShape(MiroSystem,
                              r,
                              h,
                              2500,
                              ph1,
                              'chrome.png',
                              scale=[2, 2],
                              color=[0.9, 0.9, 0.9])
    MiroAPI.add_cylinderShape(MiroSystem,
                              r,
                              h,
                              2500,
                              ph2,
                              'chrome.png',
                              scale=[2, 2],
                              color=[0.9, 0.9, 0.9])
예제 #15
0
def FullEntrance(MiroSystem, pos_south, pos_north):
    d = 0.08
    l = 3.02

    # Pole in front of doors
    p = np.array([pos_south[0] + 2.89, 1.51, pos_south[2] - 0.6])
    MiroAPI.add_boxShape(MiroSystem,
                         2 * d,
                         l,
                         2 * d,
                         p,
                         texture='white concrete.jpg',
                         scale=[4, 12])

    # Emergency exit sign
    p = np.array([pos_south[0] + 2.89, 2.7, pos_south[2] - 0.6 - d - 0.01])
    MiroAPI.add_boxShape(MiroSystem,
                         0.568 * 0.7,
                         0.285 * 0.7,
                         0.02,
                         p,
                         texture='exit.png')

    # Inner doorframe
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + (1 / 2) * d, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + 0.68, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + 2.72, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + 3.06, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + 5.10, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + 5.44, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_south[0] + 6.58, 1.51, pos_south[2]])
    greenpole(MiroSystem, d, l, 0, 0,
              [pos_north[0] - (1 / 2) * d, 1.51, pos_north[2]])

    # Horizontal parts
    greenpole(MiroSystem, d, (pos_north[0] - pos_south[0]), 0, 90, [
        (pos_north[0] + pos_south[0]) / 2, 2.5 + d / 2, pos_north[2] - d / 20
    ])
    greenpole(MiroSystem, d, (pos_north[0] - pos_south[0]), 0, 90, [
        (pos_north[0] + pos_south[0]) / 2, 3.0 - d / 2, pos_north[2] - d / 20
    ])

    # Small bits on floor
    for s in [[(1 / 2) * d, 0.68], [2.72, 3.06], [5.10, 5.44],
              [6.58, pos_north[0] - pos_south[0] - (1 / 2) * d]]:
        greenpole(MiroSystem, d, (s[1] - s[0] - d), 0, 90,
                  [pos_south[0] + (s[1] + s[0]) / 2, d / 2, pos_north[2]])

    # Revolving doors
    revolute_door(MiroSystem, d, 0.98, 15,
                  [pos_south[0] + 1.70, 2.4 - d / 2, pos_south[2]])
    revolute_door(MiroSystem, d, 0.98, 50,
                  [pos_south[0] + 4.08, 2.4 - d / 2, pos_south[2]])

    # Side door, inner
    normal_door(MiroSystem, d, 1.1 - d, 232,
                [pos_south[0] + 6.58 - d, 2.5 - d / 2, pos_south[2]])

    ########### INNER PART STOPS HERE ###########
    width = pos_north[0] - pos_south[0] + 3.04
    depth = 5
    inner_depth = 2.8
    p = np.array(
        [pos_south[0] - 2 + width / 2, -0.08, pos_south[2] + depth / 2])
    MiroAPI.add_boxShape(MiroSystem, width, 0.16, 5, p, 'MIT_stone_floor.jpg')
    p = np.array([p[0], 3.08, p[2]])
    MiroAPI.add_boxShape(MiroSystem, width, 0.16, 5, p, 'MIT_stone_floor.jpg')

    # Outer door frames
    z = pos_south[2] + inner_depth
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 0.00 + d / 2, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 0.33, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 1.51, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 1.59, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 2.77, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 3.25, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 4.43, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 4.51, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 5.69, 1.51, z])
    greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 6.02 - d / 2, 1.51, z])

    # Outer doors
    normal_door(MiroSystem, d, 1.1 - d, -42,
                [pos_south[0] + 0.33 + d, 2.5 - d / 2, z])  # south outward
    normal_door(MiroSystem, d, 1.1 - d, 180,
                [pos_south[0] + 2.77 - d, 2.5 - d / 2, z])  # south inward

    normal_door(MiroSystem, d, 1.1 - d, -0,
                [pos_south[0] + 3.25 + d, 2.5 - d / 2, z])  # north outward
    normal_door(MiroSystem, d, 1.1 - d, 180,
                [pos_south[0] + 5.69 - d, 2.5 - d / 2, z])  # north inward

    greenpole(MiroSystem, d, 6.02, 0, 90,
              [pos_south[0] + 3.01, 2.5 + d / 2, z - d / 20])
    greenpole(MiroSystem, d, 6.02, 0, 90,
              [pos_south[0] + 3.01, 3.0 - d / 2, z - d / 20])

    # Small bits on floor
    for s in [[d / 2, 0.33], [2.77, 3.25], [5.69, 6.02 - d / 2]]:
        greenpole(MiroSystem, d, (s[1] - s[0] - d), 0, 90,
                  [pos_south[0] + (s[1] + s[0]) / 2, d / 2, z])

    # south wall
    p = np.array(
        [pos_south[0] - 0.05, 1.51, pos_south[2] + inner_depth / 2 - 0.89 / 2])
    MiroAPI.add_boxShape(MiroSystem,
                         0.1,
                         3.02,
                         inner_depth + 0.89,
                         p,
                         'yellow_brick.jpg',
                         scale=[7, 9])

    # north wall
    np.array([pos_north[0] + 0.05, 1.51, pos_south[2] + inner_depth / 2])
    MiroAPI.add_boxShape(MiroSystem,
                         0.1,
                         3.02,
                         inner_depth,
                         p,
                         'yellow_brick.jpg',
                         scale=[6, 9])

    # WEST WALL
    w = 2
    dw = 0.96

    p = np.array([pos_north[0] + w / 2 - dw, 1.51, z])
    MiroAPI.add_boxShape(MiroSystem,
                         w,
                         3.02,
                         0.16,
                         p,
                         'yellow_brick.jpg',
                         scale=[2, 9],
                         color=[0.6, 0.4, 0.0])

    p = np.array([pos_south[0] - dw, 1.51, z])
    MiroAPI.add_boxShape(MiroSystem,
                         w,
                         3.02,
                         0.16,
                         p,
                         'yellow_brick.jpg',
                         scale=[2, 9],
                         color=[0.6, 0.4, 0.0])

    # Cement pillars outside
    r = 0.12
    p = np.array(
        [pos_south[0] - 1, 1.51, z - r + (depth - inner_depth) * (3 / 4)])
    MiroAPI.add_cylinderShape(MiroSystem,
                              r,
                              3.02,
                              1000,
                              p,
                              'white concrete.jpg',
                              color=[0.8, 0.8, 0.8])

    p = np.array([
        pos_north[0] + 1 - 0.96, 1.51, z - r + (depth - inner_depth) * (3 / 4)
    ])
    MiroAPI.add_cylinderShape(MiroSystem,
                              r,
                              3.02,
                              1000,
                              p,
                              'white concrete.jpg',
                              color=[0.8, 0.8, 0.8])

    p = np.array([pos_south[0] + 1.6, 1.51, z - r + (depth - inner_depth)])
    MiroAPI.add_cylinderShape(MiroSystem,
                              r,
                              3.02,
                              1000,
                              p,
                              'white concrete.jpg',
                              color=[0.8, 0.8, 0.8])

    p = np.array(
        [pos_north[0] - 1.6 - 0.96, 1.51, z - r + (depth - inner_depth)])
    MiroAPI.add_cylinderShape(MiroSystem,
                              r,
                              3.02,
                              1000,
                              p,
                              'white concrete.jpg',
                              color=[0.8, 0.8, 0.8])
예제 #16
0
def revolute_door(MiroSystem, d, l, spin, pos):
    # Revolving door bottom ring
    pos_down = np.array([pos[0], 0.0, pos[2]])
    disk_bot = MiroAPI.add_cylinderShape(MiroSystem,
                                         l,
                                         0.01,
                                         1000,
                                         pos_down,
                                         'MITentrance_floor.png',
                                         Collide=False)

    # Revolving door top ring
    pos_up = np.array([pos[0], pos[1] + 0.1 / 2 + d / 2, pos[2]])
    disk_top = MiroAPI.add_cylinderShape(MiroSystem, l, 0.1, 1000, pos_up,
                                         'MITentrance.png')

    l = l - 0.03
    eps = 0.004
    top = pos[1] - eps
    mid = pos[1] / 2 + d / 4
    bot = d / 2 + eps
    dh = np.array([0, d / 2, 0])

    # middle pole
    pos[1] = mid
    mid_pole = greenpole(MiroSystem,
                         d,
                         top - bot - d,
                         spin,
                         0,
                         pos,
                         Fixed=FIXED)

    # top cross
    pos[1] = top
    top_x = greenpole(MiroSystem, d, 2 * (l - d), spin, 90, pos, Fixed=FIXED)
    top_y = greenpole(MiroSystem,
                      d,
                      2 * (l - d),
                      spin + 90,
                      90,
                      pos,
                      Fixed=FIXED)

    if not FIXED:
        dir1 = [np.cos(np.deg2rad(spin)), 0, np.sin(np.deg2rad(spin))]
        dir2 = [
            np.cos(np.deg2rad(spin + 90)), 0,
            np.sin(np.deg2rad(spin + 90))
        ]
        MiroAPI.LinkBodies_Hinge(top_x, top_y, pos, dir1, MiroSystem)
        MiroAPI.LinkBodies_Hinge(top_x, top_y, pos, dir2, MiroSystem)
        MiroAPI.LinkBodies_Hinge(top_x, mid_pole, pos - dh, dir1, MiroSystem)
        MiroAPI.LinkBodies_Hinge(top_x, disk_top, pos + dh, [0, 1, 0],
                                 MiroSystem)
        MiroAPI.LinkBodies_Hinge(top_y, disk_top, pos + dh, [0, 1, 0],
                                 MiroSystem)

    # bottom cross
    pos[1] = bot
    bot_x = greenpole(MiroSystem, d, 2 * (l - d), spin, 90, pos, Fixed=FIXED)
    bot_y = greenpole(MiroSystem,
                      d,
                      2 * (l - d),
                      spin + 90,
                      90,
                      pos,
                      Fixed=FIXED)

    if not FIXED:
        MiroAPI.LinkBodies_Hinge(bot_x, bot_y, pos, dir1, MiroSystem)
        MiroAPI.LinkBodies_Hinge(bot_x, bot_y, pos, dir2, MiroSystem)
        MiroAPI.LinkBodies_Hinge(bot_x, mid_pole, pos + dh, dir1, MiroSystem)
        MiroAPI.LinkBodies_Hinge(bot_x, disk_top, pos - dh, [0, -1, 0],
                                 MiroSystem)
        MiroAPI.LinkBodies_Hinge(bot_y, disk_top, pos - dh, [0, -1, 0],
                                 MiroSystem)

    cross = [[top_x, bot_x], [top_y, bot_y]]
    p = np.array([pos[0], mid, pos[2]])
    for phi in [0, 90, 180, 270]:
        angle = spin + phi
        dp = np.array([
            np.cos(np.deg2rad(angle)) * (l - d / 2), 0,
            -np.sin(np.deg2rad(angle)) * (l - d / 2)
        ])
        rod = greenpole(MiroSystem,
                        d,
                        top - bot + d,
                        angle,
                        0,
                        p + dp,
                        Fixed=FIXED)
        if not FIXED:
            dh = np.array([0, (top - bot + d) / 2, 0])
            top_bar = cross[round(phi / 90) % 2][0]
            bot_bar = cross[round(phi / 90) % 2][1]
            MiroAPI.LinkBodies_Hinge(top_bar, rod, p + dp + dh, -dp,
                                     MiroSystem)
            MiroAPI.LinkBodies_Hinge(bot_bar, rod, p + dp - dh, -dp,
                                     MiroSystem)

    # side walls
    wid = 0.4
    thick = 0.02
    angle = -13
    height = top - bot + d + 2 * eps
    p = np.array([pos[0] - (l + 0.03 + thick / 2), mid, pos[2]])
    p[0] = p[0] - np.sin(np.deg2rad(angle)) * wid / 2
    p[2] = p[2] - np.cos(np.deg2rad(angle)) * wid / 2
    MiroAPI.add_boxShape(MiroSystem,
                         thick,
                         height,
                         wid,
                         p,
                         'MITentrance.png',
                         rotY=angle,
                         color=[0.02, 0.1, 0.01])

    p[2] = p[2] + np.cos(np.deg2rad(angle)) * wid
    MiroAPI.add_boxShape(MiroSystem,
                         thick,
                         height,
                         wid,
                         p,
                         'MITentrance.png',
                         rotY=-angle,
                         color=[0.02, 0.1, 0.01])

    p[0] = p[0] + np.sin(np.deg2rad(angle)) * wid + 2 * (l + 0.03 + thick / 2)
    MiroAPI.add_boxShape(MiroSystem,
                         thick,
                         height,
                         wid,
                         p,
                         'MITentrance.png',
                         rotY=angle,
                         color=[0.02, 0.1, 0.01])

    p[2] = p[2] - np.cos(np.deg2rad(angle)) * wid
    MiroAPI.add_boxShape(MiroSystem,
                         thick,
                         height,
                         wid,
                         p,
                         'MITentrance.png',
                         rotY=-angle,
                         color=[0.02, 0.1, 0.01])
예제 #17
0
def screen(system, SPEEDMODE=False):
    size_length = 4
    size_width = 0.01
    size_height = size_length / (4 / 3)

    # Screen
    grouplogo_file = '../GroupLogo_local.png'
    if not os.path.isfile('GroupLogo_local.png'):
        grouplogo_file = '../GroupLogo.png'
    alpha = np.pi / 10
    beta = np.pi / 4
    corner_pos = np.array([-5.3, 3.55, -8.8])
    delta_tilt = np.array([
        np.sin(alpha) / np.sqrt(2),
        np.cos(alpha),
        np.sin(alpha) / np.sqrt(2)
    ]) * size_height / 2
    screen_pos = corner_pos + np.array([1 / np.sqrt(8), 0, 1 / np.sqrt(8)
                                        ]) * size_length + delta_tilt
    MiroAPI.add_boxShape(system,
                         size_length,
                         size_height,
                         size_width,
                         screen_pos,
                         texture=grouplogo_file,
                         scale=[-4, -3],
                         rotX=alpha,
                         rotY=beta,
                         rotDegrees=False)

    # Top cylinder
    r = 0.08
    roll_pos = screen_pos + delta_tilt * (
        (1.9 * r + size_height) / size_height)
    MiroAPI.add_cylinderShape(system,
                              0.08,
                              4.15,
                              1000,
                              roll_pos,
                              texture=False,
                              rotAngle=90,
                              rotAxis=[1, 0, 1])

    if not SPEEDMODE:
        # Hanging bars
        bar_h = 0.05
        roller_mid = screen_pos + delta_tilt * (
            (3.9 * r + size_height) / size_height) + np.array(
                [0, bar_h / 2, 0])
        dz = np.array([0, 0, 0.25])
        dx = np.array([0.25, 0, 0])

        offset = np.array([1 / np.sqrt(2), 0, -1 / np.sqrt(2)]) * 1.8
        MiroAPI.add_boxShape(system,
                             bar_h,
                             bar_h,
                             1.2,
                             roller_mid + offset - dz,
                             texture=False)
        MiroAPI.add_boxShape(system,
                             1.2,
                             bar_h,
                             bar_h,
                             roller_mid - offset - dx,
                             texture=False)
예제 #18
0
def table_leg(MiroSystem, leg_pos, size_leg_r, size_leg_h):
    # creating the cylinder leg
    return MiroAPI.add_cylinderShape(MiroSystem, size_leg_r, size_leg_h, 1200, leg_pos, texture='chrome.png', Fixed=FIXED)