reloc: gan lai camera (VPR + PnP) vao node -- chi bat khi co --slam-reloc-vpr; duong LiDAR giu nguyen ban 29/09

Code camera lay nguyen tu 1d3cb2f, giu hien thi yaw bang rad (153bb1b).
Kiem mo phong (co tuong, khong co co camera): vong 1 trung tung chu so voi ban 29/09
(1059 diem, ty le 1.16046 / 2.22805), chot sau 4 vong lech 0.042 m.
This commit is contained in:
trung09122002
2026-10-01 11:17:03 +07:00
parent f4b45afead
commit dbd508d910
3 changed files with 278 additions and 13 deletions

View File

@@ -51,7 +51,9 @@
#ifdef VSLAM_HAVE_SLAM
#include "vslam/global_localizer.h"
#include "vslam/rtabmap_slam.h"
#include "vslam/visual_verifier.h"
#include "vslam/voxel_export.h"
#include "vslam/vpr_encoder.h"
#endif
namespace vslam {
@@ -102,6 +104,11 @@ struct RuntimeOptions {
// --slam-reloc-auto: robot TU XOAY va TU DI de gom scan (reloc_exec cua ban
// ROS). Mac dinh TAT: robot tu chay khi CHUA biet minh o dau.
bool slam_reloc_auto = false;
// --slam-reloc-vpr [ENGINE]: CAMERA cung dinh vi lai -- VPR (TensorRT) goi y cho, PnP cho
// pose, chot khi TRUNG khop LiDAR. Can -DVSLAM_WITH_TENSORRT=ON; khong co thi canh bao
// roi chay bang LiDAR nhu cu.
bool slam_reloc_vpr = false;
std::string vpr_engine; // rong = $VSLAM_RESOURCE_DIR/vpr/eigenplaces_r50_fp16.plan
};
class Runtime {
@@ -167,6 +174,13 @@ class Runtime {
std::chrono::steady_clock::time_point now);
void RelocFinish(const Pose2D& map_from_odom, const Pose2D& odom, const LaserScan& scan,
const std::string& how);
// Bat dau pha dung yen + tinh chinh sau khi CHOT -- chung cho LiDAR va camera.
void RelocBeginSettle(const Pose2D& map_from_odom, double ratio, const Pose2D& odom,
std::chrono::steady_clock::time_point now, const std::string& src);
// Camera: cu 30 do xoay chup mot anh -> VPR top-5 -> PnP -> so voi LiDAR cuc bo quanh
// node anh. true = da CHOT (da vao RelocBeginSettle).
bool RelocCamera(const LaserScan& scan, const Pose2D& odom,
std::chrono::steady_clock::time_point now);
#endif
void ApplyThreadPriority(std::thread* t, int prio, const char* name);
@@ -376,6 +390,23 @@ class Runtime {
Pose2D reloc_settle_prev_odom_;
std::vector<Point> reloc_settle_pts_;
int reloc_settle_scans_ = 0;
std::string reloc_settle_src_; // "LiDAR, ty le .." | "camera+LiDAR (..)" -- log/web
// --- Camera trong dinh vi lai (--slam-reloc-vpr). CHI luong slam cham. ---
std::unique_ptr<VprEncoder> vpr_; // null = khong dung camera
std::unique_ptr<VisualVerifier> vverif_;
std::vector<int> vpr_ids_; // node ban do co mo ta
std::vector<float> vpr_desc_; // vpr_ids_.size() x dim, da chuan hoa
struct MapShot {
VisualFrame f; // ORB + depth + K + T_base_optical
cv::Matx44d T_map_base;
};
std::map<int, MapShot> vpr_shots_; // node ban do, nap khi can roi giu
bool reloc_cam_have_last_ = false;
double reloc_cam_last_theta_ = 0.0; // odom.theta lan chup gan nhat
UnixTime reloc_cam_last_stamp_;
int reloc_cam_shots_ = 0; // anh da thu trong vong gom nay
int reloc_cam_best_inl_ = 0; // inlier PnP tot nhat vong nay
#endif
// Doc-only sau Start(), nen khong can mutex.