Python remote API in synchronous mode

Typically: "How do I... ", "How can I... " questions
Post Reply
xli4217
Posts: 11
Joined: 13 Oct 2015, 21:08

Python remote API in synchronous mode

Post by xli4217 » 05 May 2016, 01:39

Hi,

As per the title, I'm trying to send my control commands using simxSynchronousTrigger in synchronous mode, the simulation updates at the default rate of every 50ms. However the rate at which I'm sending the commands at the remote side is most likely not every 50ms, so I was wondering how Vrep deals with this discrepancy, does it just throw away command if I'm sending too fast and repeat previous command if I'm sending too slow? Is there a simple way to make sure the synchronization happens nicely or a way to detect if there is such a discrepancy?

Thanks very much!

coppelia
Site Admin
Posts: 7396
Joined: 14 Dec 2012, 00:25

Re: Python remote API in synchronous mode

Post by coppelia » 07 May 2016, 11:01

Hello,

by default the remote API client and V-REP work asynchronously together. And as you mention it, if the client sends a same command more than once for a same simulation step, then only the last command will be retained for processing. This is most of the time not a problem, e.g. when you set an object position several times, then the server will simply set the last specified position for that object. It is important to mention that this command dropping or overwriting happens on a command ID base (and nor for special commands). Two command ids are the same if the command AND the main arguments are the same.

To avoid dropping information you have several possibilities:
Cheers

xli4217
Posts: 11
Joined: 13 Oct 2015, 21:08

Re: Python remote API in synchronous mode

Post by xli4217 » 07 May 2016, 20:16

Thank you.

xli4217
Posts: 11
Joined: 13 Oct 2015, 21:08

Re: Python remote API in synchronous mode

Post by xli4217 » 11 May 2016, 01:51

One more question that came up is that if I'm using simxSynchronousTrigger and in the simulator dt=50ms which is the default, does that mean my simulation no longer updates every 50ms but updates according to the frequency simxSynchronousTrigger is called? If so is there a convenient way to measure at what frequency the simulation updates?

Another question is regarding the data streams I can plot with a graph. Other than the default data stream types, is there a way to plot custom data?

Thanks again

coppelia
Site Admin
Posts: 7396
Joined: 14 Dec 2012, 00:25

Re: Python remote API in synchronous mode

Post by coppelia » 11 May 2016, 17:32

When the real-time mode is not enabled, then your simulation will update and run as fast as possible.

When the real-time mode is enabled, then your simulation will update and run in a way as to keep not running faster than real-time. If your simulation content is heavy, then it will not keep up with the real-time.

So in your case, if you have not enabled the real-time mode, then each time you send one trigger, the simulation will advance by 50ms. 50ms in simulation time!

For displaying custom data in a graph, have a look here.

Cheers

Post Reply