예제 #1
0
def main():
    vrep.simxFinish(-1)
    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
    if clientID == -1:
        print('Failed connecting to remote API server')
        return

    print('Connected to remote API server')
    # Now try to retrieve data in a blocking fashion (i.e. a service call):
    res, objs = vrep.simxGetObjects(clientID, vrep.sim_handle_all,
                                    vrep.simx_opmode_blocking)
    if res == vrep.simx_return_ok:
        print('Number of objects in the scene:', len(objs))
    else:
        print('Remote API function call returned with error code:', res)

    sleep(2)
    # Now retrieve streaming data (i.e. in a non-blocking fashion):
    vrep.simxGetIntegerParameter(
        clientID, vrep.sim_intparam_mouse_x,
        vrep.simx_opmode_streaming)  # Initialize streaming
    err, Cub1_handle = vrep.simxGetObjectHandle(clientID, "Cub1",
                                                vrep.simx_opmode_oneshot_wait)
    err, nozzle_handle = vrep.simxGetObjectHandle(
        clientID, "nozzle", vrep.simx_opmode_oneshot_wait)

    # M path
    # m_path(30, clientID, Cub1_handle)
    #walk_to(0, 0, 0.5, clientID, Cub1_handle)
    # walk_with(1, 0, 0, clientID, Cub1_handle)
    #walk_with(-0.3, -0.5, 0, clientID, Cub1_handle)
    walk_with(-0.3, -0.3, 0, clientID, Cub1_handle)
    walk_with(0.3, 0.3, 0, clientID, Cub1_handle)

    # Now send some data to V-REP in a non-blocking fashion:
    vrep.simxAddStatusbarMessage(clientID, 'Hello V-REP!',
                                 vrep.simx_opmode_oneshot)
    # Before closing the connection to V-REP, make sure that the last command sent out had time to arrive. You can guarantee this with (for example):
    vrep.simxGetPingTime(clientID)
    # Now close the connection to V-REP:
    vrep.simxFinish(clientID)
예제 #2
0
 def get_dyn_eng_name(self):
     """Retrieve dynamics engine name."""
     dyn_engs_names = {0: "Bullet", 1: "ODE", 2: "Vortex", 3: "Newton"}
     if self._client_id is None:
         raise ConnectionError("Could not retrieve dynamics engine name: "
                               "not connected to V-REP remote API server.")
     res, dyn_eng_id = vrep.simxGetIntegerParameter(
         self._client_id, vrep.sim_intparam_dynamic_engine,
         vrep.simx_opmode_blocking)
     if res != vrep.simx_return_ok:
         raise ServerError("Could not retrieve dynamics engine name.")
     return dyn_engs_names[dyn_eng_id]
