11#include " mapOptimization/mapOptimization.hpp"
22
3- void mapOptimization::pointAssociateToMap (PointType const * const pi, PointType * const po)
4- {
5- po->x = transPointAssociateToMap (0 ,0 ) * pi->x + transPointAssociateToMap (0 ,1 ) * pi->y + transPointAssociateToMap (0 ,2 ) * pi->z + transPointAssociateToMap (0 ,3 );
6- po->y = transPointAssociateToMap (1 ,0 ) * pi->x + transPointAssociateToMap (1 ,1 ) * pi->y + transPointAssociateToMap (1 ,2 ) * pi->z + transPointAssociateToMap (1 ,3 );
7- po->z = transPointAssociateToMap (2 ,0 ) * pi->x + transPointAssociateToMap (2 ,1 ) * pi->y + transPointAssociateToMap (2 ,2 ) * pi->z + transPointAssociateToMap (2 ,3 );
8- po->intensity = pi->intensity ;
9- }
103
114pcl::PointCloud<PointType>::Ptr mapOptimization::transformPointCloud (pcl::PointCloud<PointType>::Ptr cloudIn, PointTypePose* transformIn)
125{
@@ -114,7 +107,8 @@ Eigen::Affine3f mapOptimization::affineFromTf(const tf2::Transform &transform) c
114107void mapOptimization::updatePath (const PointTypePose& pose_in)
115108{
116109 geometry_msgs::msg::PoseStamped pose_stamped;
117- rclcpp::Time t (static_cast <uint32_t >(pose_in.time * 1e9 ));
110+ rclcpp::Time t (static_cast <int64_t >(pose_in.time * 1e9 ));
111+
118112 pose_stamped.header .stamp = t;
119113 pose_stamped.header .frame_id = mapFrameLocal;
120114 pose_stamped.pose .position .x = pose_in.x ;
@@ -403,9 +397,9 @@ void mapOptimization::publishFrames()
403397 pcl::PointCloud<PointType>::Ptr transformedInput = transformPointCloud (laserCloudSurfLastDS, &thisPose6D);
404398 pcl::PointCloud<pcl::PointXYZRGB>::Ptr coloredCloud (new pcl::PointCloud<pcl::PointXYZRGB>());
405399
406- const int codeBound = laserCloudSurfLastDSNum < static_cast <int >(laserCloudSurfDebugCode.size ())
400+ const int codeBound = laserCloudSurfLastDSNum < static_cast <int >(scanAligner-> laserCloudSurfDebugCode .size ())
407401 ? laserCloudSurfLastDSNum
408- : static_cast <int >(laserCloudSurfDebugCode.size ());
402+ : static_cast <int >(scanAligner-> laserCloudSurfDebugCode .size ());
409403 const int pointBound = codeBound < static_cast <int >(transformedInput->size ())
410404 ? codeBound
411405 : static_cast <int >(transformedInput->size ());
@@ -418,21 +412,21 @@ void mapOptimization::publishFrames()
418412 point.y = transformedInput->points [i].y ;
419413 point.z = transformedInput->points [i].z ;
420414
421- switch (laserCloudSurfDebugCode[i])
415+ switch (scanAligner-> laserCloudSurfDebugCode [i])
422416 {
423- case SURF_DEBUG_ACCEPTED:
417+ case ScanAligner:: SURF_DEBUG_ACCEPTED:
424418 point.r = 0 ; point.g = 255 ; point.b = 0 ; // green
425419 break ;
426- case SURF_DEBUG_REJECTED_NEIGHBOR_COUNT:
420+ case ScanAligner:: SURF_DEBUG_REJECTED_NEIGHBOR_COUNT:
427421 point.r = 255 ; point.g = 0 ; point.b = 0 ; // red
428422 break ;
429- case SURF_DEBUG_REJECTED_KNN_DISTANCE:
423+ case ScanAligner:: SURF_DEBUG_REJECTED_KNN_DISTANCE:
430424 point.r = 255 ; point.g = 165 ; point.b = 0 ; // orange
431425 break ;
432- case SURF_DEBUG_REJECTED_PLANE_INVALID:
426+ case ScanAligner:: SURF_DEBUG_REJECTED_PLANE_INVALID:
433427 point.r = 255 ; point.g = 255 ; point.b = 0 ; // yellow
434428 break ;
435- case SURF_DEBUG_REJECTED_LOW_WEIGHT:
429+ case ScanAligner:: SURF_DEBUG_REJECTED_LOW_WEIGHT:
436430 point.r = 255 ; point.g = 0 ; point.b = 255 ; // magenta
437431 break ;
438432 default :
@@ -473,7 +467,7 @@ void mapOptimization::publishFrames()
473467 if (pubMatchedSurfFeatures->get_subscription_count () != 0 )
474468 {
475469 pcl::PointCloud<PointType>::Ptr cloudOut (new pcl::PointCloud<PointType>());
476- *cloudOut += *transformPointCloud (laserCloudOri , &thisPose6D);
470+ *cloudOut += *transformPointCloud (scanAligner-> getLaserCloudOri () , &thisPose6D);
477471 publishCloud (pubMatchedSurfFeatures, cloudOut, timeLaserInfoStamp, mapFrameLocal);
478472 }
479473 // publish registered high-res raw cloud
@@ -492,24 +486,6 @@ void mapOptimization::publishFrames()
492486 globalPath.header .frame_id = mapFrameLocal;
493487 pubPath->publish (globalPath);
494488 }
495- // publish SLAM infomation for 3rd-party usage
496- if (pubSLAMInfo->get_subscription_count () != 0 )
497- {
498- // if (lastSLAMInfoPubSize != cloudKeyPoses6D->size())
499- // {
500- // liorf::msg::CloudInfo slamInfo;
501- // slamInfo.header.stamp = timeLaserInfoStamp;
502- // pcl::PointCloud<PointType>::Ptr cloudOut(new pcl::PointCloud<PointType>());
503- // *cloudOut += *laserCloudSurfLastDS;
504- // slamInfo.key_frame_cloud = publishCloud(rclcpp::Publisher(), cloudOut, timeLaserInfoStamp, lidarFrame);
505- // slamInfo.key_frame_poses = publishCloud(rclcpp::Publisher(), cloudKeyPoses6D, timeLaserInfoStamp, odometryFrame);
506- // pcl::PointCloud<PointType>::Ptr localMapOut(new pcl::PointCloud<PointType>());
507- // *localMapOut += *laserCloudSurfFromMapDS;
508- // slamInfo.key_frame_map = publishCloud(rclcpp::Publisher(), localMapOut, timeLaserInfoStamp, odometryFrame);
509- // pubSLAMInfo->publish(slamInfo);
510- // lastSLAMInfoPubSize = cloudKeyPoses6D->size();
511- // }
512- }
513489}
514490
515491
0 commit comments