generatePointCloudFromALog

Example Matlab© code which loads odometry and laser data, projects laser ranges into 3D and optionally displays in Matlab© and saves to file.

generatePointCloudFromAlog.m

Simple Example

To run

  generatePointCloudFromALog;

The code will fill in the input arguments with the correct values for this example.

Outputs

  • A figure with interpolated trajectory of the research platform.
  • A second figure with the laser range data projected into 3D using the vehicle odometry.
  • A plain text file called ptsWithRefl.txt in the current directory.

The text file has the following column format:

 [ X Y Z R G B ] 

R, G and B are 0-255 integer colour channels that have been generated from laser reflectance data.

Input Arguments

The following details all generatePointCloudFromALog’s input and output arguments.

Verbosity

All functions use a simple verbosity paradigm to control code reporting:

0 – no text reporting (except errors and messages generated by Matlab©)

1 – essential text only (warnings, errors and messages generated by Matlab©)

2 – text reporting but no graphics

3 – fully verbose

inputStruct

This Matlab© structure contains all the information the code requires to load data in the following fields:

FieldName Simple Example Description
-To indicate which input method to use:
useALog false Optional: Boolean to switch between invoking uAlogParser on ALogFile (true) or loading ASCII text files odomTxtFile and laserTxtFile (false or not present).
-When useALog=true (uAlogParser invoked to extract data from ALog):
ALogFile QuadTree_Alog.ALog Required: Full or relative path (depending on useGlobalTime) for the input ALog file (uAlogParser must be pre-mexed and in the Matlab© path).
laserStream LMS_LASER_2D_LEFT Required: Laser stream to extract from ALog.
startTime 1225719873.50 Required: Start time of interest (see Events for examples).
endTime 1225719877.00 Required: End time of interest (see Events for examples).
useGlobalTime true Optional: Boolean to indicate if the supplied times are relative to global time (true) or the start of the ALog (false or not present).
-When useALog=false (load from ASCII text files):
odomTxtFile QuadTree_Odom.txt Required: Full or relative path (depending on useGlobalTime) for input ASCII text Odometry file, such as those produced by uAlogParser, and available for download above.
laserTxtFile QuadTree_Laser.txt Required: Full or relative path (depending on useGlobalTime) for input ASCII text Laser file, such as those produced by uAlogParser, and available for download above.

outputStruct

This Matlab© structure contains all the information the code requires in order to save data to either plain text or X3D XML format in the following fields:

FieldName Simple Example Description
outputFileName ptsWithRefl.txt Optional: Output filename. If none supplied no output file will be generated.
colourMap colormap(‘jet’) Optional: To generate colours from the reflectance stream a colour mapping is required (see the code and Matlab© help for examples). If none is supplied no colours or output will be generated.
colourEncodingSelect 2 Optional: see below. If none supplied the default encoding is 1.
XML false Optional: Boolean to switch between generating an XML file compatible with VRML and its predecessor X3D (true), and plain ASCII text as determined by byteRGB (false or not present).
-If XML=false to indicate if ASCII text file should have a byte RGB format:
byteRGB true Optional: Boolean to switch between generating integers colour channels (in the range 0 – 255) (true) and colours that range 0 – 1 in 4 decimal places (false or not present). Only applicable if not generating XML.

colourEncodingSelect permits two options:

1 – True colour mapping with no attempt to use the supplied colour map spectrum evenly.

2 – Clips the top 0.1% reflectances to the same maximum value to allow a heavier use of the supplied colour map spectrum.

Full Example

To run

  inputStruct  = struct('useALog',              true, ...
                        'ALogFile',             'QuadTree_Alog.alog', ...
                        'laserStream',          'LMS_LASER_2D_LEFT', ...
                        'startTime',            61.85, ...
                        'endTime',              65.35, ...
                        'useGlobalTime',        false);

  outputStruct = struct('outputFileName',       'ptsWithRefl.x3d',...
                        'colourEncodingSelect', 1, ...
                        'colourMap',            [0 0 0; 1 1 1], ...
                        'XML',                  true);

  verbosity    = 3;

  generatePointCloudFromALog(inputStruct, outputStruct, verbosity);

Outputs

The code will invoke uAlogParser on the downloaded ALog file, extract and display both Odometry and Laser data from the ALog in Matlab©, project the laser points into 3D, apply a grayscale colour mapping to the reflectance points, then output an X3D XML file. Viewing the X3D point cloud requires a X3D viewer; FreeWrl is available for Windows, Linux, macOS and Android.