@@ -203,7 +203,6 @@ class DistortionCorrectorTest : public ::testing::Test
203
203
pointcloud_msg.width = 0 ;
204
204
pointcloud_msg.row_step = 0 ;
205
205
}
206
-
207
206
return pointcloud_msg;
208
207
}
209
208
@@ -216,10 +215,7 @@ class DistortionCorrectorTest : public ::testing::Test
216
215
for (size_t i = 0 ; i < number_of_points; ++i) {
217
216
double timestamp = point_stamp.seconds ();
218
217
timestamps.push_back (timestamp);
219
- if (i > 0 ) {
220
- point_stamp = point_stamp + rclcpp::Duration::from_seconds (
221
- 0.001 ); // Assuming 1ms offset for demonstration
222
- }
218
+ point_stamp = addMilliseconds (point_stamp, 10 );
223
219
}
224
220
}
225
221
return timestamps;
@@ -231,7 +227,7 @@ class DistortionCorrectorTest : public ::testing::Test
231
227
std::shared_ptr<tf2_ros::StaticTransformBroadcaster> tf_broadcaster_;
232
228
233
229
static constexpr double standard_tolerance = 1e-4 ;
234
- static constexpr double coarse_tolerance = 1e -3 ;
230
+ static constexpr double coarse_tolerance = 5e -3 ;
235
231
236
232
// for debugging or regenerating the ground truth point cloud
237
233
bool debug = false ;
@@ -303,7 +299,7 @@ TEST_F(DistortionCorrectorTest, TestSetPointCloudTransformWithMissingFrame)
303
299
304
300
TEST_F (DistortionCorrectorTest, TestUndistortPointCloudWithEmptyTwist)
305
301
{
306
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
302
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
307
303
// Generate the point cloud message
308
304
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , false , timestamp);
309
305
@@ -340,7 +336,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloudWithEmptyTwist)
340
336
341
337
TEST_F (DistortionCorrectorTest, TestUndistortPointCloudWithEmptyPointCloud)
342
338
{
343
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
339
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
344
340
// Generate and process multiple twist messages
345
341
auto twist_msgs = generateTwistMsgs (timestamp);
346
342
for (const auto & twist_msg : twist_msgs) {
@@ -361,7 +357,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloudWithEmptyPointCloud)
361
357
TEST_F (DistortionCorrectorTest, TestUndistortPointCloud2dWithoutImuInBaseLink)
362
358
{
363
359
// Generate the point cloud message
364
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
360
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
365
361
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , false , timestamp);
366
362
367
363
// Generate and process multiple twist messages
@@ -381,10 +377,10 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud2dWithoutImuInBaseLink)
381
377
382
378
// Expected undistorted point cloud values
383
379
std::vector<std::array<float , 3 >> expected_pointcloud = {
384
- {10 .0f , 0 .0f , 0 .0f }, {0 .0f , 10 .0f , 0 .0f }, {0 .012002f , 5 .75338e- 07f , 10 .0f },
385
- {20 .024f , 0 .00191863f , 0 .0f }, {0 .0340828f , 20 .0f , 0 .0f }, {0 .0479994f , 4 .02654e- 06f , 20 .0f },
386
- {30 .06f , 0 .00575818f , 0 .0f }, {0 .0662481f , 30 .0f , 0 .0f }, {0 . 0839996f , 1 .03542e- 05f , 30 .0f },
387
- {10 . 0931f , 10 .0029f , 10 .0f },
380
+ {10 .0f , 0 .0f , 0 .0f }, {0 .117124f , 10 .0f , 0 .0f }, {0 .26f , 0 . 000135182f , 10 .0f },
381
+ {20 .4f , 0 .0213818f , 0 .0f }, {0 .50932f , 20 .0005f , 0 .0f }, {0 .699999f , 0 . 000819721f , 20 .0f },
382
+ {30 .8599f , 0 .076f , 0 .0f }, {0 .947959f , 30 .0016f , 0 .0f }, {1 . 22f , 0 . 00244382f , 30 .0f },
383
+ {11 . 3568f , 10 .0463f , 10 .0f },
388
384
};
389
385
390
386
// Verify each point in the undistorted point cloud
@@ -407,7 +403,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud2dWithoutImuInBaseLink)
407
403
TEST_F (DistortionCorrectorTest, TestUndistortPointCloud2dWithImuInBaseLink)
408
404
{
409
405
// Generate the point cloud message
410
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
406
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
411
407
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , false , timestamp);
412
408
413
409
// Generate and process multiple twist messages
@@ -432,10 +428,10 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud2dWithImuInBaseLink)
432
428
433
429
// Expected undistorted point cloud values
434
430
std::vector<std::array<float , 3 >> expected_pointcloud = {
435
- {10 .0f , 0 .0f , 0 .0f }, {0 .0f , 10 . 0f , 0 .0f }, {0 .0119991f , 5 .75201e- 07f , 10 .0f },
436
- {20 .024f , 0 . 0019192f , 0 .0f }, {0 .0321653f , 20 . 0f , 0 .0f }, {0 .0479994f , 6 .32762e- 06f , 20 .0f },
437
- {30 .06f , 0 . 00863842f , 0 .0f }, { 0 . 063369f , 30 . 0f , 0 .0f }, { 0 . 0839996f , 1 .84079e- 05f , 30 .0f },
438
- {10 . 0912f , 10 . 0048f , 10 .0f },
431
+ {10 .0f , 0 .0f , 0 .0f }, {0 .122876f , 9 . 99996f , 0 .0f }, {0 .26f , - 0 . 000115049f , 10 .0f },
432
+ {20 .4f , - 0 . 0174931f , 0 .0f }, {0 .56301f , 19 . 9996f , 0 .0f }, {0 .7f , - 0 . 000627014f , 20 .0f },
433
+ {30 .86f , - 0 . 052675f , 0 .0f }, { 1 . 1004f , 29 . 9987f , 0 .0f }, { 1 . 22f , - 0 . 00166245f , 30 .0f },
434
+ {11 . 4249f , 9 . 97293f , 10 .0f },
439
435
};
440
436
441
437
// Verify each point in the undistorted point cloud
@@ -458,7 +454,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud2dWithImuInBaseLink)
458
454
TEST_F (DistortionCorrectorTest, TestUndistortPointCloud2dWithImuInLidarFrame)
459
455
{
460
456
// Generate the point cloud message
461
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
457
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
462
458
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , true , timestamp);
463
459
464
460
// Generate and process multiple twist messages
@@ -483,11 +479,11 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud2dWithImuInLidarFrame)
483
479
484
480
// Expected undistorted point cloud values
485
481
std::vector<std::array<float , 3 >> expected_pointcloud = {
486
- {10 .0f , -1 .77636e-15f , -4 .44089e-16f }, {- 2 .66454e- 15f , 10 .0f , - 8 .88178e- 16f },
487
- {0 .00622853f , 0 .00600991f , 10 .0084f }, {20 .0106f , 0 .010948f , 0 .0157355f },
488
- {0 .0176543f , 20 .0176f , 0 .0248379f }, {0 .024499f , 0 .0245179f , 20 .0348f },
489
- {30 .0266f , 0 .0255826f , 0 .0357166f }, {0 .0355204f , 30 .0353f , 0 .0500275f },
490
- {0 .047132f , 0 .0439795f , 30 .0606f }, {10 .0488f , 10 .046f , 10 . 0636f },
482
+ {10 .0f , -1 .77636e-15f , -4 .44089e-16f }, {0 . 049989f , 10 .0608f , 0 . 0924992f },
483
+ {0 .106107f , 0 .130237f , 10 .1986f }, {20 .1709f , 0 .210011f , 0 .32034f },
484
+ {0 .220674f , 20 .2734f , 0 .417974f }, {0 .274146f , 0 .347043f , 20 .5341f },
485
+ {30 .3673f , 0 .457564f , 0 .700818f }, {0 .418014f , 30 .5259f , 0 .807963f },
486
+ {0 .464088f , 0 .600081f , 30 .9292f }, {10 .5657f , 10 .7121f , 11 . 094f },
491
487
};
492
488
493
489
// Verify each point in the undistorted point cloud
@@ -510,7 +506,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud2dWithImuInLidarFrame)
510
506
TEST_F (DistortionCorrectorTest, TestUndistortPointCloud3dWithoutImuInBaseLink)
511
507
{
512
508
// Generate the point cloud message
513
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
509
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
514
510
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , false , timestamp);
515
511
516
512
// Generate and process multiple twist messages
@@ -530,10 +526,10 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud3dWithoutImuInBaseLink)
530
526
531
527
// Expected undistorted point cloud values
532
528
std::vector<std::array<float , 3 >> expected_pointcloud = {
533
- {10 .0f , 0 .0f , 0 .0f }, {0 .0f , 10 .0f , 0 .0f }, {0 .0119991f , 0 . 0f , 10 .0f },
534
- {20 .024f , 0 .00120042f , 0 .0f }, {0 .0342002f , 20 .0f , 0 .0f }, {0 .0479994f , 2 .15994e- 06f , 20 .0f },
535
- {30 .06f , 0 .00450349f , 0 .0f }, {0 .0666005f , 30 .0f , 0 .0f }, {0 . 0839996f , 7 .55993e- 06f , 30 .0f },
536
- {10 . 0936f , 10 .0024f , 10 .0f },
529
+ {10 .0f , 0 .0f , 0 .0f }, {0 .117f , 10 .0f , 0 .0f }, {0 .26f , 9 .27035e- 05f , 10 .0f },
530
+ {20 .4f , 0 .0222176f , 0 .0f }, {0 .51f , 20 .0004f , 0 .0f }, {0 .7f , 0 . 000706573f , 20 .0f },
531
+ {30 .8599f , 0 .0760946f , 0 .0f }, {0 .946998f , 30 .0015f , 0 .0f }, {1 . 22f , 0 . 00234201f , 30 .0f },
532
+ {11 . 3569f , 10 .046f , 10 .0f },
537
533
};
538
534
539
535
// Verify each point in the undistorted point cloud
@@ -556,7 +552,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud3dWithoutImuInBaseLink)
556
552
TEST_F (DistortionCorrectorTest, TestUndistortPointCloud3dWithImuInBaseLink)
557
553
{
558
554
// Generate the point cloud message
559
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
555
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
560
556
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , false , timestamp);
561
557
562
558
// Generate and process multiple twist messages
@@ -582,15 +578,15 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud3dWithImuInBaseLink)
582
578
// Expected undistorted point cloud values
583
579
std::vector<std::array<float , 3 >> expected_pointcloud = {
584
580
{10 .0f , 0 .0f , 0 .0f },
585
- {0 .0f , 10 . 0f , 0 .0f },
586
- {0 .0118491f , -0 .000149993f , 10 . 0f },
587
- {20 .024f , 0 . 00220075f , 0 . 000600241f },
588
- {0 .0327002f , 20 . 0f , 0 .000900472f },
589
- {0 .0468023f , -0 .00119623f , 20 . 0f },
590
- {30 .06f , 0 . 0082567f , 0 . 00225216f },
591
- {0 . 0621003f , 30 . 0f , 0 .00270227f },
592
- {0 . 0808503f , -0 .00313673f , 30 . 0f },
593
- {10 . 0904f , 10 . 0032f , 10 .0024f },
581
+ {0 .123015f , 9 . 99998f , 0 .00430552f },
582
+ {0 .266103f , -0 .00895269f , 9 . 99992f },
583
+ {20 .4f , - 0 . 0176539f , - 0 . 0193392f },
584
+ {0 .563265f , 19 . 9997f , 0 .035628f },
585
+ {0 .734597f , -0 .046068f , 19 . 9993f },
586
+ {30 .8599f , - 0 . 0517931f , - 0 . 0658165f },
587
+ {1 . 0995f , 29 . 9989f , 0 .0956997f },
588
+ {1 . 31283f , -0 .113544f , 29 . 9977f },
589
+ {11 . 461f , 9 . 93096f , 10 .0035f },
594
590
};
595
591
596
592
// Verify each point in the undistorted point cloud
@@ -613,7 +609,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud3dWithImuInBaseLink)
613
609
TEST_F (DistortionCorrectorTest, TestUndistortPointCloud3dWithImuInLidarFrame)
614
610
{
615
611
// Generate the point cloud message
616
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
612
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
617
613
sensor_msgs::msg::PointCloud2 pointcloud = generatePointCloudMsg (true , true , timestamp);
618
614
619
615
// Generate and process multiple twist messages
@@ -639,15 +635,15 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud3dWithImuInLidarFrame)
639
635
// Expected undistorted point cloud values
640
636
std::vector<std::array<float , 3 >> expected_pointcloud = {
641
637
{10 .0f , 0 .0f , 0 .0f },
642
- {- 4 .76837e- 07f , 10 .0f , 4 .76837e- 07f },
643
- {0 .00572586f , 0 .00616837f , 10 .0086f },
644
- {20 .0103f , 0 .0117249f , 0 .0149349f },
645
- {0 .0158343f , 20 .0179f , 0 .024497f },
646
- {0 .0251098f , 0 .0254798f , 20 .0343f },
647
- {30 .0259f , 0 .0290527f , 0 .034577f },
648
- {0 .0319824f , 30 .0358f , 0 .0477753f },
649
- {0 .0478067f , 0 .0460052f , 30 .06f },
650
- {10 .0462f , 10 .0489f , 10 . 0625f },
638
+ {0 . 046484f , 10 .0622f , 0 . 098484f },
639
+ {0 .107595f , 0 .123767f , 10 .2026f },
640
+ {20 .1667f , 0 .22465f , 0 .313351f },
641
+ {0 .201149f , 20 .2784f , 0 .464665f },
642
+ {0 .290531f , 0 .303489f , 20 .5452f },
643
+ {30 .3598f , 0 .494116f , 0 .672914f },
644
+ {0 .375848f , 30 .5336f , 0 .933633f },
645
+ {0 .510001f , 0 .479651f , 30 .9493f },
646
+ {10 .5629f , 10 .6855f , 11 . 1461f },
651
647
};
652
648
653
649
// Verify each point in the undistorted point cloud
@@ -669,7 +665,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloud3dWithImuInLidarFrame)
669
665
670
666
TEST_F (DistortionCorrectorTest, TestUndistortPointCloudWithPureLinearMotion)
671
667
{
672
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
668
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
673
669
sensor_msgs::msg::PointCloud2 test2d_pointcloud = generatePointCloudMsg (true , false , timestamp);
674
670
sensor_msgs::msg::PointCloud2 test3d_pointcloud = generatePointCloudMsg (true , false , timestamp);
675
671
@@ -755,7 +751,7 @@ TEST_F(DistortionCorrectorTest, TestUndistortPointCloudWithPureLinearMotion)
755
751
756
752
TEST_F (DistortionCorrectorTest, TestUndistortPointCloudWithPureRotationalMotion)
757
753
{
758
- rclcpp::Time timestamp = node_-> get_clock ()-> now ( );
754
+ rclcpp::Time timestamp ( 10 , 100000000 , RCL_ROS_TIME );
759
755
sensor_msgs::msg::PointCloud2 test2d_pointcloud = generatePointCloudMsg (true , false , timestamp);
760
756
sensor_msgs::msg::PointCloud2 test3d_pointcloud = generatePointCloudMsg (true , false , timestamp);
761
757
0 commit comments