예제 #3
0
 def get_version(self):
     """Retrieve V-REP version."""
     if self._client_id is None:
         raise ConnectionError("Could not retrieve V-REP version: not "
                               "connected to V-REP remote API server.")
     res, version = vrep.simxGetIntegerParameter(
         self._client_id, vrep.sim_intparam_program_version,
         vrep.simx_opmode_blocking)
     if res != vrep.simx_return_ok:
         raise ServerError("Could not retrieve V-REP version.")
     return "{x}.{y}.{z}".format(x=version // 10000,
                                 y=(version // 100) % 100,
                                 z=version % 100)
예제 #4
0
파일: vrepcom.py 프로젝트: humm/dovecot
    def get_info(self):
        res, v = remote_api.simxGetIntegerParameter(self.api_id,
                                                    remote_api.sim_intparam_program_version,
                                                    remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['vrep_version'] = v
        res, v = remote_api.simxGetIntegerParameter(self.api_id,
                                                    remote_api.sim_intparam_program_revision,
                                                    remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['vrep_revision'] = v
        res, v = remote_api.simxGetIntegerParameter(self.api_id,
                                                    remote_api.sim_intparam_platform,
                                                    remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['vrep_platform'] = ['Windows', 'Darwin', 'Linux'][v]
        res, v = remote_api.simxGetIntegerParameter(self.api_id,
                                                    remote_api.sim_intparam_dynamic_engine,
                                                    remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['physic_engine'] = ['Bullet', 'ODE', 'Vortex', 'Newton'][v]

        return self.info
예제 #5
0
파일: vrepcom.py 프로젝트: dtbinh/dovecot
    def get_info(self):
        res, v = remote_api.simxGetIntegerParameter(
            self.api_id, remote_api.sim_intparam_program_version,
            remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['vrep_version'] = v
        res, v = remote_api.simxGetIntegerParameter(
            self.api_id, remote_api.sim_intparam_program_revision,
            remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['vrep_revision'] = v
        res, v = remote_api.simxGetIntegerParameter(
            self.api_id, remote_api.sim_intparam_platform,
            remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['vrep_platform'] = ['Windows', 'Darwin', 'Linux'][v]
        res, v = remote_api.simxGetIntegerParameter(
            self.api_id, remote_api.sim_intparam_dynamic_engine,
            remote_api.simx_opmode_oneshot_wait)
        assert res == 0
        self.info['physic_engine'] = ['Bullet', 'ODE', 'Vortex', 'Newton'][v]

        return self.info
예제 #6
0
    print('Connected to remote API server')

    # Now try to retrieve data in a blocking fashion (i.e. a service call):
    res, objs = vrep.simxGetObjects(clientID, vrep.sim_handle_all,
                                    vrep.simx_opmode_blocking)
    if res == vrep.simx_return_ok:
        print('Number of objects in the scene: ', len(objs))
    else:
        print('Remote API function call returned with error code: ', res)

    time.sleep(2)

    # Now retrieve streaming data (i.e. in a non-blocking fashion):
    startTime = time.time()
    vrep.simxGetIntegerParameter(
        clientID, vrep.sim_intparam_mouse_x,
        vrep.simx_opmode_streaming)  # Initialize streaming
    while time.time() - startTime < 5:
        returnCode, data = vrep.simxGetIntegerParameter(
            clientID, vrep.sim_intparam_mouse_x,
            vrep.simx_opmode_buffer)  # Try to retrieve the streamed data
        if returnCode == vrep.simx_return_ok:  # After initialization of streaming, it will take a few ms before the first value arrives, so check the return code
            print(
                'Mouse position x: ', data
            )  # Mouse position x is actualized when the cursor is over V-REP's window
        time.sleep(0.005)

    # Now send some data to V-REP in a non-blocking fashion:
    vrep.simxAddStatusbarMessage(clientID, 'Hello V-REP!',
                                 vrep.simx_opmode_oneshot)
예제 #7
0
clientID=vrep.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to V-REP
if clientID!=-1:
    print ('Connected to remote API server')

    # Now try to retrieve data in a blocking fashion (i.e. a service call):
    res,objs=vrep.simxGetObjects(clientID,vrep.sim_handle_all,vrep.simx_opmode_blocking)
    if res==vrep.simx_return_ok:
        print ('Number of objects in the scene: ',len(objs))
    else:
        print ('Remote API function call returned with error code: ',res)

    time.sleep(2)

    # Now retrieve streaming data (i.e. in a non-blocking fashion):
    startTime=time.time()
    vrep.simxGetIntegerParameter(clientID,vrep.sim_intparam_mouse_x,vrep.simx_opmode_streaming) # Initialize streaming
    while time.time()-startTime < 5:
        returnCode,data=vrep.simxGetIntegerParameter(clientID,vrep.sim_intparam_mouse_x,vrep.simx_opmode_buffer) # Try to retrieve the streamed data
        if returnCode==vrep.simx_return_ok: # After initialization of streaming, it will take a few ms before the first value arrives, so check the return code
            print ('Mouse position x: ',data) # Mouse position x is actualized when the cursor is over V-REP's window
        time.sleep(0.005)

    # Now send some data to V-REP in a non-blocking fashion:
    vrep.simxAddStatusbarMessage(clientID,'Hello V-REP!',vrep.simx_opmode_oneshot)

    # Before closing the connection to V-REP, make sure that the last command sent out had time to arrive. You can guarantee this with (for example):
    vrep.simxGetPingTime(clientID)

    # Now close the connection to V-REP:
    vrep.simxFinish(clientID)
else:
예제 #8
0
    print('Sensor_err: ', errorCode)

    if res == vrep.simx_return_ok:
        print('Number of objects in the scene: ', len(objs))
    else:
        print('Remote API function call returned with error code: ', res)
    time.sleep(2)

    #Initial Velocities
    v = 0.05 * 50
    away = True

    # Now retrieve streaming data (i.e. in a non-blocking fashion):
    startTime = time.time()
    vrep.simxGetIntegerParameter(
        clientID, vrep.sim_intparam_mouse_x,
        vrep.simx_opmode_streaming)  # Initialize streaming
    while time.time() - startTime < 10:

        errorCode = vrep.simxSetJointTargetVelocity(clientID,
                                                    left_motor_handle, v,
                                                    vrep.simx_opmode_streaming)
        errorCode = vrep.simxSetJointTargetVelocity(clientID,
                                                    right_motor_handle, v,
                                                    vrep.simx_opmode_streaming)
        #print('err: ',errorCode)

        errorCode, detectionState, detectedPoint, detectedObjectHandle, detectedSurfaceNormalVector = vrep.simxReadProximitySensor(
            clientID, sensor_handle, vrep.simx_opmode_streaming)
        print('Sensor: ', detectionState)
	def get_integer_parameter(self, param_id):
		return self.RAPI_rc(vrep.simxGetIntegerParameter( self.cID,
			param_id,
			vrep.simx_opmode_blocking))[0]