Difference between opmode_streaming and opmode_continuous

Typically: "How do I... ", "How can I... " questions
Post Reply
JohnnyMudcrab
Posts: 33
Joined: 07 Mar 2014, 12:26

Difference between opmode_streaming and opmode_continuous

Post by JohnnyMudcrab » 07 Mar 2014, 12:48

Hello,

I tried to stream data from the server into a local buffer using the following code snippet.

Code: Select all


simxFloat value;

simxGetJointPosition(clientID, handle, &value, simx_opmode_streaming);

while(1) {
    simxGetJointPosition(clientID, handle, &value, simx_opmode_buffer);
    Sleep(100);
}

However, it appears that the local buffer was filled once and then wasn't updated anymore. Every time i
read the buffer except the second time simxGetJointPosition returns 1 and value stays the same. That's why i changed the code and used the operation mode continuous instead.

Code: Select all


simxFloat value;

while(1) {
    simxGetJointPosition(clientID, handle, &value, simx_opmode_continuous);
    Sleep(100);
}

That worked like a charm so i was wondering what the difference between the operation modi streaming and continuous is? Is it valid to us continuous to receive data every 10ms?

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

Re: Difference between opmode_streaming and opmode_continuou

Post by coppelia » 07 Mar 2014, 13:13

Hello,

simx_opmode_streaming and simx_opmode_continuous have the exact same behaviour (they are defined both as the same value in the file programming/include/v_repConst.h.

Your code should look like following:

Code: Select all

simxFloat value;
// Tell V-REP to start sending data over. This function does not block (returns immediately):
simxGetJointPosition(clientID, handle, &value, simx_opmode_streaming); 

while(1) {
    // Check if a value has already arrived. This function does not block (returns immediately):
    if (simxGetJointPosition(clientID, handle, &value, simx_opmode_buffer)==simx_error_noerror) {
        // here you have a valid value!
    }
    else
        Sleep(100);
}
You should always keep in mind that when you start streaming data, it will take a few miliseconds until the command has reached the server (V-REP) and the server sent the first value back.

Cheers

Post Reply