This commit is contained in:
trung09122002
2026-09-19 15:33:52 +07:00
parent 48bd5377dc
commit 3b281174d0
22 changed files with 1913 additions and 119 deletions

View File

@@ -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");
},