reloc: --slam-reloc-vpr -- camera (VPR TensorRT + PnP) ket hop LiDAR, chot khi hai nguon trung
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "vslam/rtabmap_slam.h"
|
||||
|
||||
#include <rtabmap/core/Memory.h>
|
||||
#include <rtabmap/core/Optimizer.h>
|
||||
#include <rtabmap/core/Parameters.h>
|
||||
#include <rtabmap/core/Rtabmap.h>
|
||||
#include <rtabmap/core/SensorData.h>
|
||||
#include <rtabmap/core/Statistics.h>
|
||||
#include <rtabmap/utilite/ULogger.h>
|
||||
|
||||
@@ -378,6 +380,48 @@ StatusResponse RtabmapSlam::ExportVoxels(const VoxelExportOptions& opt,
|
||||
return ExportVoxelGrid(impl_->rtabmap, opt, &impl_->voxel_cache, out);
|
||||
}
|
||||
|
||||
namespace {
|
||||
cv::Matx44d ToMatx44(const rtabmap::Transform& t) {
|
||||
return cv::Matx44d(t.r11(), t.r12(), t.r13(), t.x(), t.r21(), t.r22(), t.r23(), t.y(),
|
||||
t.r31(), t.r32(), t.r33(), t.z(), 0, 0, 0, 1);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<int> RtabmapSlam::MapNodeIds() const {
|
||||
std::vector<int> out;
|
||||
if (!impl_->inited) return out;
|
||||
for (const auto& kv : impl_->rtabmap.getLocalOptimizedPoses()) out.push_back(kv.first);
|
||||
return out;
|
||||
}
|
||||
|
||||
StatusResponse RtabmapSlam::GetNodeView(int id, bool with_depth, NodeView* out) {
|
||||
if (!impl_->inited) {
|
||||
return StatusResponse::Error(StatusCode::kFailedPrecondition, "chua init");
|
||||
}
|
||||
const std::map<int, rtabmap::Transform>& poses = impl_->rtabmap.getLocalOptimizedPoses();
|
||||
const auto it = poses.find(id);
|
||||
if (it == poses.end() || it->second.isNull()) {
|
||||
return StatusResponse::Error(StatusCode::kNotFound, "node khong co pose toi uu");
|
||||
}
|
||||
const rtabmap::Memory* mem = impl_->rtabmap.getMemory();
|
||||
if (mem == nullptr) {
|
||||
return StatusResponse::Error(StatusCode::kFailedPrecondition, "rtabmap chua co Memory");
|
||||
}
|
||||
rtabmap::SensorData d = mem->getNodeData(id, true, false, false, false);
|
||||
cv::Mat img, depth;
|
||||
d.uncompressData(&img, with_depth ? &depth : nullptr); // du lieu trong DB la du lieu NEN
|
||||
if (img.empty() || d.cameraModels().empty()) {
|
||||
return StatusResponse::Error(StatusCode::kNotFound, "node khong co anh");
|
||||
}
|
||||
const rtabmap::CameraModel& cm = d.cameraModels()[0];
|
||||
out->gray = img;
|
||||
out->depth = depth;
|
||||
out->K = cv::Matx33d(cm.fx(), 0, cm.cx(), 0, cm.fy(), cm.cy(), 0, 0, 1);
|
||||
out->T_base_optical = ToMatx44(cm.localTransform());
|
||||
out->T_map_base = ToMatx44(it->second);
|
||||
return StatusResponse::Ok();
|
||||
}
|
||||
|
||||
StatusResponse RtabmapSlam::Close(bool save_database) {
|
||||
if (!impl_->inited) return StatusResponse::Ok();
|
||||
impl_->inited = false;
|
||||
|
||||
Reference in New Issue
Block a user