Difference between revisions of "VRep: How to use the synchronous modus operandi when using remote API"

From Macro Wiki
Jump to: navigation, search
(Created page with "The V-REP software allows to customize the simulation through Application Programming Interface (API). You can use a remote API client to connect to V-REP using remote API com...")
 
Line 1: Line 1:
 
The V-REP software allows to customize the simulation through Application Programming Interface (API). You can use a remote API client to connect to V-REP using remote API commands.
 
The V-REP software allows to customize the simulation through Application Programming Interface (API). You can use a remote API client to connect to V-REP using remote API commands.
 +
 
Suppose you want to use the Matlab to control some robot that will be simulated in V-REP. The communication between Matlab and V-REP is, by default, asynchronous. However, it is possible to enable the synchronous mode. To do that, you need to use the line
 
Suppose you want to use the Matlab to control some robot that will be simulated in V-REP. The communication between Matlab and V-REP is, by default, asynchronous. However, it is possible to enable the synchronous mode. To do that, you need to use the line
 +
 
'''vrep.simxSynchronous(clientID, true)'''
 
'''vrep.simxSynchronous(clientID, true)'''
 +
 
at the beginning of your script in Matlab. From there, the communication will behave in the synchronous mode.
 
at the beginning of your script in Matlab. From there, the communication will behave in the synchronous mode.
 
If you want to run an integration step of simulation, you can use the method
 
If you want to run an integration step of simulation, you can use the method
 +
 
'''vrep.simxSynchronousTrigger(clientID)''',
 
'''vrep.simxSynchronousTrigger(clientID)''',
 +
 
also in the Matlab side.
 
also in the Matlab side.
 
Each call of this method runs an integration step of simulation in the V-REP side. If you want that your application runs in 15ms, for example, and the integration step in V-REP is 5ms, you can put the method in a loop that will run three times. This function is usually used after other methods of type “set”, for example, vrep.simxSetJointPosition.
 
Each call of this method runs an integration step of simulation in the V-REP side. If you want that your application runs in 15ms, for example, and the integration step in V-REP is 5ms, you can put the method in a loop that will run three times. This function is usually used after other methods of type “set”, for example, vrep.simxSetJointPosition.
 +
 
To guarantee that the simulation step finished, you can use the method
 
To guarantee that the simulation step finished, you can use the method
vrep.simxGetPingTime(clientID)
+
 
this method is blocking and only returns when the step is finished. This will let you get the right information from VRep , and not wrong data.
+
'''vrep.simxGetPingTime(clientID)'''
 +
 
 +
this method is blocking and only returns when the step is finished. This will let you get the right information from VRep, and not wrong data.
 
You can change the integration step of simulation in VRep. The value of integration step is shown in the following image, in red.
 
You can change the integration step of simulation in VRep. The value of integration step is shown in the following image, in red.
Notice that this value is the integration step of the simulation, but the motors run at 5ms.
+
Notice that this value is the integration step of the '''simulation''', but the motors run at 5ms.
  
 
You can get more information in the V-REP manual, in the [“Remote API modus operandi”] part.
 
You can get more information in the V-REP manual, in the [“Remote API modus operandi”] part.

Revision as of 21:26, 13 April 2016

The V-REP software allows to customize the simulation through Application Programming Interface (API). You can use a remote API client to connect to V-REP using remote API commands.

Suppose you want to use the Matlab to control some robot that will be simulated in V-REP. The communication between Matlab and V-REP is, by default, asynchronous. However, it is possible to enable the synchronous mode. To do that, you need to use the line

vrep.simxSynchronous(clientID, true)

at the beginning of your script in Matlab. From there, the communication will behave in the synchronous mode. If you want to run an integration step of simulation, you can use the method

vrep.simxSynchronousTrigger(clientID),

also in the Matlab side. Each call of this method runs an integration step of simulation in the V-REP side. If you want that your application runs in 15ms, for example, and the integration step in V-REP is 5ms, you can put the method in a loop that will run three times. This function is usually used after other methods of type “set”, for example, vrep.simxSetJointPosition.

To guarantee that the simulation step finished, you can use the method

vrep.simxGetPingTime(clientID)

this method is blocking and only returns when the step is finished. This will let you get the right information from VRep, and not wrong data. You can change the integration step of simulation in VRep. The value of integration step is shown in the following image, in red. Notice that this value is the integration step of the simulation, but the motors run at 5ms.

You can get more information in the V-REP manual, in the [“Remote API modus operandi”] part.