b0RemoteApi simxReadProximitySensor not returning all objects

Report crashes, strange behaviour, or apparent bugs
Post Reply
Posts: 5
Joined: 30 Jan 2020, 17:11

b0RemoteApi simxReadProximitySensor not returning all objects

Post by charlesleonbarker »


The documentation for the c++ b0RemoteApi simxReadProximitySensor method suggests that the function returns the following:

A vector containing messagePack objects. The returned pointer remains valid until another remote API function is called. For convenience, you can use the helper functions to read its values. The vector contains:
item1 (bool): Whether the function was successfully called on the server side
item2 (int): detection state (0 or 1)
item3 (float): The distance to the detected point
item4 (float[3]): The detected point relative to the sensor frame
item5 (int): The detected object handle
item6 (float[3]): The normal vector of the detected surface, relative to the sensor frame

When the following code is exicuted, a "vector out of range exception" is thrown.

Code: Select all

auto out = APIHandle->simxReadProximitySensor(SensorHandle[i], APIHandle->simxServiceCall());
bool item1 = APIHandle->readBool(out, 0);
LOG(DEBUG) << "1: " << item1;
int item2 = APIHandle->readInt(out, 1);
LOG(DEBUG) <<  " 2: " << item2;
float item3 = APIHandle->readFloat(out, 2);
LOG(DEBUG) << " 3: " << item3;

It seems that simxReadProximitySensor() is returning a vector of capacity 2(Only the first two items).

Has anyone come across this before, or could anyone tell me what I am doing wrong?

IS it do do with simxServiceCall?

Site Admin
Posts: 7911
Joined: 14 Dec 2012, 00:25

Re: b0RemoteApi simxReadProximitySensor not returning all objects

Post by coppelia »


are you sure the proximity sensor is detecting something? If it is not detecting anything, then it won't return the distance to the detected point, and the other values neither, since they won't make sense.


Post Reply