Point Cloud Data from VREP to MATLAB

Typically: "How do I... ", "How can I... " questions
Astronirav
Posts: 10
Joined: 03 Jul 2017, 06:00

Point Cloud Data from VREP to MATLAB

Postby Astronirav » 26 Aug 2017, 19:27

Hello,

I'm trying to take the point cloud data obtained from velodyneVPL_16 to Matlab. I've referred to the previous posts and added this function to my velodyneVPL_16 childscript:

Code: Select all

getVelodyneData_function=function(inInts,inFloats,inStrings,inBuffer)
    return {},data,{},''
end


I'm calling this function from Matlab using this:

Code: Select all

[velodyne_pointCloud] = vrep.simxCallScriptFunction(clientID, 'velodyneVPL_16', 1, 'getVelodyneData_function',[],[],[],[],vrep.simx_opmode_blocking);


When I run the simulation, I get following error:

Code: Select all

Error using calllib
Method was not found.

Error in remApi/simxCallScriptFunction (line 2086)
            calllib(obj.libName,'mtlb_simxCallScriptFunction_a',variousIntsIn_,scriptDescriptionAndFunctionName_,inInts_,inFloats_,inStrings_,inBuffer_);
           

Error in main (line 29)
[velodyne_pointCloud] = vrep.simxCallScriptFunction(clientID, 'velodyneVPL_16', 1,
'getVelodyneData_function',[],[],[],[],vrep.simx_opmode_blocking);


I was able to run the simulation before I added velodyne lidar (simpleTest.m file runs fine). I have also changed the remoteApiProto.m file to the one found in the windows (I'm currently using Ubuntu).

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

Re: Point Cloud Data from VREP to MATLAB

Postby coppelia » 28 Aug 2017, 17:07

Hello,

are you using the remote API libraries that came from the same V-REP release you are using?
Can you run the demo program in programming/remoteApiBindings/matlab/matlab/complexCommandTest.m? (Make sure to load the demo scene remoteApiCommandServerExample.ttt for that test).

Cheers

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

Re: Point Cloud Data from VREP to MATLAB

Postby Astronirav » 29 Aug 2017, 17:40

Hi,
It turns out that I'm not able to run 'complexCommandTest.m' file.

When I first ran simpleTest.m file, I was not able to run through port 19999. So I changed it to 19997 and it ran perfectly fine. But when I ran complexCommandTest.m file, connection failed for 19999 and 19998 but it was connected for 19997. But it gives the same error when it reaches this line of the code:

Code: Select all

[velodyne_pointCloud] = vrep.simxCallScriptFunction(clientID, 'velodyneVPL_16', 1, 'getVelodyneData_function',[],[],[],[],vrep.simx_opmode_blocking);


PS: I've updated all remote API library files but still the problem persists.

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

Re: Point Cloud Data from VREP to MATLAB

Postby coppelia » 31 Aug 2017, 08:08

You should read the comments at the top of the Matlab programs you mention..
For complexCommandTest.m for example, it says:

Code: Select all

...
%
% Load the demo scene 'remoteApiCommandServerExample.ttt' in V-REP, then
% start the simulation and run this program.
%
...


Did you do that?

Cheers

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

Re: Point Cloud Data from VREP to MATLAB

Postby Astronirav » 31 Aug 2017, 10:11

Okay, my bad. I didn't run the program (I just opened it) before running complexCommandTest.m file. But when I did as you said, I got this:

Code: Select all

Connected to remote API server
Error using calllib
Method was not found.

Error in remApi/simxCallScriptFunction (line 2086)
            calllib(obj.libName,'mtlb_simxCallScriptFunction_a',variousIntsIn_,scriptDescriptionAndFunctionName_,inInts_,inFloats_,inStrings_,inBuffer_);
           

Error in complexCommandTest (line 39)
        [res retInts retFloats retStrings
        retBuffer]=vrep.simxCallScriptFunction(clientID,'remoteApiCommandServer',vrep.sim_scripttype_childscript,'displayText_function',[],[],'Hello
        world!',[],vrep.simx_opmode_blocking);


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

Re: Point Cloud Data from VREP to MATLAB

Postby coppelia » 01 Sep 2017, 12:47

I can't reproduce that error. What Matlab version are you running? On which platform? Which V-REP version?

Cheers

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

Re: Point Cloud Data from VREP to MATLAB

Postby Astronirav » 01 Sep 2017, 15:16

Matlab R2015a (64 bit)
V-REP 3.4.0 (64 bit)
Ubuntu 14.04 LTS

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

Re: Point Cloud Data from VREP to MATLAB

Postby coppelia » 06 Sep 2017, 07:54

I don't know what is going on on your system. You said previously that you changed the remoteApiProto.m file. Which one did you have and what was the difference between those two files? You shouldn't touch that file, but make sure that it is in the same path as the rest of the remote API required items for Matlab.

Cheers

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

Re: Point Cloud Data from VREP to MATLAB

Postby Astronirav » 11 Sep 2017, 14:41

Hello,
I just shifted everything to Windows and everything is working fine. I'm now getting data (vector) in Matlab. From what I've read in previous posts, it comes in the form: (x1,y1,z1,x2,y2,z2,...). To visualize the data in Matlab, I converted it into X, Y and Z vectors:

Code: Select all

for i = 1:n
 x(i) = a3(i);
 y(i) = a3(i+1);
 z(i) = a3(i+2);
end
scatter3(x,y,z,0.5)

(here n is the length of the vector that I obtained from vrep)

When I plot this, I get 3 different regions of my scene and I'm not able to make sense out of that data.
I'm getting this: https://drive.google.com/open?id=0B65Rebm2Pm6KLXlsakM0U1Z6dlU
Whereas my scene looks like this: https://drive.google.com/open?id=0B65Rebm2Pm6KeVBwWjB5LWJhcTA

Can you please explain to me how to interpret this data? Will I have to perform any rotations? Is there any documentation available for this?

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

Re: Point Cloud Data from VREP to MATLAB

Postby coppelia » 12 Sep 2017, 14:48

Shouldn't it be:

Code: Select all

for i = 1:n
 x(i) = a3(3*i);
 y(i) = a3(3*i+1);
 z(i) = a3(3*i+2);
end
scatter3(x,y,z,0.5)

??

Cheers


Return to “General questions”

Who is online

Users browsing this forum: No registered users and 25 guests