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

From Macro Wiki
Jump to: navigation, search
Line 5: Line 5:
'''simExtRemoteApiStart(portNumber, 1300, false, true)'''
'''simExtRemoteApiStart(portNumber, 1300, false, true)'''
in you VRep script, and the line
in you VRep script, and the line
'''vrep.simxSynchronous(clientID, true)'''
'''vrep.simxSynchronous(clientID, true)'''

Latest revision as of 18:29, 10 September 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

simExtRemoteApiStart(portNumber, 1300, false, true)

in you VRep script, and 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


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


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.

Vrep wiki.jpg

Notice that this value is the integration step of the simulation, but the engines always run at 5ms.

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