Esempio n. 1
0
def ExploreWorker(rank, num_processes, childPipe, args):
    print("hi:", rank, " out of ", num_processes)
    import pybullet as op1
    import pybullet_data_local as pd
    logName = ""
    p1 = 0
    n = 0
    space = 2
    simulations = []
    sims_per_worker = 10

    offsetY = rank * space
    while True:
        n += 1
        try:
            # Only block for short times to have keyboard exceptions be raised.
            if not childPipe.poll(0.0001):
                continue
            message, payload = childPipe.recv()
        except (EOFError, KeyboardInterrupt):
            break
        if message == _RESET:
            if (useGUI):
                p1 = bullet_client.BulletClient(op1.GUI)
            else:
                p1 = bullet_client.BulletClient(op1.DIRECT)
            p1.setTimeStep(timeStep)

            p1.setPhysicsEngineParameter(numSolverIterations=8)
            p1.setPhysicsEngineParameter(minimumSolverIslandSize=100)
            p1.configureDebugVisualizer(p1.COV_ENABLE_Y_AXIS_UP, 1)
            p1.configureDebugVisualizer(p1.COV_ENABLE_RENDERING, 0)
            p1.setAdditionalSearchPath(pd.getDataPath())
            p1.setGravity(0, -9.8, 0)
            logName = str("batchsim") + str(rank)
            for j in range(3):
                offsetX = 0  #-sims_per_worker/2.0*space
                for i in range(sims_per_worker):
                    offset = [offsetX, 0, offsetY]
                    sim = panda_sim.PandaSimAuto(p1, offset)
                    simulations.append(sim)
                    offsetX += space
                offsetY += space
            childPipe.send(["reset ok"])
            p1.configureDebugVisualizer(p1.COV_ENABLE_RENDERING, 1)
            for i in range(100):
                p1.stepSimulation()

            logId = p1.startStateLogging(op1.STATE_LOGGING_PROFILE_TIMINGS,
                                         logName)
            continue
        if message == _EXPLORE:
            sum_rewards = rank

            if useGUI:
                numSteps = int(20000)
            else:
                numSteps = int(5)
            for i in range(numSteps):
                for s in simulations:
                    s.step()
                p1.stepSimulation()
            #print("logId=",logId)
            #print("numSteps=",numSteps)

            childPipe.send([sum_rewards])
            continue
        if message == _CLOSE:
            p1.stopStateLogging(logId)
            childPipe.send(["close ok"])
            break
    childPipe.close()
Esempio n. 2
0
if createVideo:
	p.connect(p.GUI, options="--mp4=\"pybullet_grasp.mp4\", --mp4fps=240")
else:
	p.connect(p.GUI)

p.configureDebugVisualizer(p.COV_ENABLE_Y_AXIS_UP,1)
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)

p.resetDebugVisualizerCamera(cameraDistance=1.3, cameraYaw=38, cameraPitch=-22, cameraTargetPosition=[0.35,-0.13,0])
p.setAdditionalSearchPath(pd.getDataPath())

timeStep=1./120.#240.
p.setTimeStep(timeStep)
p.setGravity(0,-9.8,0)

panda = panda_sim.PandaSimAuto(p,[0,0,0])
logId = panda.bullet_client.startStateLogging(panda.bullet_client.STATE_LOGGING_PROFILE_TIMINGS, "log.json")
panda.bullet_client.submitProfileTiming("start")
for i in range (100000):
	panda.bullet_client.submitProfileTiming("full_step")
	panda.step()
	p.stepSimulation()
	if createVideo:
		p.configureDebugVisualizer(p.COV_ENABLE_SINGLE_STEP_RENDERING,1)
	time.sleep(timeStep)
	panda.bullet_client.submitProfileTiming()
panda.bullet_client.submitProfileTiming()
panda.bullet_client.stopStateLogging(logId)