def startRun(self, time, dt=0.05): self.runFinished = False self.remainingRunTime = time self.dt = dt vrep.simxSetFloatingParameter(self.clientID, vrep.sim_floatparam_simulation_time_step, dt, vrep.simx_opmode_oneshot) # start our simulation in lockstep with our code vrep.simxStartSimulation(self.clientID, vrep.simx_opmode_blocking)
def __init__(self): """Constructor. """ from vrep import vrep as vrep vrep.simxFinish(-1) # just in case, close all opened connections self._clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5) # Connect to V-REP # enable the synchronous mode on the client: vrep.simxSynchronous(self._clientID, True) # start the simulation: vrep.simxStartSimulation(self._clientID, vrep.simx_opmode_oneshot_wait)
def reset(self): # Restart the simulation stop = vrep.simxStopSimulation(self.client_id, vrep.simx_opmode_blocking) stop = vrep.simxStopSimulation(self.client_id, vrep.simx_opmode_blocking) start = vrep.simxStartSimulation(self.client_id, vrep.simx_opmode_blocking) start = vrep.simxStartSimulation(self.client_id, vrep.simx_opmode_blocking) print("Resetting Simulation. Stop Code: {} Start Code: {}".format( stop, start))
def start_simulation(self): self.check_is_connected() # Check if simulation is already running if self.is_running: raise RuntimeError('Simulation is already running.') # Set if communication is synchronous if self.enable_sync: status = vrep.simxSynchronous(self.id, self.enable_sync) self.check_return_code(status) # Start simulation status = vrep.simxStartSimulation(self.id, vrep.simx_opmode_blocking) self.check_return_code(status) # Wait until simulation really started while True: vrep.simxClearIntegerSignal(self.id, "DummySignal", vrep.simx_opmode_oneshot_wait) _, info = vrep.simxGetInMessageInfo( self.id, vrep.simx_headeroffset_server_state) begin_running = info & 1 if begin_running: break self.is_running = True
def __init__(self, client_id): self._clientID = client_id # query wheel joints rc, self._rightWheelJoint = vrep.simxGetObjectHandle(self._clientID, "right_wheel_joint", vrep.simx_opmode_oneshot_wait) rc, self._leftWheelJoint = vrep.simxGetObjectHandle(self._clientID, "left_wheel_joint", vrep.simx_opmode_oneshot_wait) # query create rc, self._create = vrep.simxGetObjectHandle(self._clientID, "create", vrep.simx_opmode_oneshot_wait) # start the simulation: vrep.simxStartSimulation(self._clientID, vrep.simx_opmode_oneshot_wait) self._mode = Mode.Off self._leftEncoderCount = 0 self._rightEncoderCount = 0 self._lastPosRight = None self._lastPosLeft = None self._sensorIDs = None
def start(self): v.simxStartSimulation(self._id, self._def_op_mode)