예제 #1
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    slopeLeft = [200, 400]
    slopeRight = [100, 190]
    slopeWidth = [100, 300]
    goalHeightMin = 60
    goalWidth = [80, 150]
    strutHeightMin = 40
    strutWid = [15, 40]

    flip_lr = rng.uniform(0, 1) < 0.5
    ## Make the slope
    sL = rng.uniform(slopeLeft[0], slopeLeft[1])
    sR = rng.uniform(slopeRight[0], slopeRight[1])
    sW = rng.uniform(slopeWidth[0], slopeWidth[1])
    slopeVerts = [[0, 0], [0, sL], [sW, sR], [sW, 0]]

    ## Make the goal
    goalH = rng.uniform(goalHeightMin, sR)
    goalW = rng.uniform(goalWidth[0], goalWidth[1])
    goalL = vt.VT_SCALE - goalW + 5
    goalR = vt.VT_SCALE - 5
    goalVerts = [[goalL, goalH], [goalL, 5], [goalR, 5], [goalR, goalH]]

    ## Find the ball position
    bpos = [30, sL + 15]

    ## Make the falling table
    tabL = sW + 15
    tabR = vt.VT_SCALE - goalW - 8
    tabVerts = [[tabL, sR], [tabL, sR + 10], [tabR, sR + 10], [tabR, sR]]

    if flip_lr:
        slopeVerts = vt.flip_left_right(slopeVerts)
        bpos = vt.flip_left_right(bpos)
        tabVerts = vt.flip_left_right(tabVerts)

    ## Make the world getting into the container
    slopeVerts.reverse()
    tabVerts.reverse()

    slope = C.add_convex_polygon(vt.convert_phyre_tools_vertices(slopeVerts),
                                 False)
    container, _ = vt.add_container(C,
                                    goalVerts,
                                    10,
                                    False,
                                    True,
                                    flip_lr=flip_lr)
    ball = C.add('dynamic ball',
                 30. / vt.VT_SCALE,
                 center_x=bpos[0] * C.scene.width / vt.VT_SCALE,
                 center_y=bpos[1] * C.scene.height / vt.VT_SCALE)
    table = C.add_convex_polygon(vt.convert_phyre_tools_vertices(tabVerts),
                                 True)
    C.update_task(body1=ball,
                  body2=container,
                  relationships=[C.SpatialRelationship.TOUCHING])

    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)
예제 #2
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    tableWidth = [300, 400]
    tableHeight = [100, 400]
    ballSize = [10, 30]
    goalHeight = [50, 200]
    slopeL = [20, 100]
    slopeW = [10, 50]

    flip_lr = rng.uniform(0, 1) < 0.5

    tableDims = [
        rng.uniform(tableWidth[0], tableWidth[1]),
        rng.uniform(tableHeight[0], tableHeight[1])
    ]
    ballRad = rng.uniform(ballSize[0], ballSize[1])

    sW = rng.uniform(slopeW[0], slopeW[1])
    sL = rng.uniform(slopeL[0], slopeL[1])
    slopeVerts = [[0, tableDims[1]], [0, sL + tableDims[1]],
                  [sW, tableDims[1]]]
    slopeVerts.reverse()

    ballPos = rng.uniform(ballRad + 5 + sW, tableDims[0] - ballRad - 5)
    coverL = rng.uniform(ballPos - ballRad * 3, ballPos - ballRad)
    coverR = rng.uniform(ballPos + ballRad, ballPos + ballRad * 3)
    coverY = min([
        rng.uniform(ballRad * 2 + tableDims[1], ballRad * 5 + tableDims[1]),
        vt.VT_SCALE - 15
    ])

    goalDims = [
        rng.uniform(ballRad * 2 + 5, vt.VT_SCALE - tableDims[0] - 30),
        rng.uniform(goalHeight[0], min([goalHeight[1], tableDims[1] - 10]))
    ]
    goalXPos = rng.uniform(tableDims[0] + 10, (vt.VT_SCALE - goalDims[0] - 10))

    if flip_lr:
        slopeVerts = vt.flip_left_right(slopeVerts)
        ballPos = vt.flip_left_right(ballPos)

    table = vt.add_box(C, [0, 0, tableDims[0], tableDims[1]],
                       False,
                       flip_lr=flip_lr)
    cover = vt.add_box(C, [coverL, coverY, coverR, coverY + 15],
                       False,
                       flip_lr=flip_lr)

    slope = C.add_convex_polygon(vt.convert_phyre_tools_vertices(slopeVerts),
                                 False)
    ball = C.add('dynamic ball',
                 ballRad * 2. / vt.VT_SCALE,
                 center_x=ballPos * C.scene.width / vt.VT_SCALE,
                 bottom=tableDims[1] * C.scene.height / vt.VT_SCALE)
    goalVerts = [[goalXPos, goalDims[1]], [goalXPos, 5],
                 [goalXPos + goalDims[0], 5],
                 [goalXPos + goalDims[0], goalDims[1]]]
    container_id, bbid = vt.add_container(C,
                                          goalVerts,
                                          10,
                                          False,
                                          True,
                                          flip_lr=flip_lr)
    C.update_task(body1=ball,
                  body2=container_id,
                  relationships=[C.SpatialRelationship.TOUCHING])

    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)
