Skip to content

default invalid value is not sufficinet in Grid::Pos2Sub #19

Description

@fangyuedong

the code is

Eigen::Vector3i Pos2Sub(const Eigen::Vector3d& pos) const
{
      Eigen::Vector3i sub(0, 0, 0);
      for (int i = 0; i < dimension_; i++)
      {
          sub(i) = pos(i) - origin_(i) > -1e-7 ? static_cast<int>((pos(i) - origin_(i)) * resolution_inv_(i)) : -1;
      }
      return sub;
}

but sometimes the code do inflation as in ScanHandler::SetCurrentScanCloud, which makes invalid index become valid.

    Eigen::Vector3i c_sub = voxel_grids_->Pos2Sub(Eigen::Vector3d(point.x, point.y, point.z));
    for (int i = -L; i <= L; i++) {
        for (int j = -L; j <= L; j++) {
            for (int k = -N; k <= N; k++) {
                Eigen::Vector3i sub;
                sub.x() = c_sub.x() + i, sub.y() = c_sub.y() + j, sub.z() = c_sub.z() + k;
                if (voxel_grids_->InRange(sub)) {
                    const int ind = voxel_grids_->Sub2Ind(sub);
                    voxel_grids_->GetCell(ind) = voxel_grids_->GetCell(ind) | SCAN_BIT;
                }
            }
        }
    }

we should let sub(0..2)=-1000 to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions