RemoteAPI simxGetObjectHandle time

Report crashes, strange behaviour, or apparent bugs
Post Reply
Snork_svk
Posts: 15
Joined: 21 Feb 2013, 08:29

RemoteAPI simxGetObjectHandle time

Post by Snork_svk »

The new version 3.00.3
There was a problem for me, because when using the simxGetObjectHandle.

Probably oneshot_wait operating mode, causing it to acquire "handle flag" takes about 1700 ms is incredibly long time, if I do it for 40 objects at the beginning of the program.

is a way to shorten this time?

Best regards,
Peter
Last edited by Snork_svk on 09 May 2013, 13:17, edited 1 time in total.

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

Re: RemoteAPI simxGetObjectHandle time

Post by coppelia »

Hello Peter,

You are right, in that case it takes long. There is a way to shorten this, try using simxQuery, which is available since version 3.0.3.

Another way to do it would be to retrieve all handles via streaming (i.e. simx_opmode_streaming, then simx_opmode_buffer):

Code: Select all

bool notDone[3]={true,true,true};
simxGetObjectHandle("object1",&handle1,simx_opmode_streaming);
simxGetObjectHandle("object2",&handle2,simx_opmode_streaming);
simxGetObjectHandle("object3",&handle3,simx_opmode_streaming);
while (notDone[0]|notDone[1]|notDone[2])
{
    if (simxGetObjectHandle("object1",&handle1,simx_opmode_buffer)==simx_error_noerror)
    {
        notDone[0]=false;
        simxGetObjectHandle("object1",&handle1,simx_opmode_discontinue);
    }
    if (simxGetObjectHandle("object2",&handle2,simx_opmode_buffer)==simx_error_noerror)
    {
        notDone[1]=false;
        simxGetObjectHandle("object2",&handle2,simx_opmode_discontinue);
    }
    if (simxGetObjectHandle("object3",&handle3,simx_opmode_buffer)==simx_error_noerror)
    {
        notDone[2]=false;
        simxGetObjectHandle("object3",&handle3,simx_opmode_discontinue);
    }
}
We will probably implement another version of simxGetObjectHandle that can retrieve several handles at the same time, that could be useful.

Cheers

Snork_svk
Posts: 15
Joined: 21 Feb 2013, 08:29

Re: RemoteAPI simxGetObjectHandle time

Post by Snork_svk »

Marc, this is a problem only for simxGetObjectHandle function, or all functions using the operating mode oneshot_wait ?

EDIT: Function to return multiple object handle would be very useful, returning to array.


Best regards,
Peter

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

Re: RemoteAPI simxGetObjectHandle time

Post by coppelia »

Hello Peter,

this is not a problem, it operates like this by design. When using the operation mode simx_opmode_oneshot_wait, it will send the command to V-REP, wait until the simulation loop handles it, then send a reply back. And during the whole procedure the client will be waiting. If you do this 400 times, then it will be taking 400 times more time!

simxQuery can help you out, but having a simxGetObjectHandleS could come in handy!

Cheers

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

Re: RemoteAPI simxGetObjectHandle time

Post by coppelia »

Just for info:

Two functions have been implemented to retrieve data of several objects at the same time (including handles) from a remote API client or a ROS node, and will be available in next release (V-REP V3.0.4):

Cheers

Post Reply