Share Memory

Requests or suggestions for new features
dds
Posts: 85
Joined: 20 Mar 2014, 14:35

Share Memory

Post 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.

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

Re: Share Memory

Post 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

dds
Posts: 85
Joined: 20 Mar 2014, 14:35

Re: Share Memory

Post by dds »

Is it feasible generate a shared memory communication via a plugin written in C/C++?

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

Re: Share Memory

Post 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

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

Re: Share Memory

Post 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

dds
Posts: 85
Joined: 20 Mar 2014, 14:35

Re: Share Memory

Post 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

benjamin
Posts: 13
Joined: 12 Feb 2015, 11:50

Re: Share Memory

Post 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.

benjamin
Posts: 13
Joined: 12 Feb 2015, 11:50

Re: Share Memory

Post 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.

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

Re: Share Memory

Post 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

benjamin
Posts: 13
Joined: 12 Feb 2015, 11:50

Re: Share Memory

Post 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.

Post Reply