Page 1 of 2

Share Memory

Posted: 08 Apr 2014, 22:26
by dds
Hi. It Would be great to communicate the remote API with shared memory , in order to increased communication speed . For complex applications, sending and receiving (data like pictures) becomes slow.

Re: Share Memory

Posted: 09 Apr 2014, 22:27
by coppelia
Hello,

you are perfectly right, and this makes sense when the remote API client and V-REP run on the same machine.
We have this on the todo list ;)

Cheers,
Marc

Re: Share Memory

Posted: 15 Apr 2014, 22:27
by dds
Is it feasible generate a shared memory communication via a plugin written in C/C++?

Re: Share Memory

Posted: 15 Apr 2014, 23:20
by coppelia
Yes, you can do this. But in order to work with the remote API, it needs a bit of exploration. If you have some ready-to-use code that implements shared memory in a cross-platform manner, we'll take it ;)
But yes, we are already looking into this.

Cheers

Re: Share Memory

Posted: 18 Apr 2014, 02:28
by coppelia
After digging deeper into the shared memory (and in the first place why the communication gets that slow with large data) we found the problem: for historical reasons mainly the CRC of the data sent is being computed. This takes a lot of computation time and is the bottleneck.
Simply make the CRC computation routines all return 0:

  • for the remote API client: file extApi.c: simxUShort _getCRC(const simxUChar* data,simxInt length)
  • for the remote API plugin: file simxUtils.cpp: WORD getCRC(const char* data,int length)

This will be corrected in next release.

Cheers

Re: Share Memory

Posted: 23 Apr 2014, 14:46
by dds
Hi!
When simulator an control algorithm is running on the same computer, sometimes is necessary to synchronize reading and writing data. Share memory would be a big advance in that way but still must to do "pulling" of signals on Client Side and Vrep Side.
In addition to Share memory, it would be great to have an event signalization for reading information. Something like windows message queue

Re: Share Memory

Posted: 18 May 2017, 17:19
by benjamin
I know I dig up the subject but I think it is more appropriated than creating a new one.

After noticing big slow downs when exchanging a lot of data using the remote API I started to wonder if it would be possible to have some shared memory instead to speed up the transfers. I started looking into the remote api plugin code and noticed that some shared memory based communication seems to be implemented using port number < 0.

I tried to use it (recompile the remote api library with USE_ALSO_SHARED_MEMORY) with no luck. Is it functional or is it just some preliminary work? If it is working, is there any documentation? I found none.

Re: Share Memory

Posted: 19 May 2017, 09:27
by benjamin
After some more digging in the source code I realized that the implementation has been done for Windows only and I'm running linux. I'll see if I can make it work for unix systems.

Re: Share Memory

Posted: 20 May 2017, 05:52
by coppelia
Hello Benjamin,

the shared memory started as a test, and yes, only on Windows. This was a couple of years ago, and we didn't continue with it because it wouldn't make a difference big enough.. we thought. So be aware that the code might be outdated. Also, remember that the remote API client and remote API server sides need to be modified for this to work (currently the remote API server side's shared memory code is commented out...).

Cheers

Re: Share Memory

Posted: 20 May 2017, 07:41
by benjamin
I have good news, I made the remote API works with POSIX platforms. I still need to do more tests (check with macOS and Windows) but on my Linux machine it is working. I have a scenario where I get a lot of data from the server (~1800bytes) and I could increase my real time factor in synchronous mode from 0.2 to 0.5.

The code is available here but I don't recommend to use it right now since I made it yesterday and I need to fix the make/project files and test some optimizations.