drivers,sim: moi khung anh mot bo dem rieng (sua tranh chap voi SlamLoop o RealSense/sim/replay); sim: IMU dong hoc tu quy dao 6-DoF, tan so phat/tre/bias, ground truth vao .vsr, vslam_record --robot --gt
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "vslam/buffer_pool.h"
|
||||
#include "vslam/clock.h"
|
||||
#include "vslam/driver_config.h"
|
||||
#include "vslam/driver_interfaces.h"
|
||||
@@ -323,22 +324,30 @@ class RealSenseDriver : public CameraInterface {
|
||||
depth_img->data = static_cast<const uint8_t*>(depth.get_data());
|
||||
depth_img->keep_alive = keep; // KHONG copy: giu frameset song
|
||||
} else {
|
||||
Decimate16(praw, sw, sh, static_cast<int>(cfg_.decimate), &depth_buf_,
|
||||
// MOI khung mot bo dem RIENG tu pool, anh giu no qua keep_alive.
|
||||
//
|
||||
// ⚠️ Truoc day la MOT bo dem dung chung, "hop le toi lan goi Loop()
|
||||
// sau" -- du cho perception chay INLINE trong callback, nhung SlamLoop
|
||||
// giu khung depth/IR moi nhat qua Rtabmap::process (100-600 ms) tren
|
||||
// luong KHAC, va `BuildSensorData` boc cv::Mat quanh bo dem ma khong
|
||||
// copy. Khung sau (33 ms) ghi de giua chung: anh luu vao DB co the la
|
||||
// nua khung nay nua khung kia.
|
||||
auto buf = buf_pool_->Acquire();
|
||||
Decimate16(praw, sw, sh, static_cast<int>(cfg_.decimate), buf.get(),
|
||||
&depth_img->width, &depth_img->height);
|
||||
depth_img->step = depth_img->width * 2;
|
||||
depth_img->data = depth_buf_.data();
|
||||
// Bo dem cua ta: hop le toi lan goi Loop() sau. Consumer chay INLINE
|
||||
// trong callback (xem PerceptionPipeline) nen dieu do la du.
|
||||
depth_img->data = buf->data();
|
||||
depth_img->keep_alive = buf;
|
||||
}
|
||||
out.depth = depth_img;
|
||||
|
||||
if (cfg_.enable_infra1) {
|
||||
rs2::video_frame ir = fs.get_infrared_frame(1);
|
||||
if (ir) out.infra1 = WrapIr(ir, out.header, keep, &ir1_buf_);
|
||||
if (ir) out.infra1 = WrapIr(ir, out.header, keep);
|
||||
}
|
||||
if (cfg_.enable_infra2) {
|
||||
rs2::video_frame ir = fs.get_infrared_frame(2);
|
||||
if (ir) out.infra2 = WrapIr(ir, out.header, keep, &ir2_buf_);
|
||||
if (ir) out.infra2 = WrapIr(ir, out.header, keep);
|
||||
}
|
||||
|
||||
out.depth_info = info_;
|
||||
@@ -354,8 +363,7 @@ class RealSenseDriver : public CameraInterface {
|
||||
}
|
||||
|
||||
ImagePtr WrapIr(const rs2::video_frame& ir, const Header& hdr,
|
||||
const std::shared_ptr<FrameKeepAlive>& keep,
|
||||
std::vector<uint8_t>* buf) {
|
||||
const std::shared_ptr<FrameKeepAlive>& keep) {
|
||||
auto img = std::make_shared<Image>();
|
||||
img->header = hdr;
|
||||
img->format = PixelFormat::kMono8;
|
||||
@@ -367,10 +375,13 @@ class RealSenseDriver : public CameraInterface {
|
||||
img->data = static_cast<const uint8_t*>(ir.get_data());
|
||||
img->keep_alive = keep;
|
||||
} else {
|
||||
// Bo dem rieng moi khung, nhu depth o tren.
|
||||
auto buf = buf_pool_->Acquire();
|
||||
Decimate8(static_cast<const uint8_t*>(ir.get_data()), w, h,
|
||||
static_cast<int>(cfg_.decimate), buf, &img->width, &img->height);
|
||||
static_cast<int>(cfg_.decimate), buf.get(), &img->width, &img->height);
|
||||
img->step = img->width;
|
||||
img->data = buf->data();
|
||||
img->keep_alive = buf;
|
||||
}
|
||||
return img;
|
||||
}
|
||||
@@ -384,7 +395,10 @@ class RealSenseDriver : public CameraInterface {
|
||||
float depth_scale_ = 0.001f;
|
||||
CameraInfo info_;
|
||||
|
||||
std::vector<uint8_t> depth_buf_, ir1_buf_, ir2_buf_;
|
||||
// Bo dem anh da decimate (depth + IR). Moi khung lay bo dem rieng va tra
|
||||
// ve pool khi KHONG CON AI giu anh -- 0 malloc o trang thai on dinh.
|
||||
std::shared_ptr<BufferPool<std::vector<uint8_t>>> buf_pool_ =
|
||||
BufferPool<std::vector<uint8_t>>::Create(12);
|
||||
|
||||
std::atomic<bool> running_{false};
|
||||
std::thread thread_;
|
||||
|
||||
Reference in New Issue
Block a user