How to sent data to Vrep from Matlab

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

How to sent data to Vrep from Matlab

Post by biscuit122 » 01 Feb 2019, 04:01

I have tried codes in Vrep side to receive data from Matlab in a Synchronous mode.

Code: Select all

function sysCall_init()
    s=0
    lastReceivedFX=-1
    lastReceivedPos=-1
end
function sysCall_actuation()
local packedFX=sim.getStringSignal('packedFX')
            if packedFX then 
                sim.clearStringSignal('packedFX')
                packedFX=sim.unpackFloatTable(packedFX)
                for j=1,#packedFX,1 do 
                    if packedFX[j]~=lastReceivedFX+1 then 
                        print('Error')
                    else
                    io.write('.')
                        lastReceivedFX=packedFX[s]
                    end
                end
            end
end
The code in Matlab side is shown as follows:

Code: Select all

packedFX = vrep.simxPackFloats(xFoot);
vrep.simxWriteStringStream(clientID,'packedFX',packedFX,vrep.simx_opmode_oneshot);
But it is always found that packedFX in Vrep cannot output value every sampling time, but accumulate several arrays then output about more than 20 or 30 goups of value. Could you help me with finding the reason? Thanks.

Post Reply