update
This commit is contained in:
@@ -30,6 +30,15 @@ Runtime::~Runtime() {
|
||||
Join();
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Tren muc nay thi canh bao rang odometry se kem chinh xac di. Lay tu PHEP DO
|
||||
// chu khong tu mot nguong vat ly nao: accel 0.60 cho sai so 0.015 m, accel
|
||||
// 0.86 cho 0.093 m -- dau goi nam giua hai gia tri do.
|
||||
//
|
||||
// Chi de CANH BAO, khong dieu khien gi.
|
||||
constexpr double kFastAccelWarn = 0.7;
|
||||
} // namespace
|
||||
|
||||
StatusResponse Runtime::OpenSource() {
|
||||
switch (opts_.source) {
|
||||
case SourceKind::kSim: {
|
||||
@@ -50,7 +59,7 @@ StatusResponse Runtime::OpenSource() {
|
||||
sc.camera_pitch = cfg_->robot.camera_pitch();
|
||||
sc.max_linear = speed_limit_;
|
||||
sc.max_angular = cfg_->robot.base().max_angular;
|
||||
sc.accel_limit = cfg_->robot.base().accel_limit;
|
||||
sc.accel_limit = accel_limit_;
|
||||
sc.lidar_rate_hz = cfg_->sensors.lidar_hz;
|
||||
sc.camera_rate_hz = cfg_->sensors.camera_hz;
|
||||
sc.imu_rate_hz = cfg_->sensors.imu_hz;
|
||||
@@ -87,6 +96,9 @@ StatusResponse Runtime::OpenSource() {
|
||||
<< " m. LiDAR va depth se KHONG thay no -- chi sieu am va "
|
||||
"bumper thay.");
|
||||
}
|
||||
// Ham lay ground truth, de `wiring.cc` chot no cung luc voi EKF.
|
||||
gt_fn_ = [this]() { return source_->sim->ground_truth(); };
|
||||
|
||||
lidar_ = source_->sim->lidar();
|
||||
camera_ = source_->sim->camera();
|
||||
mcu_ = source_->sim->mcu();
|
||||
@@ -161,8 +173,58 @@ StatusResponse Runtime::Start() {
|
||||
// `RobotModel` khong cho sua truc tiep (co y: no la nguon su that tu
|
||||
// robot.yaml). Gia tri cho sim va teleop lay tu bien duoi day.
|
||||
speed_limit_ = v;
|
||||
|
||||
// ⚠️ Noi tran ma khong noi GIA TOC thi tran moi khong voi toi duoc.
|
||||
//
|
||||
// `accel_limit` 0.30 m/s^2 can 6.7 giay va ~6.7 m duong chay de len toi
|
||||
// 2 m/s. Cho rong nhat trong toa nha benh vien chi 4.75 m, nen robot
|
||||
// KHONG BAO GIO cham toi toc do da dat: do duoc 0.983 m/s khi dat 2.00.
|
||||
// Nguoi van hanh keo thanh truot len het roi van thay cham, va khong co
|
||||
// gi giai thich.
|
||||
//
|
||||
// Giu nguyen ti le giua gia toc va tran, dung nhu robot that.
|
||||
const double base_v = cfg_->robot.base().max_linear;
|
||||
accel_limit_ = base_v > 1e-9
|
||||
? cfg_->robot.base().accel_limit * (v / base_v)
|
||||
: cfg_->robot.base().accel_limit;
|
||||
VSLAM_WARN("toc do: gia toc cung noi theo, " << cfg_->robot.base().accel_limit
|
||||
<< " -> " << accel_limit_ << " m/s^2. Khong noi thi tran "
|
||||
<< v << " m/s can " << (v / cfg_->robot.base().accel_limit)
|
||||
<< " s va ~" << (v * v / (2 * cfg_->robot.base().accel_limit))
|
||||
<< " m duong chay -- dai hon moi cho trong toa nha.");
|
||||
|
||||
// ⚠️ NOI GIA TOC LAM ODOMETRY KEM CHINH XAC HON.
|
||||
//
|
||||
// Do duoc tren the gioi benh vien, sai so uoc luong vs ground truth khi
|
||||
// lai lien tuc (SLAM bat):
|
||||
// --max-speed 0.35 (accel 0.30) -> 0.026 m
|
||||
// --max-speed 0.7 (accel 0.60) -> 0.015 m
|
||||
// --max-speed 1.0 (accel 0.86) -> 0.093 m
|
||||
// --max-speed 2.0 (accel 1.71) -> 0.118 m
|
||||
//
|
||||
// ⚠️ KHONG phai do truot banh. Toi da doan vay va SAI: `slip_factor` va
|
||||
// `slip_differential` mac dinh bang 0, va `vslam_node` KHONG BAO GIO dat
|
||||
// chung -- mo hinh truot chi duoc bat trong `vslam_record` va
|
||||
// `vslam_sim_run`. Trong duong chay cua node, banh khong he truot.
|
||||
//
|
||||
// Nguyen nhan la sai so ROI RAC cua wheel odometry: encoder lay mau o 50
|
||||
// Hz, nen o 2 m/s moi buoc di 4 cm va do cong trong buoc do bi bo qua.
|
||||
//
|
||||
// ⚠️ Sai so nay CO GIOI HAN, khong tich luy: do qua 170 giay lai lien tuc
|
||||
// o toc do toi da, no dao dong 0.026-0.057 m va dinh 0.100 m. Ke ca khi
|
||||
// dam vao vat can, hay lai giat cuc kieu tay, hay dung DB that -- van duoi
|
||||
// 0.10 m. Neu thay hinh ground truth tach ra XA HON the thi do la chuyen
|
||||
// khac, va o `gap` tren web se noi ro la loi du lieu hay loi ve.
|
||||
if (accel_limit_ > kFastAccelWarn) {
|
||||
VSLAM_WARN("toc do: chay nhanh lam wheel odometry kem chinh xac hon -- "
|
||||
"encoder lay mau 50 Hz nen do cong trong moi buoc bi bo qua. "
|
||||
"Do duoc: sai so vs ground truth 0.015 m o --max-speed 0.7, "
|
||||
"0.118 m o 2.0 (co gioi han, khong tich luy). Quet ban do thi "
|
||||
"dung 0.7.");
|
||||
}
|
||||
} else {
|
||||
speed_limit_ = cfg_->robot.base().max_linear;
|
||||
accel_limit_ = cfg_->robot.base().accel_limit;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -678,6 +740,11 @@ void Runtime::WebLoop() {
|
||||
shape.wheel_radius = g.wheel_radius;
|
||||
shape.wheel_separation = g.wheel_separation;
|
||||
shape.body_half_width = g.body_half_width;
|
||||
shape.body_length = g.body_length;
|
||||
shape.body_width = g.body_width;
|
||||
shape.body_height = g.body_height;
|
||||
shape.body_offset_x = g.body_offset_x;
|
||||
shape.ground_clearance = g.ground_clearance;
|
||||
|
||||
Transform t;
|
||||
if (cfg_->robot.StaticTransform(kBaseLinkFrame, kLaserFrame, &t)) {
|
||||
@@ -704,6 +771,8 @@ void Runtime::WebLoop() {
|
||||
snap.robot = shape;
|
||||
snap.stamp = clock_->Now();
|
||||
Pose2D ekf_pose;
|
||||
Pose2D gt_latched;
|
||||
bool have_gt_latched = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(odom_mu_);
|
||||
@@ -715,6 +784,8 @@ void Runtime::WebLoop() {
|
||||
}
|
||||
snap.pose_odom = wheel_odom_->pose();
|
||||
ekf_pose = ekf_->pose();
|
||||
gt_latched = gt_at_ekf_;
|
||||
have_gt_latched = have_gt_at_ekf_;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -763,7 +834,14 @@ void Runtime::WebLoop() {
|
||||
// stage nao duoc doc no, do la ca dieu kien de no dung lam thuoc do.
|
||||
if (source_->sim) {
|
||||
snap.have_ground_truth = true;
|
||||
snap.ground_truth = source_->sim->ground_truth();
|
||||
// ⚠️ Dung ban CHOT cung luc voi EKF, khong doc tuoi.
|
||||
//
|
||||
// Doc tuoi roi dem voi `ekf_pose` (cu hon mot chu ky cam bien) bien do
|
||||
// TRE thanh "sai so dinh vi": do duoc 0.118 m o 2 m/s va 0.0000 m khi
|
||||
// dung yen -- ti le thang voi van toc, dung chu ky cua do tre chu khong
|
||||
// phai cua sai so.
|
||||
snap.ground_truth = have_gt_latched ? gt_latched
|
||||
: source_->sim->ground_truth();
|
||||
source_->sim->true_tilt(&snap.gt_roll, &snap.gt_pitch);
|
||||
}
|
||||
|
||||
@@ -799,6 +877,31 @@ void Runtime::WebLoop() {
|
||||
// Hau qua: lop `duong di` chi la MOT diem dung yen o goc the gioi, trong
|
||||
// khi robot chay di cho khac. Khong mot loi nao: khung PATH van gui dung
|
||||
// nhip, chi la no luon mang dung 1 diem (28 byte).
|
||||
// ⚠️ Ghi dinh ky SAI SO vs ground truth vao log.
|
||||
//
|
||||
// Cau hoi "hinh xanh la lech that hay lech do ve" da mat nhieu luot trao
|
||||
// doi, vi no chi tra loi duoc bang MOT con so ma con so do truoc day chi
|
||||
// hien thoang qua tren man hinh. Gio no nam trong log, nen mot file
|
||||
// `tee` la du de tra loi.
|
||||
//
|
||||
// `err` tinh o server tu `pose_map` va `ground_truth`. Neu no nho ma
|
||||
// nguoi dung van thay hai hinh tach xa thi loi nam o tang HIEN THI, khong
|
||||
// o uoc luong.
|
||||
if (snap.have_ground_truth) {
|
||||
const double err = Distance2D(snap.pose_map, snap.ground_truth);
|
||||
if (err > gt_err_max_) gt_err_max_ = err;
|
||||
const double now_s = snap.stamp.toSec();
|
||||
if (gt_err_last_log_ == 0.0) gt_err_last_log_ = now_s;
|
||||
if (now_s - gt_err_last_log_ >= 5.0) {
|
||||
gt_err_last_log_ = now_s;
|
||||
VSLAM_INFO("gt: sai so vs ground truth " << err << " m (lon nhat "
|
||||
<< gt_err_max_ << " m). uoc=(" << snap.pose_map.x << ", "
|
||||
<< snap.pose_map.y << ") that=(" << snap.ground_truth.x
|
||||
<< ", " << snap.ground_truth.y << ")");
|
||||
gt_err_max_ = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(traj_mu_);
|
||||
// Thua hoa: chi them diem khi da di du xa. Gui lai ca quy dao moi khung
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
// theo luong, de review thay ngay cai nao cham vao cai nao.
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
@@ -221,6 +222,24 @@ class Runtime {
|
||||
bool slam_should_save_ = false;
|
||||
// Tran toc do dang dung (m/s): tu robot.yaml, hoac --max-speed ghi de.
|
||||
double speed_limit_ = 0.35;
|
||||
// Gia toc thuc su dung. Bang robot.yaml, TRU khi `--max-speed` noi tran --
|
||||
// khi do no noi theo cung ti le, xem ghi chu trong runtime.cc.
|
||||
double accel_limit_ = 0.30;
|
||||
// Sai so vs ground truth, de ghi log dinh ky. Chi co nghia khi chay sim.
|
||||
// Lay ground truth cua mo phong. Rong khi khong chay sim.
|
||||
//
|
||||
// Dung std::function chu khong con tro toi SimSource: `wiring.cc` khong
|
||||
// thay dinh nghia cua `SourceHolder`, va keo them mot include vao day chi
|
||||
// de doc mot Pose2D la khong dang.
|
||||
std::function<Pose2D()> gt_fn_;
|
||||
|
||||
// Ground truth CHOT cung luc voi EKF, duoi `odom_mu_`. Doc tuoi luc chup
|
||||
// snapshot roi dem voi pose cu la do DO TRE chu khong phai sai so.
|
||||
Pose2D gt_at_ekf_;
|
||||
bool have_gt_at_ekf_ = false;
|
||||
|
||||
double gt_err_max_ = 0.0;
|
||||
double gt_err_last_log_ = 0.0;
|
||||
#ifdef VSLAM_HAVE_SLAM
|
||||
SlamMode slam_mode_ = SlamMode::kMapping;
|
||||
#endif
|
||||
|
||||
@@ -110,6 +110,22 @@ StatusResponse Runtime::Wire() {
|
||||
o.twist.covariance[35]);
|
||||
latest_odom_ = o;
|
||||
have_odom_ = true;
|
||||
|
||||
// ⚠️ CHOT ground truth NGAY DAY, cung luc voi EKF.
|
||||
//
|
||||
// `ekf_->pose()` la uoc luong tai thoi diem cap nhat NAY. Neu web doc
|
||||
// ground truth TUOI luc chup snapshot roi dem so voi pose cu, thi cai
|
||||
// do duoc khong phai sai so dinh vi ma la DO TRE nhan van toc.
|
||||
//
|
||||
// Do duoc: dung yen lech 0.0000 m; dang chay lech ti le thang voi toc
|
||||
// do -- 0.018 m o 0.87 m/s, 0.044 m o 1.14 m/s, 0.118 m o 2.0 m/s.
|
||||
// Chia ra la 20-60 ms, dung bang mot chu ky cam bien. Hinh ground
|
||||
// truth xanh la vi the tach ra ngay khi robot vua chay, va nguoi van
|
||||
// hanh tuong robot lac.
|
||||
if (gt_fn_) {
|
||||
gt_at_ekf_ = gt_fn_();
|
||||
have_gt_at_ekf_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// gravity_align phai TRU gia toc rieng cua robot truoc khi coi phan con
|
||||
@@ -192,6 +208,30 @@ StatusResponse Runtime::Wire() {
|
||||
}
|
||||
return StatusResponse::Ok();
|
||||
}
|
||||
// Dat THANG gia tri, thay vi cong don tung buoc.
|
||||
//
|
||||
// ⚠️ `teleop/adjust` di mot buoc 0.05 m/s. Tu mac dinh 0.30 len tran
|
||||
// 2.00 la **34 lan bam** -- nguoi van hanh bam vai cai, thay van cham,
|
||||
// roi ket luan la lenh khong an. Da xay ra that.
|
||||
if (cmd == "teleop/set") {
|
||||
std::string axis;
|
||||
double value = 0.0;
|
||||
if (!JsonGetString(body, "axis", &axis) ||
|
||||
!JsonGetNumber(body, "value", &value)) {
|
||||
return StatusResponse::Error(StatusCode::kInvalidArgument,
|
||||
"can \"axis\" va \"value\"");
|
||||
}
|
||||
std::lock_guard<std::mutex> lk(teleop_mu_);
|
||||
// Model tu kep vao [min, max]; khong kep o day de chi co MOT cho
|
||||
// giu gioi han.
|
||||
if (axis == "lin") teleop_->SetLinearSpeed(value);
|
||||
else if (axis == "ang") teleop_->SetAngularSpeed(value);
|
||||
else {
|
||||
return StatusResponse::Error(StatusCode::kInvalidArgument,
|
||||
"axis phai la \"lin\" hoac \"ang\"");
|
||||
}
|
||||
return StatusResponse::Ok();
|
||||
}
|
||||
return StatusResponse::Error(StatusCode::kNotFound, "lenh la");
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user