hku-mars / FAST_LIO

A computationally efficient and robust LiDAR-inertial odometry (LIO) package
GNU General Public License v2.0
2.74k stars 922 forks source link

I need help for Fast_lio2 compatible with PandarXT32. #360

Open hzm789 opened 4 weeks ago

hzm789 commented 4 weeks ago

This is my code, i dont know what is wrong void Preprocess::pandar_handler(const sensor_msgs::PointCloud2::ConstPtr &msg) { pl_surf.clear(); pl_corn.clear(); pl_full.clear(); pcl::PointCloud pl_orig; pcl::fromROSMsg(*msg, pl_orig); // 将 ROS 点云消息转换为 PCL 格式 int plsize = pl_orig.points.size(); pl_surf.reserve(plsize); // 为输出点云预留空间

while (pl_orig.points[plsize - 1].timestamp - pl_orig.points[0].timestamp >= 0.1) { plsize--; pl_orig.points.pop_back(); }

auto time_list_pandar = [&](pandar_ros::Point &point_1, pandar_ros::Point &point_2) { return (point_1.timestamp < point_2.timestamp); }; std::sort(pl_orig.points.begin(), pl_orig.points.end(), time_list_pandar);

double time_head = pl_orig.points[0].timestamp;

for(int i=0; i<plsize; i++) { if (!(std::isfinite(pl_orig.points[i].x) && std::isfinite(pl_orig.points[i].y) && std::isfinite(pl_orig.points[i].z))) continue;

PointType added_pt;
added_pt.normal_x = 0;
added_pt.normal_y = 0;
added_pt.normal_z = 0;
added_pt.x = pl_orig.points[i].x;
added_pt.y = pl_orig.points[i].y;
added_pt.z = pl_orig.points[i].z;

added_pt.intensity = pl_orig.points[i].intensity;
added_pt.curvature = (pl_orig.points[i].timestamp - time_head) * time_unit_scale;

if(i % point_filter_num == 0)
{
  if(added_pt.x*added_pt.x + added_pt.y*added_pt.y + added_pt.z*added_pt.z > blind * blind)
  {
    pl_surf.points.push_back(added_pt);
  }
}

} }

stale[bot] commented 4 days ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.