Getting the 2D laser data into MATLAB or Excel

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting the 2D laser data into MATLAB or Excel

alexr
Hi,

Is there a way to plot the saved 2D laser scans from the Hokuyo sesor into MATLAB or Excel. I can presently save the scans in .ply format and open them in Meshlab. However, for my research I need to get the data into MATLAB for further line extraction from the laser scans. Can you suggest a way, where in a simple way I can plot the laser scans. (I need the corrected assembled laser scans that is produced before and after optimization using the RTABMAP and graph SLAM)

Thanks

Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: Getting the 2D laser data into MATLAB or Excel

matlabbe
Administrator
Hi Alex,

With the RTAB-Map GUI (rtabmapviz or with the standalone), you can select "File -> Export 2D scans (*.ply, *.pcd)" when there are laser scans shown. If you just loaded a previous database, make sure to do "Edit->Download all clouds (update cache)". Make sure also that checkbox "Cloud filtering" in the Preferences dialog (3D Rendering panel) is not checked, otherwise not all lasers would be exported.

So for the Export 2D scans, select:
1) Assemble scans? NO
2) Binary file? NO
3) Select a directory...
4) File format, select either pcd or ply
5) When you have the pcd or ply, you can open them in a text editor, you will see all the points in plain text with some headers. Either you edit manually, or you may parse them in MATLAB -> Import data... and ignore the header lines.

I'll take a note if I can just add a plain text format (*.txt) where each lines could be "x y z" without headers (tab delimited).

Examples PCD and PLY format:
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 717
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 717
DATA ascii
5.086833 -2.4301226 0
5.0978403 -2.4359834 0
5.1088905 -2.4417987 0
5.1190763 -2.4534991 0
5.1306777 -2.4562593 0
5.141583 -2.4639182 0
5.1533766 -2.465591 0
5.1659813 -2.461266 0
5.2058902 -2.247663 0
[...]

ply
format ascii 1.0
comment PCL generated
element vertex 717
property float x
property float y
property float z
element camera 1
property float view_px
property float view_py
property float view_pz
property float x_axisx
property float x_axisy
property float x_axisz
property float y_axisx
property float y_axisy
property float y_axisz
property float z_axisx
property float z_axisy
property float z_axisz
property float focal
property float scalex
property float scaley
property float centerx
property float centery
property int viewportx
property int viewporty
property float k1
property float k2
end_header
5.086833 -2.4301226 0
5.0978403 -2.4359834 0
5.1088905 -2.4417987 0
5.1190763 -2.4534991 0
5.1306777 -2.4562593 0
5.141583 -2.4639182 0
5.1533766 -2.465591 0
5.1659813 -2.461266 0
5.2058902 -2.247663 0
[...]

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: Getting the 2D laser data into MATLAB or Excel

alexr
Hi Mathieu,

Thanks. I will try to load the data into MATLAB without the headers. Also can you tell me what unit are the scan readings in (meter, cm ??).

Regards
Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: Getting the 2D laser data into MATLAB or Excel

matlabbe
Administrator
It is meter.

cheers
Reply | Threaded
Open this post in threaded view
|

Re: Getting the 2D laser data into MATLAB or Excel

alexr
Dear Mathieu,

Is there a method to save the corrected odometry and raw odometry from rtabmap to plot in matlab. I can get the raw odometry from the rosbag however i cannot find a way to get the corrected one from the graph slam. I want to compare the two odometry into matlab. Can you help me in this?

Thanks

Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: Getting the 2D laser data into MATLAB or Excel

alexr
Hi,

Also I am trying to run this example from here but getting following error when running the command

>>showlogs

Loading log files...
Index exceeds matrix dimensions.

Error in showlogs (line 100)
plot((sum(LogF(:,2:7),2)+LogF(:,17))*1000);

I downloaded the samples folder and followed the steps as described, setting the detection rate to 30 hz and image buffer to 0 and enabling the log in advanced option.

Thanks
Alex
------ Alex
Reply | Threaded
Open this post in threaded view
|

Re: Getting the 2D laser data into MATLAB or Excel

matlabbe
Administrator
This post was updated on .
Hi,

RTAB-Map doesn't save all odometry poses, only those in the nodes of the map's graph. On the GUI (standalone), you can save the TORO graph with optimized or raw poses.
1) Edit -> Avanced -> "Generate TORO graph (*.graph) ..."
2) In the dialog shown, select "Global optimized" for corrected poses/odometry or "Global not optimized" for raw poses/odometry.

The example you try to run is outdated. You would need to remove the headers in the log files (LogF.txt and LogI.txt). You can do it manually or uncheck "Add headers (column names) to log files" in advanced RTAB-Map settings under "Log statistics" group box. Make sure you have the latest showlogs code from Github.

cheers