updatePrivateDsg
메서드는 백엔드의 프라이빗 DSG를 최신 상태로 유지하기 위해 사용됩니다.force_update
플래그를 확인하여 업데이트가 필요한지 판단합니다.updatePrivateDsg
함수 및 관련 코드에 대한 상세 설명BackendModule
)에서 프라이빗 DSG(private Dynamic Scene Graph)를 업데이트하는 과정을 다루고 있습니다. force_update
와 타임스탬프 비교를 통해 불필요한 업데이트를 최소화업데이트 요청: 백엔드 모듈은 새로운 입력에 따라 프라이빗 DSG를 업데이트하려고 합니다.
업데이트 여부 판단:
updatePrivateDsg
함수를 호출하여 업데이트가 필요한지 판단합니다.동기화 및 안전한 업데이트:
불필요한 업데이트 방지:
force_update
플래그와 타임스탬프 비교를 통해 이미 최신 상태인 경우 업데이트를 생략합니다.if (!updatePrivateDsg(input.timestamp_ns, force_update))
조건문if (!updatePrivateDsg(input.timestamp_ns, force_update)) {
VLOG(2) << "Backend skipping input @ " << input.timestamp_ns << " [ns]";
// 조건이 만족되지 않으면 로그를 기록하고 함수 종료
logStatus();
return;
}
updatePrivateDsg
함수를 호출하여 프라이빗 DSG를 업데이트합니다.updatePrivateDsg
함수의 정의bool BackendModule::updatePrivateDsg(size_t timestamp_ns, bool force_update) {
std::unique_lock<std::mutex> graph_lock(private_dsg_->mutex);
{ // 공동 임계 영역 시작
ScopedTimer timer("backend/read_graph", timestamp_ns);
const auto& shared_dsg = *state_->backend_graph;
std::unique_lock<std::mutex> shared_graph_lock(shared_dsg.mutex);
if (!force_update && shared_dsg.last_update_time != timestamp_ns) {
return false;
}
unmerged_graph_->mergeGraph(*shared_dsg.graph);
} // 공동 임계 영역 종료
if (logs_) {
backend_graph_logger_.logGraph(private_dsg_->graph);
}
return true;
}
shared_dsg
)의 변경 사항을 프라이빗 DSG에 병합합니다.업데이트 필요 여부 확인
if (!force_update && shared_dsg.last_update_time != timestamp_ns) {
return false;
}
force_update
가 false
이고, 공유된 DSG의 마지막 업데이트 시간이 현재 타임스탬프와 다르면 업데이트를 수행하지 않습니다.그래프 병합
unmerged_graph_->mergeGraph(*shared_dsg.graph);
unmerged_graph_
에 병합하여 업데이트를 수행합니다.unmerged_graph_
는 병합되지 않은 그래프를 임시로 저장하는 역할을 합니다.