Exemple #1
0
def load_save_template(world):
    """Shows the load/save functions. First loads a Config resource, then ask you to save the edited config"""
    fn, q = resource.load('Config')
    resource.edit('loaded config', q, world=world)
    resource.save(q)
Exemple #2
0
#gridres = 0.1
#pcres = 0.05

geometryopt.TEST_PYCCD = False

DUMP_SDF = False
DRAW_GRID_AND_PC = False
VERBOSE = 0

world = WorldModel()

if len(sys.argv) > 1:
    for fn in sys.argv[1:]:
        world.readFile(fn)
else:
    res = resource.load('WorldModel')
    if res is not None:
        fn,world = res
    else:
        exit(1)

if world.numRobots() == 0:
    print("Must specify a robot")
    exit(1)

robot = world.robot(0)
obstacles = []
for i in xrange(1,world.numRobots()):
    for j in xrange(world.robot(i).numLinks()):
        obstacles.append(world.robot(i).link(j))
for i in xrange(world.numRigidObjects()):
#you can play with these parameters
gridres = 0.05
pcres = 0.02

if len(sys.argv) > 1:
    fn = sys.argv[1]
    resource.setDirectory('.')
    obj = resource.get(fn, 'Geometry3D')

    if len(sys.argv) > 2:
        fn2 = sys.argv[2]
        obj2 = resource.get(fn2, 'Geometry3D')
    else:
        obj2 = obj.clone()
else:
    res = resource.load('Geometry3D')
    if res is not None:
        fn, obj = res
    else:
        exit(1)
    print "Cloning object for second object"
    obj2 = obj.clone()

if obj is None:
    exit(1)

print "Input object has type", obj.type(), "with", obj.numElements(
), "elements"
geom1 = PenetrationDepthGeometry(obj, gridres, pcres)
geom2 = PenetrationDepthGeometry(obj2, gridres, pcres)