How to parse data from 2D laser scanner in MATLAB?

Typically: "How do I... ", "How can I... " questions
Post Reply
strider
Posts: 1
Joined: 21 Jan 2017, 16:03

How to parse data from 2D laser scanner in MATLAB?

Post by strider » 21 Jan 2017, 22:43

Hello,

We are trying to read 2D laser scanner data from MATLAB via remote api.

We checked out the following post and managed to get laser scanner data (a 1xnumber_of_points matrix) to MATLAB with the code given below; however, we could not make any sense out of it.

We guess that the data is in the form of x,y,z coordinates for each laser point but we are not sure about evaluating/parsing the data matrix.

Is it with respect to robot coordinate frame or sensor coordinate frame?

viewtopic.php?f=9&t=1535

Code: Select all

Matlab Code:
[returnCode,signal] = vrep.simxGetStringSignal(clientID,'measuredDataAtThisTime',vrep.simx_opmode_buffer);
        if(vrep.simx_return_ok == returnCode)
            data=vrep.simxUnpackFloats(signal);

Aside from this issue, is there a way to represent occupancy grid maps in V-REP?

Thank you in advance,

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

Re: How to parse data from 2D laser scanner in MATLAB?

Post by coppelia » 23 Jan 2017, 11:58

Hello,

the data is normally relative to the model reference frame. If you need another type of data (e.g. angle+detected distances), you will have to slightly modify the child script loop that reads out the points.

To read the data from a remote API client such as Matlab, there is now a better method: you can use simxCallScriptFunction.

Your question about the occupancy grid, is it related to visualization only? If yes, you have several possibilities:
Above functions can only be called locally (i.e. not from a remote API client). But you always have the possibility to indirectly call above function via simxCallScriptFunction, from your remote API client.

Cheers

Astronirav
Posts: 10
Joined: 03 Jul 2017, 06:00

Re: How to parse data from 2D laser scanner in MATLAB?

Post by Astronirav » 14 Jul 2017, 13:07

Hello Coppelia,

I am using the same laser scanner and facing a similar problem.
I've added the following code in the child script of the robot:

Code: Select all

data=simPackFloats(points)
simSetStringSignal("measuredDataAtThisTime",data)
Now, to get the value of range I've written following code in MATLAB:

Code: Select all

[returnCode, signalValue] = vrep.simxGetStringSignal(clientID,'measuredDataAtThisTime',vrep.simx_opmode_streaming);
	while(1)
		[returnCode, signalValue] = vrep.simxGetStringSignal(clientID,'measuredDataAtThisTime',vrep.simx_opmode_buffer);
		disp(signalValue);
		pause(0.1);
	end
It prints some kind of cryptic code like this: https://drive.google.com/open?id=0B65Re ... 19TUHFRSE0

Is it because the child script sent packed code and I didn't unpack it in MATLAB?
How can I overcome this problem?

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

Re: How to parse data from 2D laser scanner in MATLAB?

Post by coppelia » 16 Jul 2017, 19:52

Hello,

yes, if you packed the data, then you should unpack it on the Matlab side, with simxUnpackFloats.

Cheers

Post Reply