0

I'm trying to read laser scan data and then use that for building a map of the environment.

My problem is, that I don't understand in what format the data has to be provided to the CObservation2DRangeScan object.

I've tried:

X,Y,X,Y,...
Y,X,Y,X,...
X,X,Y,Y,...
Y,Y,X,X,...

I write the data into a rawlog file and then look at it in the rawlog viewer. I used [1,1] and the point appears at X=-1 and Y=0. Why is that?

Here is the data from the rawlog viewer

Timestamp (UTC): 2016/06/21,07:22:42.166880
(as time_t): 1466493762.16688
(as TTimestamp): 131109673621668800
Sensor label: ''

Homogeneous matrix for the sensor's 3D pose, relative to robot base:
1.00000 0.00000 0.00000 0.00000
0.00000 1.00000 0.00000 0.00000
0.00000 0.00000 1.00000 0.00000
0.00000 0.00000 0.00000 1.00000(x,y,z,yaw,pitch,roll)
(0.0000,0.0000,0.0000,0.00deg,-0.00deg,0.00deg)
Samples direction: Right->Left
Points in the scan: 2
Estimated sensor 'sigma': 0.010000
Increment in pitch during the scan: 0.000000 deg
Invalid points in the scan: 0
Sensor maximum range: 80.00 m 
Sensor field-of-view ("aperture"): 360.0 deg
Raw scan values: [1.000 1.000 ]
Raw valid-scan values: [1 1 ]

Here is the code that I'm using:

CSensoryFrame SF;

CActionCollection actionCol;

CPose2D actualOdometryReading(0.0f, 0.0f, DEG2RAD(.0f));

// Prepare the "options" structure:
CActionRobotMovement2D                      actMov;
CActionRobotMovement2D::TMotionModelOptions opts;

opts.modelSelection = CActionRobotMovement2D::mmThrun;
opts.thrunModel.alfa3_trans_trans = 0.10f;

// Create the probability density distribution (PDF) from a 2D odometry reading:
actMov.computeFromOdometry(actualOdometryReading, opts);

actionCol.insert(actMov);

CObservation2DRangeScanPtr myObs = CObservation2DRangeScan::Create();


myObs->scan = scan; // = [1,0]
myObs->validRange = vranges; // = [1,1]
myObs->aperture = 2 * M_PI;


SF.insert(myObs);
mase
  • 1
  • 1

1 Answers1

0

I'm not fully familiar with the details of MRPT's laser data classes, but having used other robotics frameworks, I can tell you that laser scans are typically represented as a collection of range values, rather than Cartesian (x,y) coordinates. Indeed, the reference says that CObservation2DRangeScan holds

A vector of float values with all the range measurements (in meters).

And your program's output shows:

Raw scan values: [1.000 1.000 ]

i.e., two range measurements of 1m distance. Since your sensor is configured to have a 360-degree field of view, the first measurement will be in direction -180° of your sensor's pose. Your sensor is facing towards +X, so this laser ray aims "behind" the robot, which gives you the coordinates (−1, 0). The second (and last) measurement ray faces towards +180°, giving the same coordinates.

Try to pass in a list of 360 range measurements of 1 metre, and you should see something that corresponds to a circle.

mindriot
  • 5,413
  • 1
  • 25
  • 34
  • 1
    So then the question is how to use laser scan data in the form of points, instead of range measurements. – mase Jun 22 '16 at 21:13
  • 1
    You probably want to use something like [`CSimplePointsMap`](http://reference.mrpt.org/devel/classmrpt_1_1maps_1_1_c_simple_points_map.html). – mindriot Jun 23 '16 at 04:48