hydra code - src/utils/pgmo_mesh_interface.cpp

About_work·2024년 10월 16일
0

lifelong scene graph

목록 보기
18/56

1. 코드 설명

  • 이 코드는 Hydra 프로젝트에서 사용하는 메쉬 인터페이스로, PgmoMeshLayerInterfacePgmoMeshInterface 클래스를 정의
  • 이 두 클래스는 Kimera-PGMO에서 메쉬 데이터를 처리하기 위한 인터페이스를 구현 - 이 인터페이스는 메쉬 데이터에 접근하고, 활성화된 메쉬 블록 내의 버텍스 좌표와 색상 등의 정보를 Kimera-PGMO에서 사용할 수 있게 제공

종합 설명

  • PgmoMeshLayerInterface메쉬 레이어(여러 블록으로 구성된 메쉬)를 다루며,
  • PgmoMeshInterface단일 메쉬를 다룹니다.
  • 이를 통해, Kimera-PGMO 시스템은 메쉬 데이터에 버텍스, 색상, 레이블 정보에 쉽게 접근할 수 있게 됩니다.

PgmoMeshLayerInterface

  • 이 클래스는 MeshLayer라는 객체와 상호작용하며, 주로 여러 블록으로 구성된 메쉬 데이터를 처리

1. 생성자 및 초기화

PgmoMeshLayerInterface::PgmoMeshLayerInterface(const MeshLayer& mesh) : mesh_(mesh) {
  block_indices_ = mesh.allocatedBlockIndices();
}
  • 생성자MeshLayer 객체를 입력으로 받아, 이를 mesh_로 저장하고, 메쉬 레이어 내에 할당된 블록들의 인덱스(blockindices)를 초기화합니다.

2. blockIndices()

const BlockIndices& PgmoMeshLayerInterface::blockIndices() const {
  return block_indices_;
}
  • 메쉬 블록들의 인덱스를 반환하는 함수입니다. 이는 메쉬 레이어에서 어떤 블록들이 할당되어 있는지를 알려줍니다.

3. markBlockActive()

void PgmoMeshLayerInterface::markBlockActive(const BlockIndex& block) const {
  active_mesh_ = mesh_.getBlockPtr(block);
}
  • 이 함수는 특정 블록을 활성화시킵니다. 즉, 활성화할 블록을 지정하여 active_mesh_에 해당 블록 데이터를 저장합니다. 이후 다른 메소드에서 활성화된 블록을 기반으로 데이터를 가져옵니다.

4. activeBlockSize()

size_t PgmoMeshLayerInterface::activeBlockSize() const {
  return active_mesh_->points.size();
}
  • 활성화된 블록 내의 버텍스(point)의 개수를 반환합니다.

5. getActiveVertex()

pcl::PointXYZRGBA PgmoMeshLayerInterface::getActiveVertex(size_t index) const {
  const auto& pos = active_mesh_->points[index];
  const auto& color = active_mesh_->colors[index];
  ...
}
  • 활성화된 블록 내에서 index에 해당하는 버텍스좌표(pos)색상(color) 정보를 pcl::PointXYZRGBA 형식으로 반환합니다.

6. getActiveSemantics()

std::optional<uint32_t> PgmoMeshLayerInterface::getActiveSemantics(size_t index) const {
  if (index < active_mesh_->labels.size()) {
    return active_mesh_->labels[index];
  }
  return std::nullopt;
}
  • 활성화된 블록 내에서 해당 인덱스의 의미론적 레이블(semantic label)이 있으면 반환하고, 없으면 std::nullopt을 반환합니다.

7. hasSemantics()

bool PgmoMeshLayerInterface::hasSemantics() const {
  return mesh_.begin()->has_labels;
}
  • 이 함수는 메쉬 레이어의미론적 레이블을 가지고 있는지 여부를 확인합니다. 첫 번째 블록을 확인하여, 해당 블록이 레이블 정보를 포함하고 있는지를 판단합니다.

8. clone()

kimera_pgmo::MeshInterface::Ptr PgmoMeshLayerInterface::clone() const {
  return std::make_shared<PgmoMeshLayerInterface>(*this);
}
  • 이 함수는 인터페이스 객체의 복제본을 반환합니다. 이를 통해, 동일한 메쉬 데이터를 여러 곳에서 사용할 수 있습니다.

PgmoMeshInterface

단일 메쉬와 상호작용하는 인터페이스로, 위의 PgmoMeshLayerInterface와 유사한 역할을 합니다. 다만, 블록 단위의 메쉬 레이어가 아닌 단일 메쉬 객체를 다루는 데 사용

1. 생성자 및 초기화

PgmoMeshInterface::PgmoMeshInterface(const Mesh& mesh) : mesh_(mesh) {
  block_indices_ = {BlockIndex(0, 0, 0)};
}
  • Mesh 객체를 입력으로 받아, 이를 mesh_로 저장합니다. 이 경우, 단일 메쉬이므로 하나의 블록만 사용합니다.

2. blockIndices()

const BlockIndices& PgmoMeshInterface::blockIndices() const { return block_indices_; }
  • 단일 블록 인덱스를 반환합니다.

3. activeBlockSize()

size_t PgmoMeshInterface::activeBlockSize() const {
  return mesh_.numVertices();
}
  • 단일 메쉬에서 버텍스의 개수를 반환합니다.

4. getActiveVertex()

pcl::PointXYZRGBA PgmoMeshInterface::getActiveVertex(size_t index) const {
  const auto& pos = mesh_.pos(index);
  const auto& color = mesh_.color(index);
  ...
}
  • 단일 메쉬에서 index에 해당하는 버텍스의 좌표(pos)와 색상(color) 정보를 pcl::PointXYZRGBA 형식으로 반환합니다.

5. getActiveSemantics()

std::optional<uint32_t> PgmoMeshInterface::getActiveSemantics(size_t index) const {
  if (index < mesh_.labels.size()) {
    return mesh_.label(index);
  }
  return std::nullopt;
}
  • 단일 메쉬에서 해당 인덱스의 의미론적 레이블(semantic label)이 존재하면 반환하고, 없으면 std::nullopt을 반환합니다.

6. hasSemantics()

bool PgmoMeshInterface::hasSemantics() const { return mesh_.has_labels; }
  • 메쉬의미론적 레이블을 가지고 있는지 여부를 반환합니다.

7. clone()

kimera_pgmo::MeshInterface::Ptr PgmoMeshInterface::clone() const {
  return std::make_shared<PgmoMeshInterface>(*this);
}
  • 인터페이스 객체의 복제본을 반환합니다.

profile
새로운 것이 들어오면 이미 있는 것과 충돌을 시도하라.

0개의 댓글