## RemoteAPI simxGetObjectHandle time

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

### RemoteAPI simxGetObjectHandle time

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
Posts: 7445
Joined: 14 Dec 2012, 00:25

### Re: RemoteAPI simxGetObjectHandle time

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

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
Posts: 7445
Joined: 14 Dec 2012, 00:25

### Re: RemoteAPI simxGetObjectHandle time

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