Exemplo n.º 1
0
def load_world(world_spec, world):
    with HideOutput():
        # robot = load_model(DRAKE_IIWA_URDF)
        world.load_robot(world_spec['robot_urdf'])

        for obj_spec in world_spec['objects']:
            world.load_object(**obj_spec)

        for shape_spec in world_spec['shapes']:
            world.create_shape(**shape_spec)

        # TODO: HIGH resolve placement chain
        for placement in world_spec['placements']:
            if placement[0] == 'set':
                world.place(world.id(placement[1]), world.id(placement[2]), placement[3])

        for placement in world_spec['placements']:
            if placement[0] == 'on':
                region = None
                if len(placement) == 4:
                    region = placement[3]
                world.random_place(world.id(placement[1]), world.id(placement[2]), region=region)

    set_camera(180, -70, 1.2, Point())

    return world
Exemplo n.º 2
0
def sample_scene():

    with HideOutput():
        # robot = load_model(DRAKE_IIWA_URDF)
        world = World(['table', 'stove', 'sink', 'plate', 'pot', 'cabbage'])
        world.load_robot(URDFS['ph_gripper'])
        world.load_object(URDFS['short_floor'],
                          'table',
                          fixed=True,
                          globalScaling=0.6)
        world.load_object(URDFS['stove'],
                          'stove',
                          fixed=True,
                          globalScaling=0.8)
        world.load_object(URDFS['sink'], 'sink', fixed=True)
        world.load_object(URDFS['plate'], 'plate', fixed=False)
        world.load_object(URDFS['pot'], 'pot', fixed=True)
        world.load_object(URDFS['cabbage'], 'cabbage', fixed=False)
        world.place(world.id('stove/0'), world.id('table/0'),
                    [[0.4, 0, 0], [0, 0, 0, 1]])
        world.place(world.id('sink/0'), world.id('table/0'),
                    [[-0.2, -0.4, 0], [0, 0, 0, 1]])
        # world.place(world.id('plate/0'), world.id('table/0'), [[-0.3, -0.3, 0], [0, 0, 0, 1]])
        world.place(world.id('plate/0'), world.id('table/0'),
                    [[-0.4, 0, 0], [0, 0, 0, 1]])
        # world.place(world.id('pot/0'), world.id('table/0'), [[0.3, -0.3, 0], [0, 0, 0, 1]])
        world.random_place(world.id('pot/0'), world.id('table/0'))
        # world.place(world.id('cabbage/0'), world.id('table/0'), [[0, 0, 0], [0, 0, 0, 1]])
        world.random_place(world.id('cabbage/0'), world.id('table/0'),
                           np.array([[-0.3, -0.2], [0.3, 0.2]]))

    set_camera(180, -60, 1, Point())
    return world