[Frontend] hydra code - src/frontend/frontend_module.cpp (updatePlaceMeshMapping)

About_work·2024년 10월 18일
0

lifelong scene graph

목록 보기
35/56
void FrontendModule::updatePlaceMeshMapping(const ReconstructionOutput& input) {
  const auto& places = dsg_->graph->getLayer(DsgLayers::PLACES);
  if (places.numNodes() == 0) {
    // avoid doing work by making the kdtree lookup if we don't have places
    return;
  }

  ScopedTimer timer("frontend/place_mesh_mapping", input.timestamp_ns, true, 1);
  CHECK(last_mesh_update_);
  CHECK(mesh_remapping_);

  // TODO(nathan) we can maybe put this somewhere else
  const auto num_active = last_mesh_update_->vertex_updates->size();
  std::vector<size_t> deformation_mapping(num_active,
                                          std::numeric_limits<size_t>::max());
  for (const auto& [block, indices] : *mesh_remapping_) {
    const auto block_iter = deformation_remapping_.find(block);
    if (block_iter == deformation_remapping_.end()) {
      LOG(WARNING) << "Missing block " << block.transpose() << " from graph mapping!";
      continue;
    }

    const auto& block_mapping = block_iter->second;
    for (const auto& [block_idx, mesh_idx] : indices) {
      const auto vertex_iter = block_mapping.find(block_idx);
      if (vertex_iter == block_mapping.end()) {
        continue;
      }

      const auto local_idx = last_mesh_update_->getLocalIndex(mesh_idx);
      CHECK_LT(local_idx, num_active);
      deformation_mapping[local_idx] = vertex_iter->second;
    }
  }

  PlaceMeshConnector connector(last_mesh_update_);
  const auto num_missing = connector.addConnections(places, deformation_mapping);

  VLOG_IF(1, num_missing > 0) << "[Frontend] " << num_missing
                              << " places missing basis points @ " << input.timestamp_ns
                              << " [ns]";
}

updatePlaceMeshMapping()

1. 핵심! 이것만 보면돼!

  • 장소(Place) 노드와 메쉬 데이터 간의 연결을 유지하고, 일치하지 않는 부분을 수정
  • 최근 메쉬 업데이트 정보기존의 메쉬-블록 매핑을 바탕으로 메쉬와 장소의 연속성을 유지
  • 일치하지 않는 메쉬 정보가 있는 경우 이를 탐지하고 경고 메시지를 남깁니다.
  • PlaceMeshConnector 객체를 생성하여,
    • 활성화된 장소(Place) 노드와 가까운 메쉬 포인트를 연결
    • 각 장소(place) 노드에 변형(deformation) 연결 정보레이블(semantics)을 할당
    • 연결되지 않은 노드를 카운트하여 누락된 연결 수를 반환

2. 로직 설명

(2) 필수 정보 확인

  • last_mesh_update_mesh_remapping_이 존재하는지 검사
    • 이들은 메쉬와 블록 간의 매핑 정보를 포함하는데, 이 정보가 없다면 작업을 수행할 수 없습니다.

(3) 메쉬와 블록 매핑 준비

  • 이전 메쉬 업데이트 정보에서 활성화된 메쉬 노드의 개수를 가져옵니다.
  • 각 메쉬 노드의 매핑을 추적하기 위해 기본 값으로 초기화된 매핑 배열(deformation_mapping)을 준비합니다.
    • 초기 값: std::numeric_limits<size_t>::max()로 설정하여 아직 매핑되지 않은 노드를 나타냅니다.

(4) 블록과 메쉬의 매핑 처리

  • mesh_remapping_에 있는 블록과 메쉬 간의 매핑을 반복하며 각 블록이 올바르게 매핑되었는지 확인합니다.
    • 블록 매핑이 존재하지 않으면 경고 메시지를 출력합니다.
  • 메쉬 인덱스가 블록의 로컬 인덱스와 일치하는지 확인합니다.
    • 일치하는 경우, 메쉬 노드의 로컬 인덱스를 매핑 배열에 저장합니다.

(5) 메쉬와 장소 노드 연결

  • PlaceMeshConnector 객체를 생성하여,
    • 활성화된 장소(Place) 노드와 가까운 메쉬 포인트를 연결
    • 각 장소(place) 노드에 변형(deformation) 연결 정보레이블(semantics)을 할당
    • 연결되지 않은 노드를 카운트하여 누락된 연결 수를 반환
 PlaceMeshConnector connector(last_mesh_update_);
  const auto num_missing = connector.addConnections(places, deformation_mapping);
profile
새로운 것이 들어오면 이미 있는 것과 충돌을 시도하라.

0개의 댓글