def reset(self): super(StandingUpEnvironment, self).reset() # print('*** Reset ***') vrep.simxStopSimulation(self.client_id, self.opmode) vrep.simxCloseScene(self.client_id, self.opmode) vrep.simxLoadScene(self.client_id, self.model_path, 0, self.opmode) vrep.simxSynchronous(self.client_id, True) vrep.simxStartSimulation(self.client_id, self.opmode) self.bioloid = Bioloid(self.client_id)
def close(self): self.__stop() if self.IS_RECORD: self.__move() if self.IS_BOOT: vrep.simxFinish(self.__ID) os.killpg(os.getpgid(self.vrepProcess.pid), signal.SIGTERM) self.vrepProcess.wait() print("Enviornment was closed") else: vrep.simxCloseScene(self.__ID, vrep.simx_opmode_blocking) vrep.simxFinish(self.__ID) print("Scene was closed") time.sleep(5) # just in case (must in linux?)
def finishSimulation(clientID): errorStop=vrep.simxStopSimulation(clientID,vrep.simx_opmode_oneshot_wait) errorClose=vrep.simxCloseScene(clientID,vrep.simx_opmode_oneshot_wait) error=errorStop or errorClose errorFinish=vrep.simxFinish(clientID) error=error or errorFinish return error
def finishSimulation(self, clientID): self.getObjectPositionFirstTime = True errorStop=vrep.simxStopSimulation(clientID,vrep.simx_opmode_oneshot_wait) errorClose=vrep.simxCloseScene(clientID,vrep.simx_opmode_oneshot_wait) error=errorStop or errorClose errorFinish=vrep.simxFinish(clientID) error=error or errorFinish return error
print("distance to goal:", distanceToGoal) # reward = #checkGoalReached if distanceToGoal < minDistance: goalReached = True time.sleep(0.1) #end of execution loop # stop simulation returnCode = vrep.simxStopSimulation(clientID, vrep.simx_opmode_blocking) printlog('simxStopSimulation', returnCode) running = True while running: returnCode, ping = vrep.simxGetPingTime(clientID) returnCode, serverState = vrep.simxGetInMessageInfo( clientID, vrep.simx_headeroffset_server_state) running = serverState returnCode = vrep.simxCloseScene(clientID, vrep.simx_opmode_blocking) printlog('simxCloseScene', returnCode) vrep.simxFinish(clientID) #close v-rep # vrepProcess.terminate() # vrepProcess.kill() os.killpg(os.getpgid(vrepProcess.pid), signal.SIGTERM) print('Mico Arm Program ended')
def close_scene(self): if not self.scene_loaded: raise RuntimeError('Scene is not loaded') vrep.simxCloseScene(self.client_id, self.modes['blocking']) self.scene_loaded = False
def loadScene(): vrep.simxCloseScene(0, vrep.simx_opmode_oneshot) print ("loading scene") if vrep.simxLoadScene(0, "/home/tutu/projects/ia/2wheel1arm/test/2w1a.ttt", 0, vrep.simx_opmode_blocking) < 0: raise Exception("cannot load scene")
def close_scene(self): if not self.scene_loaded: raise RuntimeError('Scene is not loaded.') self.RAPI_rc(vrep.simxCloseScene(self.cID, vrep.simx_opmode_blocking)) self.scene_loaded = False