slam,odometry,perception: di tren doc (G4, slam.yaml slope.enabled, mac dinh tat) -- z robot = tich -ds*sin(pitch IMU) kep phang < 1.5 do va neo vao ban do (HeightEstimator), odometry ngang, scan cho SLAM bu nghieng + bo tia cham san/doc theo ban do do cao tu depth (ScanLeveler, ElevationMap), z/roll/pitch luu vao node + do thi z 1-D + mat san theo node (height_map), voxel dat o z that va vat can tinh tu san cuc bo, xoa tuong gia LiDAR tren doc noi camera da thay mat san, web z uoc luong, --sim-imu-hz

This commit is contained in:
trung09122002
2026-10-04 00:03:02 +07:00
parent 6735b53423
commit f064dcf3ec
32 changed files with 1799 additions and 10 deletions

View File

@@ -39,9 +39,12 @@
#include "app_config.h"
#include "vslam/driver_interfaces.h"
#include "vslam/ekf_se2.h"
#include "vslam/elevation_map.h"
#include "vslam/gamepad.h"
#include "vslam/geometry.h"
#include "vslam/height_estimator.h"
#include "vslam/perception_pipeline.h"
#include "vslam/scan_leveler.h"
#include "vslam/safety_monitor.h"
#include "vslam/scan_sanitizer.h"
#include "vslam/teleop_model.h"
@@ -93,6 +96,8 @@ struct RuntimeOptions {
// Ve camera mo phong bang GPU (vslam_sim_gl): depth + anh IR co texture.
// Can --world va node build voi -DVSLAM_SIM_WITH_GL=ON.
bool sim_gl = false;
// Tan so PHAT IMU cua sim (SimConfig::imu_output_hz). 0 = moi buoc vat ly.
double sim_imu_hz = 0.0;
bool force_slam = false; // --slam: ghi de slam.yaml enabled
bool have_slam_db = false; // --slam-db "" nghia la DB trong RAM
std::string slam_db;
@@ -130,6 +135,8 @@ class Runtime {
// wiring.cc -- noi duy nhat noi nguon voi stage. Tuong duong toan bo 20
// file .launch cua ban ROS.
StatusResponse Wire();
// Di tren doc: mot khung depth -> ban do do cao san cuc bo (luong camera).
void AddDepthToElevation(const CameraFrame& f);
// runtime.cc
StatusResponse OpenSource();
@@ -231,6 +238,9 @@ class Runtime {
// web_tx doc.
mutable std::mutex scan_mu_;
LaserScanPtr latest_scan_;
// Scan cho SLAM / dinh vi lai / canh lac: BU NGHIENG khi slope_on_ (xem
// ScanLeveler), con lai CHINH la latest_scan_. An toan + web dung ban tho.
LaserScanPtr latest_slam_scan_;
// odom_mu_: wheel_odom_ va ekf_. CHI luong source cham vao chung; hai luong
// kia chi doc ban sao pose.
@@ -476,6 +486,29 @@ class Runtime {
std::atomic<double> tilt_pitch_{0.0};
std::atomic<bool> tilt_accel_ok_{false};
// ---- Di tren doc (slam.yaml `slope:`) ----
// slope_on_ doc-only sau Start(). Tat thi KHONG doi tuong nao duoi day
// duoc tao, va moi duong cu giu nguyen.
bool slope_on_ = false;
// Duoi odom_mu_: luong encoder cong buoc, luong slam neo.
std::unique_ptr<HeightEstimator> height_;
// elev_mu_: ban do do cao san cuc bo + thong ke bu nghieng scan. THU TU
// KHOA: odom_mu_ roi moi elev_mu_, KHONG BAO GIO nguoc lai.
mutable std::mutex elev_mu_;
std::unique_ptr<ElevationMap> elev_;
ScanLevelerConfig level_cfg_;
ScanLevelStats level_stats_;
UnixTime elev_pruned_;
// Tinh, doc-only sau Start(): base_link <- laser_link / camera optical.
Transform laser_to_base_static_ = TransformIdentity();
Transform cam_to_base_static_ = TransformIdentity();
bool have_cam_to_base_ = false;
// CHI luong slam: lan giai do thi z cuoi; da neo z lan nao chua (lan DAU
// sau khoi dong / dinh vi lai thi DAT THANG z ban do, khong qua cong).
bool height_anchored_ = false;
uint64_t heights_version_ = 0;
std::chrono::steady_clock::time_point heights_at_{};
std::atomic<bool> estop_{false};
std::atomic<bool> stop_{false};