Page 1 of 1

proximity sensors problem

Posted: 06 Jun 2019, 13:45
by luberdis
Hi Coppelia

I am facing 2 problems with ultrasonic sensors.
1)there is a small noise most of the times in the measurement even though the area is clear it seems that it sees something at a distance of 0.02 as a noise
2) I have 3 sensors that they cover 180 degrees , the strange is that when one senros sees something then the other also sensors see the same even though it should be clear.
For example.

As you see only one detector sees the obstacle but also the other receive it. Why???

I run in sychronous mode and i use commands e.g. for sensor 1



Code: Select all

function simpleSynchronousTest()
    disp('Program started');
    % vrep=remApi('remoteApi','extApi.h'); % using the header (requires a compiler)
    vrep=remApi('remoteApi'); % using the prototype file (remoteApiProto.m)
    vrep.simxFinish(-1); % just in case, close all opened connections

    if (clientID>-1)
        disp('Connected to remote API server');

        % enable the synchronous mode on the client:

        % start the simulation:


        % Now step a few times:
        for i=0:1000
%             [returnCode,detectionState3,detectedPoint3,~,~]=vrep.simxReadProximitySensor(clientID,sensor3,vrep.simx_opmode_streaming);
            disp('Press a key to step the simulation!');
        % stop the simulation:

        % Now close the connection to V-REP:    
        disp('Failed connecting to remote API server');
    vrep.delete(); % call the destructor!
    disp('Program ended');

Re: proximity sensors problem

Posted: 14 Jun 2019, 12:17
by coppelia

you really need to be able to locate where the problem is. The problem does not appear to be in V-REP, but more because of the way you interact with V-REP via the remote API. So first thing would be to make sure that in V-REP everything is ok. Next is to find the problem in your client application.

Very probably you are not correctly using the remote API streaming mode. An easy way to check is to use the blocking mode (much slower) first. Then to switch to the streaming mode for values that continuously need to be read. Make sure to carefully read and understand how data streaming works with the remote API.


Re: proximity sensors problem

Posted: 18 Jun 2019, 10:05
by luberdis
Ok! Let us go from beginning, we have a robot that has multiple proximity sensors. At the example is 3 I want in the SAME simulation step each proximity sensor read its current value and then the robot decide what to do. Th problem is that the sensors get the same value of the others. Now I have tested the different streaming options and the only difference I saw is that when I use op_mode_blocking all the sensors take the value of one no matter where it is and when I use op_mode_streaming the sensors who are placed on the left of the detecting sensor get the same value but on the right. I use synchronous mode with Matlab. The documentation focus on how to avoid reading form other steps.

In my case DOESN'T happen this because I step by pressing key. I want the logical thing the sensor give the value of what it detects by itself and not from the neighbouring

I have seen already the other options of remote API. So how would you implement this?

P.S. the only way I avoid this is to use the trigger for the next simulation step, but then the algorithm is wrong they should work in parallel. So the problem is that multiple proximity sensors get the SAME VALUE, it is correct for the one but for the rest is wrong as there is not any obstacle.


Re: proximity sensors problem

Posted: 18 Jun 2019, 10:43
by luberdis
I just saw this post for simReadProximitySensor:

Reads the state of a proximity sensor. This function doesn't perform detection, it merely reads the result from a previous call to sim.handleProximitySensor (sim.handleProximitySensor is called in the default main script). See also sim.checkProximitySensor, sim.checkProximitySensorEx and sim.resetProximitySensor.

To make it clear I want to read the distance from the object.

Re: proximity sensors problem

Posted: 21 Jun 2019, 13:26
by coppelia
Please write a small script that reads and prints the data from those proximity sensors, directly in V-REP. Make sure that those values are correct. Only then, look at the remote API side.
Also, if you are in synchronous mode and haven't yet stepped the simulation, then you won't get any valid data from those proximity sensors, since they haven't yet computed their first values.