This commit is contained in:
trung09122002
2026-09-25 09:04:37 +07:00
parent d6f1afac31
commit 0093df0508
7 changed files with 139 additions and 5 deletions

View File

@@ -568,7 +568,8 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
const ConfigNode v = root["voxel"];
const StatusResponse r =
Reject(v, "slam.yaml voxel",
{"emit_size_m", "z_min", "z_max", "max_cells", "delta_max_ratio"});
{"emit_size_m", "z_min", "z_max", "max_cells", "delta_max_ratio",
"obstacle_z_min", "obstacle_z_max"});
if (!r.ok()) return r;
out->voxel.emit_size_m = v.get<double>("emit_size_m", out->voxel.emit_size_m);
@@ -578,6 +579,10 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
v.get<int>("max_cells", static_cast<int>(out->voxel.max_cells)));
out->voxel.delta_max_ratio =
v.get<double>("delta_max_ratio", out->voxel.delta_max_ratio);
out->voxel.obstacle_z_min =
v.get<double>("obstacle_z_min", out->voxel.obstacle_z_min);
out->voxel.obstacle_z_max =
v.get<double>("obstacle_z_max", out->voxel.obstacle_z_max);
if (out->voxel.emit_size_m <= 0.0) {
return StatusResponse::Error(StatusCode::kInvalidArgument,
@@ -592,6 +597,11 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
return StatusResponse::Error(StatusCode::kInvalidArgument,
"slam.yaml voxel.max_cells phai > 0");
}
if (out->voxel.obstacle_z_min >= out->voxel.obstacle_z_max) {
return StatusResponse::Error(
StatusCode::kInvalidArgument,
"slam.yaml voxel: obstacle_z_min phai nho hon obstacle_z_max");
}
}
}
#endif

View File

@@ -57,6 +57,10 @@ struct VoxelConfig {
// Ti le (them + bot) / tong vuot nguong nay thi gui lai CA TAP thay vi
// delta. Sau mot lan toi uu do thi thi gan nhu moi o doi chi so.
double delta_max_ratio = 0.35;
// Lop vat can tu camera gop vao luoi 2D: voxel co z trong khoang nay (tinh
// tu mat san) bi danh dau la tuong. Xem slam.yaml khoi `voxel:`.
double obstacle_z_min = 0.10;
double obstacle_z_max = 0.55;
};
struct ThreadConfig {

View File

@@ -1087,10 +1087,7 @@ void Runtime::SlamLoop() {
last_map_occ_ = occ;
last_map_free_ = fre;
}
auto ptr = std::make_shared<const OccupancyGrid>(std::move(grid));
std::lock_guard<std::mutex> lk(slam_mu_);
slam_map_ = ptr;
slam_published_version_ = slam_map_version_;
// KHONG dang o day -- xem cuoi khoi need_map.
}
// Loi o day khong phai chuyen la: do thi co the chua co pose toi uu nao
// o nhung khung dau. Khong log moi lan de khong lap day log.
@@ -1146,6 +1143,18 @@ void Runtime::SlamLoop() {
}
vg.epoch = voxel_epoch_;
// Lop vat can tu camera -> luoi 2D. Ngoai process(): dua depth vao
// Grid/* cua RTAB-Map keo pose lech (do 2026-09-24: TB 0.020 ->
// 0.052 m). Phai lam TRUOC khi `vg` bi move ben duoi.
if (st.ok()) {
const size_t n = MarkVoxelObstacles(vg, cfg_->voxel.obstacle_z_min,
cfg_->voxel.obstacle_z_max, &grid);
VSLAM_INFO_THROTTLE(30.0, "slam: " << n << " o vat can tu camera ("
<< cfg_->voxel.obstacle_z_min << "-"
<< cfg_->voxel.obstacle_z_max
<< " m) gop vao luoi 2D");
}
prev_voxel_cells_ = vg.cells;
auto vptr = std::make_shared<const VoxelGrid>(std::move(vg));
{
@@ -1155,6 +1164,16 @@ void Runtime::SlamLoop() {
}
}
}
// Dang luoi 2D SAU buoc voxel: web gui ban do theo version, nen dang
// ban chua gop roi thay bang ban da gop CUNG version la web khong bao
// gio thay ban da gop.
if (st.ok()) {
auto ptr = std::make_shared<const OccupancyGrid>(std::move(grid));
std::lock_guard<std::mutex> lk(slam_mu_);
slam_map_ = ptr;
slam_published_version_ = slam_map_version_;
}
}
}
#endif