An asynchronous non-blocking remote exchanging between Vrep and Matlab

Typically: "How do I... ", "How can I... " questions
Post Reply
biscuit122
Posts: 30
Joined: 23 Jan 2018, 16:16

An asynchronous non-blocking remote exchanging between Vrep and Matlab

Post by biscuit122 » 02 Jan 2019, 22:44

I have written low-level controller through Lua in Vrep and optimized APPs in Matlab to get optimal kinematic parameters. In this process, both Matlab and Vrep need to set string signals and get string signals between each other. The code in Matlab is shown as an example.

Code: Select all

    packedFoot=vrep.simxPackFloats(deltaFoot);
    vrep.simxWriteStringStream(clientID,'packedCog',packedCog,vrep.simx_opmode_oneshot);

Code: Select all

[errFP,strFP]=vrep.simxGetStringSignal(clientID,'sentFP',vrep.simx_opmode_oneshot);
        if (errFP==vrep.simx_return_ok)
            posFoot=vrep.simxUnpackFloats(strFP);
        end
At this time, I found a problem that Vrep had not received or published string data when Matlab published data and subscribe to and from Vrep. I tried script parameters between parent and child script though Lua in Vrep. The communicating mode is really great. The operation I have known is that two scripts work on their own flow and update the exchanging script parameters during every simulation loop. So I would like to achieve this type of communication. But I do not know how to accomplish this. I guess that we should use asynchronous non-blocking remote API, if you have a better suggestion, please let me know.

I do not know whether I describe enough clear. But I really need your help. Thanks a lot in advance.

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

Re: An asynchronous non-blocking remote exchanging between Vrep and Matlab

Post by coppelia » 04 Jan 2019, 13:45

Hello,

if you want to pass data between V-REP and a remote API client, then you cannot simply set string signals. You will have to append data on your string signal on one side or the other. Have a look at simxReadStringStream and simxWriteStringStream.

Cheers

Post Reply