structTrajectoryNode { // 记录了前端传来的 点云、重力方向、局部位姿等数据 structData { // 扫描数据被插入子图的时刻 common::Time time; // Transform to approximately gravity align the tracking frame as // determined by local SLAM. Eigen::Quaterniond gravity_alignment; // Used for loop closure in 2D: voxel filtered returns in the // 'gravity_alignment' frame. sensor::PointCloud filtered_gravity_aligned_point_cloud; // 省略用于3D建图时闭环检测的字段
// The node pose in the local SLAM frame. transform::Rigid3d local_pose; }; common::Time time()const{ return constant_data->time; } // 实际只有这两个成员 std::shared_ptr<const Data> constant_data; // The node pose in the global SLAM frame. transform::Rigid3d global_pose;
// 计算物理坐标点的像素索引 // 返回的这个点是栅格的中心点,因此,栅格点(grid_point)是一个格子的中心 Eigen::Array2i GetCellIndex(const Eigen::Vector2f& point)const { // Index values are row major and the top left has Eigen::Array2i::Zero() // and contains (centered_max_x, centered_max_y). We need to flip and // rotate. return Eigen::Array2i( common::RoundToInt((max_.y() - point.y()) / resolution_ - 0.5), common::RoundToInt((max_.x() - point.x()) / resolution_ - 0.5)); }
voidProbabilityGridRangeDataInserter2D::Insert( const sensor::RangeData& range_data, GridInterface* const grid)const { ProbabilityGrid* const probability_grid = static_cast<ProbabilityGrid*>(grid); CHECK(probability_grid != nullptr); // By not finishing the update after hits are inserted, we give hits priority // (i.e. no hits will be ignored because of a miss in the same cell). CastRays(range_data, hit_table_, miss_table_, options_.insert_free_space(), probability_grid); probability_grid->FinishUpdate(); }