// 根据参数配置,将一帧雷达数据分成几段, 再传入trajectory_builder_ voidSensorBridge::HandleLaserScan( const std::string& sensor_id, const carto::common::Time time, const std::string& frame_id, const carto::sensor::PointCloudWithIntensities& points){ if (points.points.empty()) { return; } // CHECK_LE: 小于等于 CHECK_LE(points.points.back().time, 0.f); // TODO(gaschler): Use per-point time instead of subdivisions.
// 意为一帧雷达数据被分成几次处理, 一般将这个参数设置为1 for (int i = 0; i != num_subdivisions_per_laser_scan_; ++i) { constsize_t start_index = points.points.size() * i / num_subdivisions_per_laser_scan_; constsize_t end_index = points.points.size() * (i + 1) / num_subdivisions_per_laser_scan_; // 生成分段的点云 carto::sensor::TimedPointCloud subdivision( points.points.begin() + start_index, points.points.begin() + end_index); if (start_index == end_index) { continue; } constdouble time_to_subdivision_end = subdivision.back().time; // `subdivision_time` is the end of the measurement so sensor::Collator will // send all other sensor data first. const carto::common::Time subdivision_time = time + carto::common::FromSeconds(time_to_subdivision_end); auto it = sensor_to_previous_subdivision_time_.find(sensor_id); if (it != sensor_to_previous_subdivision_time_.end() && // 上一段点云的时间不应该大于等于这一段点云的时间 it->second >= subdivision_time) { LOG(WARNING) << "Ignored subdivision of a LaserScan message from sensor " << sensor_id << " because previous subdivision time " << it->second << " is not before current subdivision time " << subdivision_time; continue; } // 更新对应sensor_id的时间戳 sensor_to_previous_subdivision_time_[sensor_id] = subdivision_time; // 检查点云的时间 for (auto& point : subdivision) { point.time -= time_to_subdivision_end; } CHECK_EQ(subdivision.back().time, 0.f); // 将分段后的点云 subdivision 传入 trajectory_builder_ HandleRangefinder(sensor_id, subdivision_time, frame_id, subdivision); } // for }
auto it = sensor_to_previous_subdivision_time_.find(sensor_id); if (it != sensor_to_previous_subdivision_time_.end() && // 上一段点云的时间不应该大于等于这一段点云的时间 it->second >= subdivision_time) { LOG(WARNING) << "Ignored subdivision of a LaserScan message from sensor " << sensor_id << " because previous subdivision time " << it->second << " is not before current subdivision time " << subdivision_time; continue; } // 更新对应sensor_id的时间戳 sensor_to_previous_subdivision_time_[sensor_id] = subdivision_time;
更新此分段点云中每一个点的时间,同样的需要做到此点云中最后一个点的时间为0
1 2 3 4
// 更新点云中点的时间 for (auto& point : subdivision) { point.time -= time_to_subdivision_end; }