reloc: dung XIEN tren doc -- tu chay quay mat theo chieu doc (IMU) de camera nhan ra; bo loc nghieng + neo z noi suy giua hai lan cung mat doc (doc rong) -- sim doc rong quet 3 lan: 8/8 cho xien chot dung 0.5-4.4 cm, 6/8 bang camera (11-55 s)
This commit is contained in:
@@ -1619,6 +1619,9 @@ constexpr double kRelocCreepBlind = 1.5; // m
|
||||
// duoi chan doc truoc khi toi tuong xa -> mu toi khi ra gan chan doc.
|
||||
constexpr double kRelocSlopeCreepMax = kRelocMaxDrive; // m
|
||||
constexpr double kRelocCreepMargin = 0.6; // m chua truoc vat can (lop an toan dung 0.45)
|
||||
// Tu chay tren doc co camera: dung XIEN qua goc nay so voi chieu doc thi quay mat
|
||||
// theo doc (xem cho goi SlopeAlignTurn).
|
||||
constexpr double kRelocSlopeAlignRad = 20.0 * M_PI / 180.0;
|
||||
} // namespace
|
||||
|
||||
double Runtime::RelocFrontClear(const LaserScan& scan) const {
|
||||
@@ -1651,7 +1654,10 @@ bool Runtime::RelocPoseAdmissible(const Pose2D& p, double tilt_r, double tilt_p)
|
||||
const int r = static_cast<int>(std::lround((p.y - lf->origin_y()) / lf->resolution()));
|
||||
if (!lf->Free(r, c)) return false;
|
||||
double gx = 0.0, gy = 0.0;
|
||||
if (!FloorGradientAt(slam_->floor_model(), p.x, p.y, reloc_cfg_.tilt_node_radius, &gx, &gy)) {
|
||||
const FloorModel& fm = slam_->floor_model();
|
||||
if (!FloorGradientAt(fm, p.x, p.y, reloc_cfg_.tilt_node_radius, &gx, &gy) &&
|
||||
!FloorGradientBetween(fm, p.x, p.y, reloc_cfg_.tilt_between_radius,
|
||||
std::tan(reloc_cfg_.tilt_agree_deg * M_PI / 180.0), &gx, &gy)) {
|
||||
return true; // khong biet san o do -- khong loai
|
||||
}
|
||||
return TiltResidual(tilt_r, tilt_p, p.theta, gx, gy) <=
|
||||
@@ -1822,16 +1828,18 @@ void Runtime::RelocStep(const LaserScan& scan, const Pose2D& odom) {
|
||||
const double err = AngleDiff(reloc_turn_target_, odom.theta);
|
||||
const double t = std::chrono::duration<double>(now - reloc_phase_t0_).count();
|
||||
if (std::fabs(err) < 5.0 * M_PI / 180.0 || t > kRelocPhaseTimeout) {
|
||||
// Quay theo chieu doc: reloc_drive_len_ = 0 nen pha DI xong ngay, sang vong gom moi.
|
||||
reloc_exec_ = RelocExec::kDrive;
|
||||
reloc_drive_start_ = odom;
|
||||
reloc_phase_t0_ = now;
|
||||
reloc_aligning_ = false;
|
||||
if (!yielding) RelocCommand(0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
if (!yielding) RelocCommand(0.0, err > 0.0 ? kRelocTurnRate : -kRelocTurnRate);
|
||||
SetRelocStatus("TU QUAY ve huong thoang (con " +
|
||||
std::to_string(static_cast<int>(std::fabs(err) * 180.0 / M_PI)) + " do)" +
|
||||
(yielding ? " -- NHUONG NGUOI" : ""),
|
||||
SetRelocStatus(std::string(reloc_aligning_ ? "QUAY THEO CHIEU DOC" : "TU QUAY ve huong thoang") +
|
||||
" (con " + std::to_string(static_cast<int>(std::fabs(err) * 180.0 / M_PI)) +
|
||||
" do)" + (yielding ? " -- NHUONG NGUOI" : ""),
|
||||
true);
|
||||
return;
|
||||
}
|
||||
@@ -2066,8 +2074,16 @@ void Runtime::RelocStep(const LaserScan& scan, const Pose2D& odom) {
|
||||
py.y, py.theta * 180.0 / M_PI);
|
||||
}
|
||||
VSLAM_WARN("slam: reloc chua chot -- " << buf << who);
|
||||
// Dung XIEN tren doc: anh ban do chup DOC doc (luc quet robot di len / xuong) nen camera
|
||||
// khong nhan ra goc xien (sim 06/10, doc rong: 8/8 cho xien khong chot, PnP 0-6 diem).
|
||||
// Huong doc lay tu IMU, khong can biet pose.
|
||||
double misalign = 0.0;
|
||||
const double align = SlopeAlignTurn(tilt_r, tilt_p, &misalign);
|
||||
const bool askew = vpr_ && reloc_static_round_ && misalign > kRelocSlopeAlignRad;
|
||||
if (!running) {
|
||||
SetRelocStatus(buf, true);
|
||||
SetRelocStatus(std::string(buf) +
|
||||
(askew ? " -- xoay robot DOC theo doc (len/xuong) de camera nhan ra" : ""),
|
||||
true);
|
||||
return;
|
||||
}
|
||||
// Tu chay: sang cho khac roi xoay tiep -- doi xung cuc bo thuong vo khi
|
||||
@@ -2086,6 +2102,25 @@ void Runtime::RelocStep(const LaserScan& scan, const Pose2D& odom) {
|
||||
// < min_ratio thi DecideStatic tra truoc khi kiem doc truc (sim: giua lan
|
||||
// dich 1 m giu 100% ma van bo tung 0.5 m sau 3 lan).
|
||||
const bool blind = admit && shift_ratio >= reloc_cfg_.tilt_max_shift_ratio;
|
||||
// Dung xien va LiDAR chua chac sau vong dau o cho nay -> quay mat theo chieu doc
|
||||
// (len / xuong, phia gan hon) roi khop lai tai cho: anh camera moi giong anh ban
|
||||
// do. Moi cho mot lan. Khong camera thi khong quay -- LiDAR khong loi gi ma them
|
||||
// truot banh.
|
||||
const bool lidar_sure = m.ok && m.ratio() >= reloc_cfg_.static_min_ratio && !blind;
|
||||
if (askew && !reloc_aligned_here_ && !lidar_sure) {
|
||||
reloc_aligned_here_ = true;
|
||||
reloc_aligning_ = true;
|
||||
reloc_static_here_ = 0;
|
||||
reloc_static_hist_.clear();
|
||||
reloc_turn_target_ = NormalizeAngle(odom.theta + align);
|
||||
reloc_drive_len_ = 0.0;
|
||||
reloc_exec_ = RelocExec::kTurn;
|
||||
reloc_phase_t0_ = now;
|
||||
VSLAM_INFO("reloc_exec: dung xien " << misalign * 180.0 / M_PI << " do so voi chieu doc -- QUAY "
|
||||
<< align * 180.0 / M_PI << " do de camera nhin doc theo doc, roi khop lai tai cho.");
|
||||
SetRelocStatus(std::string(buf) + " -- QUAY THEO CHIEU DOC", true);
|
||||
return;
|
||||
}
|
||||
if (!blind && reloc_static_here_ < kRelocStaticBeforeCreep) {
|
||||
RelocStartSweep();
|
||||
VSLAM_INFO("reloc_exec: vong " << reloc_cycle_ << " chua chot -- tren doc: khop lai tai cho ("
|
||||
@@ -2104,6 +2139,7 @@ void Runtime::RelocStep(const LaserScan& scan, const Pose2D& odom) {
|
||||
return;
|
||||
}
|
||||
reloc_static_here_ = 0;
|
||||
reloc_aligned_here_ = false; // cho moi
|
||||
reloc_creeping_ = true;
|
||||
// Chot CHO nay truoc khi bo: chot "hai cho" so cho moi voi no.
|
||||
if (!reloc_static_hist_.empty()) {
|
||||
@@ -2145,6 +2181,7 @@ void Runtime::RelocStep(const LaserScan& scan, const Pose2D& odom) {
|
||||
return;
|
||||
}
|
||||
reloc_static_here_ = 0;
|
||||
reloc_aligned_here_ = false;
|
||||
if (reloc_exec_cycles_ >= kRelocMaxCycles || reloc_total_drive_ >= kRelocMaxDrive) {
|
||||
RelocHalt("het tran " + std::to_string(kRelocMaxCycles) + " vong / " +
|
||||
std::to_string(static_cast<int>(kRelocMaxDrive)) + " m");
|
||||
@@ -2558,7 +2595,13 @@ void Runtime::RelocFinish(const Pose2D& map_from_odom, const Pose2D& odom,
|
||||
slam_->UpdateHeights(zc);
|
||||
}
|
||||
double z_ref = 0.0;
|
||||
if (slam_->HeightAt(pose.x, pose.y, 2.0, &z_ref)) {
|
||||
// Giua doc rong (node gan nhat xa hon 2 m -- sim 06/10: z lech 0.75 m sau khi chot)
|
||||
// thi noi suy giua hai lan cung mat doc. 0.3 m: z ban do hai lan da lech nhau 13 cm
|
||||
// (sim 06/10); hai MAT khac nhau thi do doc da loai, nguong z chi chan hai san song
|
||||
// song khac do cao (sanh 0 m / tang 1.5 m).
|
||||
if (slam_->HeightAt(pose.x, pose.y, 2.0, &z_ref) ||
|
||||
FloorZBetween(slam_->floor_model(), pose.x, pose.y, reloc_cfg_.tilt_between_radius,
|
||||
std::tan(reloc_cfg_.tilt_agree_deg * M_PI / 180.0), 0.30, &z_ref)) {
|
||||
std::lock_guard<std::mutex> lk(odom_mu_);
|
||||
height_->Reset(z_ref, cfg_->slope.sigma_anchor);
|
||||
height_anchored_ = true;
|
||||
@@ -2624,6 +2667,8 @@ void Runtime::RelocWatch(const LaserScan& scan, const Pose2D& pose_map) {
|
||||
reloc_static_hist_.clear();
|
||||
reloc_static_places_.clear();
|
||||
reloc_static_here_ = 0;
|
||||
reloc_aligned_here_ = false;
|
||||
reloc_aligning_ = false;
|
||||
reloc_slope_creep_ = 0.0;
|
||||
reloc_creeping_ = false;
|
||||
if (opts_.slam_reloc_auto) {
|
||||
|
||||
@@ -410,6 +410,10 @@ class Runtime {
|
||||
int reloc_static_here_ = 0;
|
||||
double reloc_slope_creep_ = 0.0;
|
||||
bool reloc_creeping_ = false;
|
||||
// Tu chay tren doc co camera: da quay mat theo chieu doc o CHO nay chua, va pha QUAY
|
||||
// hien tai co phai lan quay theo chieu doc khong (chu tren web).
|
||||
bool reloc_aligned_here_ = false;
|
||||
bool reloc_aligning_ = false;
|
||||
std::chrono::steady_clock::time_point reloc_t0_; // dau vong gom
|
||||
std::chrono::steady_clock::time_point reloc_epoch_; // moc thoi gian cho tracker
|
||||
// Truoc khi chot, web ve robot (mo) tu pose nay: node DAU TIEN cua ban do (cho bat dau
|
||||
|
||||
Reference in New Issue
Block a user