예제 #3
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    cataWidth = [200, 400]
    cataHeight = [30, 100]
    ballRad = [5, 15]
    strutWidth = [10, 50]
    strutHeight = [60, 200]
    goalWidth = [60, 150]
    goalHeight = [60, 180]
    cataThick = [5, 10]
    spacing = [25, 100]
    strutPlace = [0, 150]

    ## Define the features first
    cW = rng.uniform(cataWidth[0], cataWidth[1])
    cH = 20.
    bR = rng.uniform(ballRad[0], ballRad[1])
    sW = rng.uniform(strutWidth[0], strutWidth[1])
    sH = rng.uniform(strutHeight[0], strutHeight[1])
    gW = rng.uniform(goalWidth[0], goalWidth[1])
    gH = rng.uniform(goalHeight[0], goalHeight[1])
    cT = rng.uniform(cataThick[0], cataThick[1])
    sp = rng.uniform(spacing[0], spacing[1])
    stP = rng.uniform(strutPlace[0], strutPlace[1])
    stP = min([stP, cW / 2])

    flip_lr = rng.uniform(0, 1) < 0.5
    ## Then fit together
    cataCent = vt.VT_SCALE - gW - sp - cW / 2
    cataLeft = cataCent - cW / 2

    ## Make the world
    strut = vt.add_box(
        C, [cataCent - sW / 2 + stP, 0, cataCent + sW / 2 + stP, sH],
        False,
        flip_lr=flip_lr)
    cradle = vt.add_box(C, [cataLeft, 0, cataLeft + 10, sH],
                        False,
                        flip_lr=flip_lr)
    container, _ = vt.add_container(
        C, [[vt.VT_SCALE - gW, gH], [vt.VT_SCALE - gW, 5],
            [vt.VT_SCALE - 5, 5], [vt.VT_SCALE - 5, gH]],
        10,
        False,
        True,
        flip_lr=flip_lr)
    polys = [[[cataLeft, sH], [cataLeft, sH + cT], [cataLeft + cT, sH + cT],
              [cataLeft + cT, sH]],
             [[cataLeft, sH + cT], [cataLeft, sH + cH],
              [cataLeft + cT, sH + cH], [cataLeft + cT, sH + cT]],
             [[cataLeft + cT, sH], [cataLeft + cT, sH + cT],
              [cataLeft + cW, sH + cT], [cataLeft + cW, sH]]]
    for p in polys:
        p.reverse()

    if flip_lr:
        p = vt.flip_left_right(p)
        center_x = vt.flip_left_right(cataLeft + cT + bR + 30)
    else:
        center_x = cataLeft + cT + bR + 30
    converted_polylist = [
        vt.convert_phyre_tools_vertices(poly) for poly in polys
    ]
    catapult = C.add_multipolygons(polygons=converted_polylist, dynamic=True)

    ball = C.add('dynamic ball',
                 bR * 2. / vt.VT_SCALE,
                 center_x=center_x * C.scene.width / vt.VT_SCALE,
                 center_y=(sH + cT + bR) * C.scene.width / vt.VT_SCALE)
    C.update_task(body1=ball,
                  body2=container,
                  relationships=[C.SpatialRelationship.TOUCHING])

    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)
    '''pgw.addBox('Strut', [cataCent - sW/2 + stP, 0, cataCent + sW/2 + stP, sH], 'black', 0)
예제 #4
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    leftWall = [80, 180]
    breakPoint = [0.2, 0.8]
    bridgeLength = [150, 300]
    slopeL = [60, 200]
    slopeR = [250, 400]

    flip_lr = rng.uniform(0, 1) < 0.5

    ## Make the goal container
    height = rng.uniform(slopeL[0], slopeL[1])
    lW = rng.uniform(leftWall[0], leftWall[1])
    container, _ = vt.add_container(
        C, [[5, height], [5, 5], [lW - 5, 5], [lW - 5, height]],
        10,
        False,
        True,
        flip_lr=flip_lr)  #'green', 0)

    ## Make the bridge
    bL = rng.uniform(bridgeLength[0], bridgeLength[1])
    bP = rng.uniform(breakPoint[0], breakPoint[1])
    bridgeL = vt.add_box(
        C, [lW + 20 + 2, height + 10, lW + 20 + 2 + bL * bP, height + 20],
        True,
        flip_lr=flip_lr)
    bridgeR = vt.add_box(C, [
        lW + 20 + 2 + bL * bP + 2, height + 10, lW + 20 + 2 + bL + 2,
        height + 20
    ],
                         True,
                         flip_lr=flip_lr)

    ## Make the left wall
    lw1 = vt.add_box(C, [lW, 0, lW + 40, height - 10], False, flip_lr=flip_lr)
    lw2 = vt.add_box(C, [lW, height - 10, lW + 20, height],
                     False,
                     flip_lr=flip_lr)

    ## Make the right wall
    sW = rng.uniform(min([lW + 20 + 2 + bL + 2, vt.VT_SCALE - 30]),
                     max([vt.VT_SCALE - 30, lW + 20 + 2 + bL + 2]))
    rw1 = vt.add_box(C,
                     [lW + 20 + 2 + bL + 2 - 50, 0, vt.VT_SCALE, height - 10],
                     False,
                     flip_lr=flip_lr)
    rw2 = vt.add_box(C, [lW + 20 + 2 + bL + 2, 0, sW, height],
                     False,
                     flip_lr=flip_lr)
    ## Make the slope
    sR = rng.uniform(slopeR[0], slopeR[1])
    slopeVerts = [(sW, height - 10), (sW, height), (vt.VT_SCALE, sR),
                  (vt.VT_SCALE, height - 10)]
    slopeVerts.reverse()
    if flip_lr:
        slopeVerts = vt.flip_left_right(slopeVerts)
        center_x = vt.flip_left_right(rng.uniform(500, 575))
    else:
        center_x = rng.uniform(500, 575)

    rw2 = C.add_convex_polygon(vt.convert_phyre_tools_vertices(slopeVerts),
                               False)

    center_y = rng.uniform(425, 525)
    ball = C.add('dynamic ball',
                 15 * 2. / vt.VT_SCALE,
                 center_x=center_x * C.scene.width / vt.VT_SCALE,
                 center_y=center_y * C.scene.width / vt.VT_SCALE)

    C.update_task(body1=ball,
                  body2=container,
                  relationships=[C.SpatialRelationship.TOUCHING])
    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)
예제 #5
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    slopeLeft = [300, 450]
    slopeRight = [200, 350]
    slopeWidth = [200, 300]
    ballXPos = [50, 150]
    ballYPos = [15, 50]
    gapWidth = [60, 200]
    supportX = [5, 25]
    supportY = [-5, 80]
    lidThick = [15, 40]

    flip_lr = rng.uniform(0, 1) < 0.5
    ## Make the slope
    sL = rng.uniform(slopeLeft[0], slopeLeft[1])
    sR = rng.uniform(slopeRight[0], slopeRight[1])
    sW = rng.uniform(slopeWidth[0], slopeWidth[1])
    slopeVerts = [[0.0, 0.0], [0.0, sL], [sW, sR], [sW, 0]]

    ## Make the gap
    gW = rng.uniform(gapWidth[0], gapWidth[1])
    strutSupportBox = [sW, 0, sW + gW, sR - 150]

    ## Make the support
    jitterX = rng.uniform(supportX[0], supportX[1])
    jitterY = rng.uniform(supportY[0], supportY[1])
    lidT = rng.uniform(lidThick[0], lidThick[1])
    supportBox = [
        sW + jitterX, sR + jitterY, sW + gW - jitterX, sR + jitterY + lidT
    ]

    ## Make the goal
    goalSegs = [[sW + gW, sR - 50], [sW + gW, 5], [550, 5], [550, sR - 50]]

    ## Find the ball position
    bX = rng.uniform(ballXPos[0], ballXPos[1])
    bY = sL * (sW - bX) / sW + sR
    bpos = [
        bX, bY +
        rng.uniform(ballYPos[0], np.min([ballYPos[1], vt.VT_SCALE - bY - 15]))
    ]

    ## Make the world getting into the container
    slopeVerts.reverse()

    if flip_lr:
        slopeVerts = vt.flip_left_right(slopeVerts)
        bpos = vt.flip_left_right(bpos)

    slope = C.add_convex_polygon(vt.convert_phyre_tools_vertices(slopeVerts),
                                 False)
    container, _ = vt.add_container(C,
                                    goalSegs,
                                    10,
                                    False,
                                    True,
                                    flip_lr=flip_lr)
    ball = C.add('dynamic ball',
                 30. / vt.VT_SCALE,
                 center_x=bpos[0] * C.scene.width / vt.VT_SCALE,
                 center_y=bpos[1] * C.scene.height / vt.VT_SCALE)
    strutBox = vt.add_box(C, strutSupportBox, False, flip_lr=flip_lr)
    support = vt.add_box(C, supportBox, True, flip_lr=flip_lr)

    C.update_task(body1=ball,
                  body2=container,
                  relationships=[C.SpatialRelationship.TOUCHING])

    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)
예제 #6
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    goalWidth = [100, 200]
    goalHeight = [80, 100]
    ballRad = [7, 12]
    slopeLeft = [40, 70]
    slopeRight = [5, 10]
    slopeWidth = [200, 275]
    slopeHeight = [380, 450]
    platformLeft = [300, 400]
    platformRight = [475, 500]
    platformHeight = [200, 250]
    blockSize = [30, 40]
    pWidth = 15  ## Platform Vertical Width

    flip_lr = rng.uniform(0, 1) < 0.5
    gW = rng.uniform(goalWidth[0], goalWidth[1])
    gH = rng.uniform(goalHeight[0], goalHeight[1])
    bR = rng.uniform(ballRad[0], ballRad[1])
    sL = rng.uniform(slopeLeft[0], slopeLeft[1])
    sR = rng.uniform(slopeRight[0], slopeRight[1])
    sW = rng.uniform(slopeWidth[0], slopeWidth[1])
    sH = rng.uniform(slopeHeight[0], slopeHeight[1])
    pL = rng.uniform(platformLeft[0], platformLeft[1])
    pR = rng.uniform(platformRight[0], platformRight[1])
    pH = rng.uniform(platformHeight[0], platformHeight[1])
    bS = rng.uniform(blockSize[0], blockSize[1])
    jitter = rng.uniform(0, pR - pL)
    ## Set params
    bLeft = (pR - pL) / 2 - bS / 2  ## Left bound of block

    slopeVerts = [[0, sH], [0, sH + sL], [sW, sH + sR], [sW, sH]]
    if flip_lr:
        slopeVerts = vt.flip_left_right(slopeVerts)
        blockXPos = vt.flip_left_right(pL + jitter)
        ballXPos = vt.flip_left_right(bR + 5)
    else:
        blockXPos = pL + jitter
        ballXPos = bR + 5

    ## Make the world
    slopeVerts.reverse()
    slope = C.add_convex_polygon(vt.convert_phyre_tools_vertices(slopeVerts),
                                 False)
    container, _ = vt.add_container(
        C, [[vt.VT_SCALE - 5 - gW, gH], [vt.VT_SCALE - 5 - gW, 0.0],
            [vt.VT_SCALE - 5, 0.0], [vt.VT_SCALE - 5, gH]],
        10,
        False,
        True,
        flip_lr=flip_lr)
    #block = vt.add_box(C, [pL, pH + pWidth, bS + pL, pH + pWidth + bS], True)
    block = C.add('dynamic ball',
                  bS / vt.VT_SCALE,
                  center_x=blockXPos * C.scene.width / vt.VT_SCALE,
                  bottom=(pH + pWidth) * C.scene.width / vt.VT_SCALE)
    platform = vt.add_box(C, [pL, pH, pR, pH + pWidth], False, flip_lr=flip_lr)
    ball = C.add('dynamic ball',
                 bR * 2 / vt.VT_SCALE,
                 center_x=ballXPos * C.scene.width / vt.VT_SCALE,
                 center_y=(sL + sH + bR) * C.scene.height / vt.VT_SCALE)

    C.update_task(body1=ball,
                  body2=container,
                  relationships=[C.SpatialRelationship.TOUCHING])

    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)
예제 #7
0
def build_task(C, seed):
    rng = np.random.RandomState(seed=seed)
    slopeLeft = [200, 400]
    slopeRight = [100, 190]
    slopeWidth = [100, 300]
    ballXPos = [30, 100]
    ballYPos = [15, 50]
    goalHeightMin = 60
    goalWidth = [80, 150]
    lidWidthExtra = [10, 50]
    lidThick = [8, 20]

    flip_lr = rng.uniform(0, 1) < 0.5
    ## Make the slope
    sL = rng.uniform(slopeLeft[0], slopeLeft[1])
    sR = rng.uniform(slopeRight[0], slopeRight[1])
    sW = rng.uniform(slopeWidth[0], slopeWidth[1])
    slopeVerts = [[0, 0], [0, sL], [sW, sR], [sW, 0]]

    ## Make the goal
    goalH = rng.uniform(goalHeightMin, sR)
    goalW = rng.uniform(goalWidth[0], goalWidth[1])
    goalL = sW
    goalR = sW + goalW
    goalVerts = [[goalL, goalH], [goalL, 5], [goalR, 5], [goalR, goalH]]

    ## Find the ball position
    bpos = [
        rng.uniform(ballXPos[0], ballXPos[1]),
        sL + min([rng.uniform(ballYPos[0], ballYPos[1]), vt.VT_SCALE - 15])
    ]

    ## Make the lid
    lidT = rng.uniform(lidThick[0], lidThick[1])
    lidExtent = rng.uniform(lidWidthExtra[0], lidWidthExtra[1])
    lidBbox = [goalL, goalH + 5, goalR + lidExtent, goalH + 5 + lidT]

    ## Make the world getting into the container
    slopeVerts.reverse()

    if flip_lr:
        slopeVerts = vt.flip_left_right(slopeVerts)
        bpos = vt.flip_left_right(bpos)

    slope = C.add_convex_polygon(vt.convert_phyre_tools_vertices(slopeVerts),
                                 False)
    container, _ = vt.add_container(C,
                                    goalVerts,
                                    10,
                                    False,
                                    True,
                                    flip_lr=flip_lr)
    ball = C.add('dynamic ball',
                 30. / vt.VT_SCALE,
                 center_x=bpos[0] * C.scene.width / vt.VT_SCALE,
                 center_y=bpos[1] * C.scene.height / vt.VT_SCALE)
    lid = vt.add_box(C, lidBbox, True, flip_lr=flip_lr)
    C.update_task(body1=ball,
                  body2=container,
                  relationships=[C.SpatialRelationship.TOUCHING])

    C.set_meta(C.SolutionTier.VIRTUAL_TOOLS)