#ifndef DESKEW_POINT_CLOUD_H #define DESKEW_POINT_CLOUD_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct PointXYZIRT { PCL_ADD_POINT4D PCL_ADD_INTENSITY; double time; uint16_t ring; EIGEN_MAKE_ALIGNED_OPERATOR_NEW } EIGEN_ALIGN16; POINT_CLOUD_REGISTER_POINT_STRUCT (PointXYZIRT, (float, x, x) (float, y, y) (float, z, z) (float, intensity, intensity) (double , time, time) (uint16_t, ring, ring) ) class DeskewPointCloud { public: explicit DeskewPointCloud(ros::NodeHandle &iNh,ros::NodeHandle &iNhPrivate); ~DeskewPointCloud(); private: float m_fVoxelLeafSize_; const int m_iQueueLength = 100; std::mutex imuLock; bool m_bFirstPointFlag_; bool m_bImuAvailable_; bool m_bOdomAvailable_; bool m_bOdomDeskewFlag_; double m_dTimeScanCur_, m_dTimeScanEnd_; double m_dDistanceMax_,m_dDistanceMin_; int m_nImuPointerFront_; int m_nImuPointerLast_; int m_nImuPointerCur_; int m_nOdomPointerCur_; std::deque m_qImu; std::deque m_qOdom_; double *m_pImuTime_; double *m_pOdomTime_; double *m_pImuRotX_; double *m_pImuRotY_; double *m_pImuRotZ_; double *m_pOdomTansX_; double *odomTansY; int m_dScanRows_,m_dScanCols_; pcl::PointCloud::Ptr m_pPointCloudIn_; pcl::PointCloud::Ptr m_pPointCloudDeskew_; pcl::PointCloud::Ptr m_pPointCloudFilter_; cv::Mat m_iMatCloud_; cv::RNG m_iRng; std::mt19937 m_iGen; std::uniform_int_distribution dis; Eigen::Affine3f transStartInverse; ros::NodeHandle nh; ros::Subscriber m_iSubImu_; ros::Subscriber odom_sub; ros::Subscriber m_iSubPointCloud_; ros::Publisher m_iPubDeskewCloud_; ros::Publisher m_iPubFilterCloud_; ros::Publisher m_iPubFilterCloud2_; ros::Publisher m_iPubFilterCloud3_; ros::Publisher m_iPubCloudGrand_; ros::Publisher m_iPubCloudNoGrand_; double PointDistance(pcl::PointXYZI p); sensor_msgs::Imu __ImuConverter(const sensor_msgs::Imu& imu_in); void __ImuDataHandle(); void __OdomDataHandle(); bool __DataHandle(); void __FindRotation(double dPointTime, float *pRotXCur, float *pRotYCur, float *pRotZCur); void __FindPosition(double dPointTime, float *pPosXCur, float *pPosYCur, float *pPosZCur); pcl::PointXYZI __DeskewPoint(pcl::PointXYZI *pPoint, double dRelTime); void __ResetParameters(); void __ProjectPointCloud(const sensor_msgs::PointCloud2::ConstPtr ¤tCloudMsg); static void PublishCloud(ros::Publisher *pPubObject, pcl::PointCloud::Ptr pCloud, ros::Time iStamp, std::string cFrameName); void __OnCallbackImu(const sensor_msgs::Imu::ConstPtr &pMsgImu); void __OnCallbackOdom(const nav_msgs::Odometry::ConstPtr &pMsgOdom); void __OnCallbackLidarCloud(const sensor_msgs::PointCloud2::ConstPtr &pMsgLidarPintCloud); void VoxelGridFilter(const pcl::PointCloud::Ptr &pCloud, double time, std::string cFrameName); void __FilterPointCloud( const cv::Mat& mat, pcl::PointCloud::Ptr &cloud); double __PointDistance(pcl::PointXYZI p1, pcl::PointXYZI p2); void __CloudClustering(pcl::PointCloud::Ptr pCloudIn, pcl::PointCloud::Ptr pCloudOut); void __RanSac(pcl::PointCloud::Ptr pCloudIn, pcl::PointCloud::Ptr pCloudOutPlane, pcl::PointCloud::Ptr pCloudOutOther); }; #endif