This commit is contained in:
trung09122002
2026-09-24 16:30:03 +07:00
parent 5e27c7cc41
commit d6f1afac31
20 changed files with 596 additions and 252 deletions

View File

@@ -453,6 +453,7 @@ StatusResponse Runtime::Start() {
// ATE 0.2378 m thay vi 0.0146 m tren map_house.db, khong mot loi nao.
Transform cam_to_base = TransformIdentity();
cfg_->robot.StaticTransform(kBaseLinkFrame, kCameraDepthOpticalFrame, &cam_to_base);
slam_cam_to_link_ = cam_to_base;
slam_->SetExtrinsics(laser_to_base, cam_to_base);
}
#else
@@ -959,6 +960,7 @@ void Runtime::SlamLoop() {
// Dung tach doan nay thanh mot helper tra ve con tro tho.
ImagePtr depth, infra1;
std::shared_ptr<const CameraInfo> depth_info;
double depth_roll = 0.0, depth_pitch = 0.0;
if (slam_use_depth_) {
std::lock_guard<std::mutex> lk(depth_mu_);
// 50 ms = mac dinh cua ApproxTimeSync. Scan 25 Hz (40 ms) va depth 30 Hz
@@ -971,8 +973,17 @@ void Runtime::SlamLoop() {
depth = latest_depth_;
infra1 = latest_infra1_;
depth_info = latest_depth_info_;
depth_roll = latest_depth_roll_;
depth_pitch = latest_depth_pitch_;
}
}
// Camera nghieng THEO than luc chup. Cung hinh hoc voi GravityAlign va
// CliffDetect -- dung chung TiltLift(), khong tu dung mot ban thu ba.
// TiltLift nang them wheel_radius, nen z cua ban do 3D tinh tu MAT SAN,
// khop voi voxel.z_min va voi hinh robot tren web.
const Transform cam_now = TransformCompose(
TiltLift(depth_roll, depth_pitch, cfg_->robot.geometry().wheel_radius),
slam_cam_to_link_);
SlamInput in;
in.stamp = scan->header.stamp;
@@ -981,6 +992,7 @@ void Runtime::SlamLoop() {
in.depth = depth.get();
in.depth_info = depth_info.get();
in.infra1 = infra1.get();
in.camera_to_base = depth ? &cam_now : nullptr;
// --- KHONG MOT MUTEX NAO duoc giu qua dong nay ---
const SlamOutput out = slam_->Process(in);
@@ -1301,7 +1313,9 @@ void Runtime::WebLoop() {
const char* voxels_source = "off";
if (voxel_enabled_) {
std::lock_guard<std::mutex> dlk(depth_mu_);
voxels_source = have_depth_ ? "scan+depth" : "scan";
// Ban do voxel dung TU DEPTH cua tung node, khong con tu scan: khong co
// depth thi no rong, va nhan phai noi dung dieu do.
voxels_source = have_depth_ ? "depth" : "thieu depth";
}
#endif

View File

@@ -40,6 +40,7 @@
#include "vslam/driver_interfaces.h"
#include "vslam/ekf_se2.h"
#include "vslam/gamepad.h"
#include "vslam/geometry.h"
#include "vslam/perception_pipeline.h"
#include "vslam/safety_monitor.h"
#include "vslam/scan_sanitizer.h"
@@ -210,6 +211,12 @@ class Runtime {
std::shared_ptr<const CameraInfo> latest_depth_info_;
UnixTime latest_depth_stamp_;
bool have_depth_ = false;
// Nghieng (gravity_align) LUC chup khung depth tren -- xem
// SlamInput::camera_to_base.
double latest_depth_roll_ = 0.0;
double latest_depth_pitch_ = 0.0;
// base_link <- camera_depth_optical_frame, tinh. Doc-only sau Start().
Transform slam_cam_to_link_ = TransformIdentity();
// mcu_mu_: sieu am va bumper.
//

View File

@@ -218,6 +218,10 @@ StatusResponse Runtime::Wire() {
// SlamLoop cam duoc con tro ra ngoai lock.
latest_depth_info_ = std::make_shared<const CameraInfo>(f.depth_info);
latest_depth_stamp_ = f.header.stamp;
// Qua atomic, khong doc thang GravityAlign: tren --live camera va IMU
// chay tren HAI luong khac nhau.
latest_depth_roll_ = tilt_roll_.load(std::memory_order_relaxed);
latest_depth_pitch_ = tilt_pitch_.load(std::memory_order_relaxed);
have_depth_ = true;
}