update
This commit is contained in:
@@ -36,6 +36,8 @@ struct RtabmapConfig {
|
||||
// Reg/Strategy=1 (ICP tren LiDAR) van la thu TINH phep bien doi. Nen bat
|
||||
// thi giac khong danh doi do chinh xac.
|
||||
bool visual_loop = false;
|
||||
// Gui depth vao RTAB-Map (luu trong DB) va bat ban do voxel 3D. KHONG doi
|
||||
// luoi -- xem ghi chu trong BuildRtabmapParams.
|
||||
bool camera_3d = false;
|
||||
|
||||
// Optimizer. "1" = g2o. KHONG dung "2" (GTSAM): apt jammy arm64 khong co
|
||||
|
||||
@@ -39,6 +39,14 @@ struct SlamInput {
|
||||
const Image* depth = nullptr;
|
||||
const CameraInfo* depth_info = nullptr;
|
||||
const Image* infra1 = nullptr; // D410 KHONG co RGB -> dung IR trai lam "rgb"
|
||||
|
||||
// base_footprint <- camera_depth_optical_frame TAI luc chup depth, DA gom
|
||||
// nghieng do duoc (TiltLift). Null = dung ngoai lai tinh trong SetExtrinsics
|
||||
// (camera coi nhu luon nam ngang).
|
||||
//
|
||||
// Than robot chuc len/xuong khi tang/giam toc. Coi camera nam ngang thi san
|
||||
// o 3 m bi day len ~0.2 m va thanh vat can gia trong ban do 3D.
|
||||
const Transform* camera_to_base = nullptr;
|
||||
};
|
||||
|
||||
struct SlamOutput {
|
||||
|
||||
@@ -6,26 +6,30 @@
|
||||
// Khac occupancy_export.cc o mot cho ban le: o day KHONG dung
|
||||
// rtabmap::OccupancyGrid. `BuildFromCache` ep Grid/3D="false" ngay trong ham
|
||||
// (occupancy_export.cc) va do la dung cho duong 2D -- no chieu moi thu xuong
|
||||
// mot mat phang. Ban do 3D phai lay o BI CHIEM o he cuc bo cua tung node roi
|
||||
// tu bien doi bang pose DA TOI UU.
|
||||
// mot mat phang. Ban do 3D lay DEPTH cua tung node, chieu thanh diem MOT lan
|
||||
// (cache theo id node), roi moi lan xuat chi bien doi cac diem do bang pose
|
||||
// DA TOI UU. Khong dung luoi cuc bo 3D cua RTAB-Map: dung no trong process()
|
||||
// keo pose lech (xem BuildRtabmapParams).
|
||||
//
|
||||
// ⚠️ Chinh vi dung pose da toi uu ma ban do 3D tu NAN lai sau moi vong dong:
|
||||
// khong co buoc "sua ban do" nao ca, ta dung lai tu dau tu do thi moi. Doi
|
||||
// lai, sau mot lan toi uu thi gan nhu MOI voxel doi chi so -- xem `epoch`
|
||||
// trong VoxelGrid va luat 35% o phia web.
|
||||
//
|
||||
// ⚠️ `data.uncompressData()` la BAT BUOC truoc khi doc gridObstacleCellsRaw().
|
||||
// ⚠️ `data.uncompressData()` la BAT BUOC truoc khi doc depthOrRightRaw().
|
||||
// Quen no thi moi node tra ve ma tran RONG, va trieu chung la "1990 node, 0 o"
|
||||
// -- y het cai bay da co trong occupancy_export.h.
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "vslam/vslam_common.h"
|
||||
|
||||
namespace rtabmap {
|
||||
class Rtabmap;
|
||||
class SensorData;
|
||||
}
|
||||
|
||||
namespace vslam {
|
||||
@@ -39,13 +43,31 @@ struct VoxelExportOptions {
|
||||
double z_min = 0.05;
|
||||
double z_max = 2.00;
|
||||
|
||||
// Tran cung. Cham tran thi cat bot va bat `truncated` chu khong am tham
|
||||
// nuot: mot ban do 3D thieu mot nua trong im lang la kieu hong te nhat.
|
||||
// Tran SO O PHAT. Cham tran thi GIAM MAU DEU (buoc `stride`), khong cat cut
|
||||
// -- ban do giu nguyen hinh dang, chi thua di. Xem Finish().
|
||||
size_t max_cells = 150000;
|
||||
|
||||
// Gom bao nhieu khoa thi sort+unique mot lan. Doi bo nho dinh lay so lan
|
||||
// tron: 2M khoa = 16 MB tam thoi.
|
||||
size_t flush_every = 2000000;
|
||||
|
||||
// Chieu depth cua node thanh diem. Cung dai voi depth_filter (pipeline.yaml
|
||||
// 0.22-4.0 m): xa hon 4 m nhieu cua D410 tang theo binh phuong.
|
||||
double depth_min_m = 0.22;
|
||||
double depth_max_m = 4.0;
|
||||
// Bang Grid/DepthDecimation (4) ma luoi 3D cu da dung.
|
||||
int depth_decimation = 4;
|
||||
// So node MOI toi da doi depth -> diem trong MOT lan xuat. Localization nap
|
||||
// ca nghin node mot luc; khong gioi han thi lan xuat dau chan luong slam
|
||||
// hang chuc giay. Ban do day dan qua cac lan xuat.
|
||||
size_t max_new_nodes = 40;
|
||||
};
|
||||
|
||||
// Diem cua tung node, o frame CUA NODE, da gom voxel. Tinh MOT lan roi giu:
|
||||
// depth cua node khong doi, chi pose cua no doi sau moi lan toi uu.
|
||||
// CHI luong slam cham vao.
|
||||
struct VoxelNodeCache {
|
||||
std::unordered_map<int, std::vector<float>> nodes; // id -> x,y,z,x,y,z...
|
||||
};
|
||||
|
||||
// Gom diem -> tap voxel. KHONG chua kieu nao cua RTAB-Map, nen test duoc ma
|
||||
@@ -67,6 +89,9 @@ class VoxelAccumulator {
|
||||
// So diem bi cat vi nam ngoai [z_min, z_max].
|
||||
size_t z_rejected() const { return z_rejected_; }
|
||||
|
||||
// Buoc giam mau da dung o lan Finish() gan nhat. 1 = khong giam.
|
||||
size_t stride() const { return stride_; }
|
||||
|
||||
private:
|
||||
void Flush();
|
||||
|
||||
@@ -76,6 +101,7 @@ class VoxelAccumulator {
|
||||
std::vector<uint64_t> acc_; // luon o trang thai da sort+unique
|
||||
size_t clamped_ = 0;
|
||||
size_t z_rejected_ = 0;
|
||||
size_t stride_ = 1;
|
||||
};
|
||||
|
||||
// Quet toan bo pose da toi uu va dung lai tap voxel tu dau.
|
||||
@@ -83,7 +109,15 @@ class VoxelAccumulator {
|
||||
// `out->epoch` KHONG duoc dat o day -- nguoi goi quan ly vong doi epoch, vi
|
||||
// chi ho moi biet tap truoc do la gi.
|
||||
StatusResponse ExportVoxelGrid(rtabmap::Rtabmap& slam,
|
||||
const VoxelExportOptions& opt, VoxelGrid* out);
|
||||
const VoxelExportOptions& opt,
|
||||
VoxelNodeCache* cache, VoxelGrid* out);
|
||||
|
||||
// Depth trong `data` (da uncompressData) -> diem o frame base cua node, cat
|
||||
// theo depth_min/max va z_min/z_max, gom theo emit_size_m. Rong neu node
|
||||
// khong co depth. Tach rieng de test duoc ma khong can Rtabmap.
|
||||
void NodeCloudFromSensorData(const rtabmap::SensorData& data,
|
||||
const VoxelExportOptions& opt,
|
||||
std::vector<float>* out);
|
||||
|
||||
// Hieu hai tap DA SAP XEP: `added` co trong `now` ma khong co trong `prev`,
|
||||
// `removed` thi nguoc lai. O(n + m), mot luot.
|
||||
|
||||
@@ -116,41 +116,16 @@ std::map<std::string, std::string> BuildRtabmapParams(
|
||||
// Kp/MaxFeatures: -1 = tat han tui tu. >0 = so dac trung moi anh.
|
||||
out["Kp/MaxFeatures"] = cfg.visual_loop ? "400" : "-1";
|
||||
|
||||
// --- camera_3d: luoi cuc bo 3D de dung ban do voxel cho web ---
|
||||
// --- camera_3d KHONG dung vao Grid/* ---
|
||||
//
|
||||
// Nam o muc 3 chu khong o `project_defaults`: slam.yaml dat THANG
|
||||
// `Grid/Sensor: "0"` va `Grid/3D: "false"`, ma muc 2 (YAML) ghi de len muc
|
||||
// 1. De o day thi ba key nay la HE QUA cua co, dung nhu Mem/IncrementalMemory
|
||||
// la he qua cua mode.
|
||||
if (cfg.camera_3d) {
|
||||
// 0=scan 1=depth 2=ca hai. Can "2": LiDAR van la trong tai cho ICP, con
|
||||
// depth la thu duy nhat co chieu cao.
|
||||
out["Grid/Sensor"] = "2";
|
||||
out["Grid/3D"] = "true";
|
||||
|
||||
// Tach san/vat can bang NGUONG CHIEU CAO, khong bang phap tuyen.
|
||||
// NormalsSegmentation mac dinh true va la duong DAT: no uoc luong phap
|
||||
// tuyen (Grid/NormalK = 20 lang gieng) cho moi diem, moi khung. Robot nay
|
||||
// la 2.5D (Reg/Force3DoF), san phang, nen mot nguong chieu cao la du.
|
||||
// RTAB-Map cung noi thang: MaxGroundHeight "should be set if
|
||||
// NormalsSegmentation is false".
|
||||
out["Grid/NormalsSegmentation"] = "false";
|
||||
out["Grid/MaxGroundHeight"] = "0.10"; // duoi nguong = san
|
||||
out["Grid/MaxObstacleHeight"] = "2.0"; // tren nguong = tran, vut di
|
||||
|
||||
// ⚠️ Grid/RayTracing GIU NGUYEN "true" (mac dinh cua du an), khong tat.
|
||||
//
|
||||
// Tat no re hon that -- voi Grid/3D=true, ray tracing dien o KHONG GIAN
|
||||
// chu khong phai mat phang, va ban do voxel chi doc o BI CHIEM nen o
|
||||
// trong la chi phi thuan. Nhung no cung chinh la thu sinh ra o "trong"
|
||||
// cua luoi 2D: do tren robot that 2026-09-23, mot phien 3.5 phut cho
|
||||
// 84961 o trong / 5049 o bi chiem. Tat di thi khung ban do tren web gan
|
||||
// nhu chi con mau "chua biet".
|
||||
//
|
||||
// Muon danh doi nguoc lai thi dat `Grid/RayTracing: "false"` trong khoi
|
||||
// `rtabmap:` cua slam.yaml -- do la viec cua nguoi van hanh, khong phai
|
||||
// mot he qua am tham cua camera_3d.
|
||||
}
|
||||
// Truoc 2026-09-24 camera_3d ep Grid/Sensor=2 + Grid/3D=true de RTAB-Map
|
||||
// dung luoi cuc bo 3D TRONG process(). Do trong mo phong (hospital, 0.7 m/s,
|
||||
// sai so vs ground truth luc dung yen): 2D 0.009 m; luoi 3D 0.06-0.11 m;
|
||||
// luoi 3D tat ray tracing 0.035 m; depth vao nhung luoi 2D 0.024 m. Luoi 3D
|
||||
// trong process() keo pose lech -- co che ben trong RTAB-Map CHUA ro.
|
||||
//
|
||||
// Nen luoi giu 2D, depth van vao SensorData (luu trong DB), va ban do 3D
|
||||
// dung NGOAI process() tu depth cua tung node -- xem voxel_export.h.
|
||||
|
||||
// Optimizer: dat TUONG MINH, luon luon.
|
||||
//
|
||||
|
||||
@@ -40,6 +40,9 @@ class RtabmapSlamImpl {
|
||||
|
||||
SlamStats stats;
|
||||
|
||||
// Diem depth theo node cho ban do voxel. Chi ExportVoxels (luong slam) cham.
|
||||
VoxelNodeCache voxel_cache;
|
||||
|
||||
void RecordMs(double ms) {
|
||||
stats.last_ms = ms;
|
||||
stats.max_ms = std::max(stats.max_ms, ms);
|
||||
@@ -167,12 +170,15 @@ StatusResponse RtabmapSlam::Init(const RtabmapConfig& cfg) {
|
||||
"visual_loop=true nhung DB khong co tu vung (Word = 0). Ban do nay "
|
||||
"duoc quet voi visual_loop=false; hai co phai khop nhau.");
|
||||
}
|
||||
if (cfg.camera_3d && facts.exists && !facts.grid_3d) {
|
||||
VSLAM_WARN("slam: camera_3d=true nhung DB nay duoc quet voi Grid/3D=false "
|
||||
"-- ban do voxel se chi co MOT lop ngang o cao do LiDAR. Quet "
|
||||
"lai vao DB moi neu can ban do 3D that.");
|
||||
}
|
||||
if (facts.exists && facts.optimizer_strategy != cfg.optimizer_strategy) {
|
||||
// ⚠️ Canh bao duoi day hoi `nodes > 0`, khong chi `exists`.
|
||||
//
|
||||
// `facts.exists` nghia la MO DUOC, khong phai CO BAN DO: sqlite tao file
|
||||
// ngay khi `InspectDatabase` mo no, nen mot duong dan moi tinh cung ra
|
||||
// exists=true voi nodes=0 va moi tham so rong. Chi kiem `exists` thi moi lan
|
||||
// quet moi deu keu "DB nay quet voi Grid/3D=false" va "DB luu
|
||||
// Optimizer/Strategy=" (gia tri rong) -- do dung la cai da in ra o lan chay
|
||||
// dau tien cua ban do 3D.
|
||||
if (facts.nodes > 0 && facts.optimizer_strategy != cfg.optimizer_strategy) {
|
||||
VSLAM_WARN("slam: DB luu Optimizer/Strategy=" << facts.optimizer_strategy
|
||||
<< ", dang ep ve " << cfg.optimizer_strategy
|
||||
<< " (loadDatabaseParameters=false)");
|
||||
@@ -264,7 +270,10 @@ SlamOutput RtabmapSlam::Process(const SlamInput& in) {
|
||||
const auto t0 = std::chrono::steady_clock::now();
|
||||
|
||||
rtabmap::SensorData data =
|
||||
BuildSensorData(in, impl_->laser_to_base, impl_->camera_to_base, impl_->next_id++);
|
||||
BuildSensorData(in, impl_->laser_to_base,
|
||||
in.camera_to_base != nullptr ? *in.camera_to_base
|
||||
: impl_->camera_to_base,
|
||||
impl_->next_id++);
|
||||
|
||||
bool ok = false;
|
||||
try {
|
||||
@@ -352,7 +361,7 @@ StatusResponse RtabmapSlam::ExportVoxels(const VoxelExportOptions& opt,
|
||||
if (!impl_->inited) {
|
||||
return StatusResponse::Error(StatusCode::kFailedPrecondition, "chua init");
|
||||
}
|
||||
return ExportVoxelGrid(impl_->rtabmap, opt, out);
|
||||
return ExportVoxelGrid(impl_->rtabmap, opt, &impl_->voxel_cache, out);
|
||||
}
|
||||
|
||||
StatusResponse RtabmapSlam::Close(bool save_database) {
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
#include <rtabmap/core/Rtabmap.h>
|
||||
#include <rtabmap/core/SensorData.h>
|
||||
#include <rtabmap/core/Transform.h>
|
||||
#include <rtabmap/core/util3d.h>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "vslam/log.h"
|
||||
#include "vslam/node_constants.h"
|
||||
@@ -113,12 +116,27 @@ void VoxelAccumulator::Finish(VoxelGrid* out) {
|
||||
out->origin_y = 0.0;
|
||||
out->origin_z = 0.0;
|
||||
out->header.frame_id = kMapFrame;
|
||||
out->truncated = acc_.size() > opt_.max_cells;
|
||||
|
||||
const size_t n = std::min(acc_.size(), opt_.max_cells);
|
||||
// ⚠️ Cham tran thi GIAM MAU DEU, tuyet doi khong cat cut danh sach.
|
||||
//
|
||||
// `acc_` sort theo khoa goi, ma khoa goi sort theo x truoc -- nen lay
|
||||
// `max_cells` phan tu DAU la chat mot lat khong gian: nguyen mot canh cua
|
||||
// toa nha bien mat khoi ban do trong khi phan con lai van day du. Da mac
|
||||
// dung loi nay: nguoi dung bao "goc tren ben trai quet roi ma gio mat".
|
||||
//
|
||||
// Giam mau deu thi ban do GIU NGUYEN hinh dang, chi thua di. Cung khuon mau
|
||||
// ma EncodeCloud dung cho `cloud_max_points` (binary_codec.cc) -- buoc deu,
|
||||
// khong cat duoi.
|
||||
const size_t total = acc_.size();
|
||||
stride_ = 1;
|
||||
if (opt_.max_cells > 0 && total > opt_.max_cells) {
|
||||
stride_ = (total + opt_.max_cells - 1) / opt_.max_cells;
|
||||
}
|
||||
out->truncated = stride_ > 1;
|
||||
|
||||
out->cells.clear();
|
||||
out->cells.reserve(n);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
out->cells.reserve(total / stride_ + 1);
|
||||
for (size_t i = 0; i < total; i += stride_) {
|
||||
int32_t x = 0, y = 0, z = 0;
|
||||
UnpackKey(acc_[i], &x, &y, &z);
|
||||
VoxelIndex k;
|
||||
@@ -154,8 +172,33 @@ void DiffVoxelGrids(const std::vector<VoxelIndex>& prev,
|
||||
for (; j < now.size(); ++j) added->push_back(now[j]);
|
||||
}
|
||||
|
||||
void NodeCloudFromSensorData(const rtabmap::SensorData& data,
|
||||
const VoxelExportOptions& opt,
|
||||
std::vector<float>* out) {
|
||||
out->clear();
|
||||
if (data.depthOrRightRaw().empty() || data.cameraModels().empty()) return;
|
||||
// cloudFromSensorData ap localTransform cua camera (base <- optical), nen
|
||||
// diem ra o frame base cua node -- cung frame voi pose cua no.
|
||||
const auto cloud = rtabmap::util3d::cloudFromSensorData(
|
||||
data, opt.depth_decimation, static_cast<float>(opt.depth_max_m),
|
||||
static_cast<float>(opt.depth_min_m));
|
||||
if (!cloud) return;
|
||||
VoxelAccumulator acc(opt);
|
||||
for (const auto& p : cloud->points) acc.AddPoint(p.x, p.y, p.z);
|
||||
VoxelGrid vg;
|
||||
acc.Finish(&vg);
|
||||
const double s = opt.emit_size_m;
|
||||
out->reserve(vg.cells.size() * 3);
|
||||
for (const VoxelIndex& k : vg.cells) {
|
||||
out->push_back(static_cast<float>((k.x + 0.5) * s));
|
||||
out->push_back(static_cast<float>((k.y + 0.5) * s));
|
||||
out->push_back(static_cast<float>((k.z + 0.5) * s));
|
||||
}
|
||||
}
|
||||
|
||||
StatusResponse ExportVoxelGrid(rtabmap::Rtabmap& slam,
|
||||
const VoxelExportOptions& opt, VoxelGrid* out) {
|
||||
const VoxelExportOptions& opt,
|
||||
VoxelNodeCache* cache, VoxelGrid* out) {
|
||||
const std::map<int, rtabmap::Transform>& poses = slam.getLocalOptimizedPoses();
|
||||
if (poses.empty()) {
|
||||
return StatusResponse::Error(StatusCode::kFailedPrecondition,
|
||||
@@ -167,35 +210,37 @@ StatusResponse ExportVoxelGrid(rtabmap::Rtabmap& slam,
|
||||
"rtabmap chua co Memory");
|
||||
}
|
||||
|
||||
// Bo node khong con trong do thi (bi gop/xoa) -- khong thi cache phinh mai.
|
||||
for (auto it = cache->nodes.begin(); it != cache->nodes.end();) {
|
||||
it = poses.count(it->first) ? std::next(it) : cache->nodes.erase(it);
|
||||
}
|
||||
|
||||
VoxelAccumulator acc(opt);
|
||||
size_t nodes_with_grid = 0;
|
||||
int channels_seen = 0;
|
||||
size_t nodes_used = 0, fetched = 0, pending = 0, no_points = 0;
|
||||
|
||||
for (const auto& kv : poses) {
|
||||
if (kv.second.isNull()) continue;
|
||||
rtabmap::SensorData data = mem->getNodeData(kv.first, false, false, false, true);
|
||||
// ⚠️ BAT BUOC. Thieu dong nay thi gridObstacleCellsRaw() tra ma tran RONG
|
||||
// o moi node va ban do 3D im lang rong khong.
|
||||
data.uncompressData();
|
||||
if (data.gridCellSize() <= 0.0f) continue;
|
||||
|
||||
const cv::Mat& obs = data.gridObstacleCellsRaw();
|
||||
if (obs.empty()) continue;
|
||||
if (obs.depth() != CV_32F) {
|
||||
return StatusResponse::Error(
|
||||
StatusCode::kInternal,
|
||||
"o luoi cuc bo khong phai float32 (depth=" +
|
||||
std::to_string(obs.depth()) + ") -- phien ban RTAB-Map la");
|
||||
auto it = cache->nodes.find(kv.first);
|
||||
if (it == cache->nodes.end()) {
|
||||
if (fetched >= opt.max_new_nodes) {
|
||||
++pending;
|
||||
continue;
|
||||
}
|
||||
++fetched;
|
||||
// images=true, con lai false: chi can depth + camera model.
|
||||
rtabmap::SensorData data = mem->getNodeData(kv.first, true, false, false, false);
|
||||
// ⚠️ BAT BUOC. Thieu dong nay thi depthOrRightRaw() tra ma tran RONG o
|
||||
// moi node va ban do 3D im lang rong khong.
|
||||
data.uncompressData();
|
||||
std::vector<float> pts;
|
||||
NodeCloudFromSensorData(data, opt, &pts);
|
||||
it = cache->nodes.emplace(kv.first, std::move(pts)).first;
|
||||
}
|
||||
|
||||
const int ch = obs.channels();
|
||||
if (ch < 2) {
|
||||
return StatusResponse::Error(
|
||||
StatusCode::kInternal,
|
||||
"o luoi cuc bo co " + std::to_string(ch) +
|
||||
" kenh, cho doi 2 (XY) hoac 3/4 (XYZ[+RGB])");
|
||||
const std::vector<float>& pts = it->second;
|
||||
if (pts.empty()) {
|
||||
++no_points;
|
||||
continue;
|
||||
}
|
||||
if (channels_seen == 0) channels_seen = ch;
|
||||
|
||||
// Pose da toi uu: node -> map. Dung ma tran 3x4 dung san, 12 phep nhan
|
||||
// cho moi diem, thay vi dung mot rtabmap::Transform cho tung diem.
|
||||
@@ -204,37 +249,34 @@ StatusResponse ExportVoxelGrid(rtabmap::Rtabmap& slam,
|
||||
const float r10 = T.r21(), r11 = T.r22(), r12 = T.r23(), ty = T.y();
|
||||
const float r20 = T.r31(), r21 = T.r32(), r22 = T.r33(), tz = T.z();
|
||||
|
||||
const int n = obs.cols * obs.rows;
|
||||
const float* p = obs.ptr<float>();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const float px = p[0];
|
||||
const float py = p[1];
|
||||
// 2 kenh = luoi PHANG (DB quet voi Grid/3D=false). Van ve duoc, chi la
|
||||
// ra mot lop ngang -- Init() da canh bao truong hop nay.
|
||||
const float pz = (ch >= 3) ? p[2] : 0.0f;
|
||||
p += ch;
|
||||
|
||||
for (size_t i = 0; i + 2 < pts.size(); i += 3) {
|
||||
const float px = pts[i], py = pts[i + 1], pz = pts[i + 2];
|
||||
acc.AddPoint(r00 * px + r01 * py + r02 * pz + tx,
|
||||
r10 * px + r11 * py + r12 * pz + ty,
|
||||
r20 * px + r21 * py + r22 * pz + tz);
|
||||
}
|
||||
++nodes_with_grid;
|
||||
++nodes_used;
|
||||
}
|
||||
|
||||
if (nodes_with_grid == 0) {
|
||||
if (nodes_used == 0) {
|
||||
return StatusResponse::Error(
|
||||
StatusCode::kFailedPrecondition,
|
||||
"khong node nao co luoi cuc bo -- RGBD/CreateOccupancyGrid tat, hoac "
|
||||
"DB quet truoc khi bat camera_3d");
|
||||
pending > 0 ? "dang nap depth cua node"
|
||||
: "khong node nao co depth -- DB quet voi camera_3d=false, "
|
||||
"hoac khong co camera");
|
||||
}
|
||||
|
||||
acc.Finish(out);
|
||||
|
||||
// Mot dong, mot lan moi 30 giay: so kenh la thu duy nhat trong ca duong nay
|
||||
// khong doc duoc tu header RTAB-Map, nen no phai hien ra o log that.
|
||||
// Mot dong, mot lan moi 30 giay. `khong co diem` cao bat thuong nghia la
|
||||
// getNodeData khong tra depth -- thu dau tien can nhin khi ban do 3D rong.
|
||||
VSLAM_INFO_THROTTLE(30.0, "slam: voxel " << out->cells.size() << " o tu "
|
||||
<< nodes_with_grid << " node (" << channels_seen
|
||||
<< " kenh/o" << (out->truncated ? ", DA CAT BOT" : "")
|
||||
<< nodes_used << " node (dang nap " << pending << ", "
|
||||
<< no_points << " node khong co diem"
|
||||
<< (out->truncated
|
||||
? ", GIAM MAU 1/" + std::to_string(acc.stride()) +
|
||||
" -- cham tran max_cells"
|
||||
: std::string())
|
||||
<< ")");
|
||||
if (acc.clamped() > 0) {
|
||||
VSLAM_WARN_THROTTLE(30.0, "slam: " << acc.clamped()
|
||||
|
||||
@@ -46,7 +46,7 @@ struct SlamSnapshot {
|
||||
uint32_t map_version = 0;
|
||||
double process_ms = 0.0;
|
||||
|
||||
// Ban do voxel 3D den tu dau: "scan+depth" | "scan" | "off".
|
||||
// Ban do voxel 3D den tu dau: "depth" | "thieu depth" | "off".
|
||||
// Hien trong JSON status de mot ban do 3D RONG doc duoc ma khong phai mo
|
||||
// khung 3D len xem -- cung ly do voi dong dem o/trong/chua-biet cua luoi 2D.
|
||||
std::string voxels_source = "off";
|
||||
|
||||
@@ -12,7 +12,7 @@ const MAGIC = 0x314C5356; // 'VSL1' little-endian
|
||||
// Phien ban ma nguon giao dien. TANG khi doi app.js / app3d.js / style.css.
|
||||
// Hien ngay tren thanh tren cung de phan biet "chua sua" voi "trinh duyet con
|
||||
// cache ban cu".
|
||||
const UI_VERSION = '2026-09-23a';
|
||||
const UI_VERSION = '2026-09-23d';
|
||||
|
||||
// ⚠️ HAI bang mau, mot cho moi khung. Chung KHONG duoc giong nhau.
|
||||
//
|
||||
@@ -722,6 +722,16 @@ function updateSlamLabel() {
|
||||
labR.textContent = 'SLAM TAT -- chay lai voi --slam';
|
||||
return;
|
||||
}
|
||||
// Che do 3D|3D: khung phai la DAM MAY, khong phai luoi 2D -- dem o cua dam
|
||||
// may moi la con so noi len no dang dung toi dau.
|
||||
if (split3d) {
|
||||
const v = state.voxels;
|
||||
labR.textContent = v && v.set.size
|
||||
? 'SLAM 3D ' + v.set.size.toLocaleString() + ' o @ ' + v.res.toFixed(2) + ' m' +
|
||||
(v.syncing ? ' (dang tai...)' : '')
|
||||
: 'SLAM 3D (chua co diem -- can camera_3d: true va lai them)';
|
||||
return;
|
||||
}
|
||||
const m = state.map;
|
||||
labR.textContent = m
|
||||
? 'SLAM ' + state.slamMode + ' ' + (m.w * m.res).toFixed(1) + ' x ' +
|
||||
@@ -747,6 +757,10 @@ function draw() {
|
||||
updateSlamLabel();
|
||||
drawScene(cvR, ctxR, state.map, state.mapImage, state.pose, true, 'lyMap',
|
||||
PALETTE.slam);
|
||||
} else if (split3d) {
|
||||
// Khong co canvas thu hai o che do nay: draw3d() da ve ca hai nua. Chi
|
||||
// con cap nhat nhan.
|
||||
updateSlamLabel();
|
||||
}
|
||||
requestAnimationFrame(draw);
|
||||
return;
|
||||
@@ -1030,23 +1044,51 @@ connect();
|
||||
const btnSplit = document.getElementById('btnSplit');
|
||||
const labR = document.getElementById('labR');
|
||||
const wrap = document.querySelector('.canvas-wrap');
|
||||
// Hai co, KHONG phai mot: chung la hai LAYOUT khac han nhau.
|
||||
// split -> khung phai la canvas 2D that (#mainR)
|
||||
// split3d -> mot canvas 3D duy nhat, tu cat lam doi bang scissor
|
||||
let split = false;
|
||||
let split3d = false;
|
||||
|
||||
function applySplitMode() {
|
||||
wrap.classList.toggle('split', split);
|
||||
wrap.classList.toggle('split3d', split3d);
|
||||
const chia = split || split3d;
|
||||
document.getElementById('labL').style.display = chia ? '' : 'none';
|
||||
labR.style.display = chia ? '' : 'none';
|
||||
btnSplit.textContent = split ? 'chia doi 3D' : (split3d ? 'mot khung' : 'chia doi');
|
||||
btnSplit.title = split
|
||||
? 'Bam nua: khung phai thanh DAM MAY 3D do SLAM quet ra'
|
||||
: (split3d ? 'Bam nua: ve mot khung'
|
||||
: 'Hai khung: THE GIOI (de lai) va SLAM (de xem ban do dang dung)');
|
||||
}
|
||||
|
||||
// Nut xoay vong BA kieu thay vi bat/tat:
|
||||
// tat -> the gioi | ban do 2D -> the gioi | dam may 3D -> tat
|
||||
//
|
||||
// Kieu thu hai giu nguyen vi code cu goi no la "to hop huu ich nhat khi dang
|
||||
// quet". Kieu thu ba la de NHIN ban do 3D dung len theo thoi gian thuc, canh
|
||||
// chinh cai the gioi that -- do la cau hoi khac: khong phai "quet toi dau" ma
|
||||
// "quet ra co giong that khong".
|
||||
btnSplit.addEventListener('click', () => {
|
||||
if (!state.worldMap) {
|
||||
// Khong co su that de doi chieu -- chay that, khong phai mo phong.
|
||||
btnSplit.textContent = 'khong co su that';
|
||||
setTimeout(() => { btnSplit.textContent = 'chia doi'; }, 1800);
|
||||
setTimeout(applySplitMode, 1800);
|
||||
return;
|
||||
}
|
||||
split = !split;
|
||||
wrap.classList.toggle('split', split);
|
||||
document.getElementById('labL').style.display = split ? '' : 'none';
|
||||
labR.style.display = split ? '' : 'none';
|
||||
btnSplit.textContent = split ? 'mot khung' : 'chia doi';
|
||||
// 3D va chia doi KHONG loai tru nhau: `.split.three` cho ra
|
||||
// trai = the gioi 3D (Gazebo) | phai = ban do SLAM 2D (RViz)
|
||||
// -- dung to hop huu ich nhat khi dang quet.
|
||||
if (!split && !split3d) {
|
||||
split = true;
|
||||
} else if (split) {
|
||||
split = false;
|
||||
split3d = true;
|
||||
// Kieu nay VO NGHIA o 2D. Tu bat 3D thay vi de nguoi dung bam mot nut
|
||||
// khong lam gi ca -- dung cach cac nut goc nhin dang lam.
|
||||
setThreeD(true);
|
||||
} else {
|
||||
split3d = false;
|
||||
}
|
||||
applySplitMode();
|
||||
});
|
||||
|
||||
{
|
||||
@@ -1104,6 +1146,14 @@ function setThreeD(on) {
|
||||
// stylesheet -- dung cai bay da lam khung phai den xi mot lan.
|
||||
wrap.classList.toggle('three', use3d);
|
||||
btn3d.textContent = use3d ? '2D' : '3D';
|
||||
// Tat 3D thi kieu chia doi 3D|3D khong con cho dua: canvas 3D ngung duoc ve
|
||||
// nhung CSS van cho no hien, nen man hinh se dong bang o khung hinh cuoi
|
||||
// cung. Roi ve kieu chia doi thuong.
|
||||
if (!use3d && split3d) {
|
||||
split3d = false;
|
||||
split = true;
|
||||
applySplitMode();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1184,10 +1234,10 @@ function draw3d() {
|
||||
|
||||
// SLAM: lop phu tren san, hien DAN khi quet -- day la phan "RViz". O chua
|
||||
// quet trong suot nen tuong 3D van nhin xuyen qua.
|
||||
// VOXEL: "cai gi dung tren san", bu cho tam phang cua v3dSetMap ("da quet
|
||||
// toi dau"). Hai lop khong tranh nhau: tam phang o y = -0.002, voxel bat
|
||||
// dau tu z_min = 0.05.
|
||||
v3dSetVoxels(state.voxels, on('lyVoxel'));
|
||||
// Dam may DA QUET: nhung gi camera nhin thay, giu lai va nan theo pose toi
|
||||
// uu. Bu cho tam phang cua v3dSetMap ("da quet toi dau"); hai lop khong
|
||||
// tranh nhau vi tam phang o y = -0.002 con dam may bat dau tu z_min = 0.05.
|
||||
v3dSetMapCloud(state.voxels, on('lyMapCloud'));
|
||||
|
||||
if (state.map && on('lyMap')) {
|
||||
v3dSetMap({ ...state.map, data: state.map.cells, version: state.mapVersion });
|
||||
@@ -1196,7 +1246,7 @@ function draw3d() {
|
||||
if (on('lyPath')) v3dSetPath(state.path);
|
||||
else if (V3D.pathLine) V3D.pathLine.visible = false;
|
||||
|
||||
v3dRender(cv3d, on('lyFollow'));
|
||||
v3dRender(cv3d, on('lyFollow'), split3d);
|
||||
}
|
||||
|
||||
requestAnimationFrame(draw);
|
||||
|
||||
@@ -24,7 +24,7 @@ const V3D = {
|
||||
ready: false,
|
||||
scene: null, camera: null, renderer: null, root: null,
|
||||
robotGroup: null, scanPts: null, cloudPts: null, mapMesh: null,
|
||||
voxelMesh: null, voxelCap: 0, voxelEpoch: -1,
|
||||
mapCloud: null, mapCloudCap: 0, mapCloudRes: 0,
|
||||
worldMesh: null, worldKey: null,
|
||||
meshWorld: null, // nhom mesh THAT doc tu .world; co thi khong dung khoi hop
|
||||
gtGroup: null, pathLine: null,
|
||||
@@ -497,91 +497,98 @@ function v3dSetCloud(arr, pose) {
|
||||
V3D.cloudPts.geometry.setAttribute('color', new THREE.BufferAttribute(col, 3));
|
||||
}
|
||||
|
||||
// --- Ban do voxel 3D -------------------------------------------------------
|
||||
// --- Ban do 3D da quet (dam may diem tich luy) -----------------------------
|
||||
//
|
||||
// Nguon: SLAM, khong phai bo mo phong. Day la "cai gi dung tren san" do chinh
|
||||
// robot do duoc, bu cho tam phang cua v3dSetMap ("da quet toi dau").
|
||||
// Nguon: SLAM, khong phai bo mo phong. Day la nhung gi CHINH CON ROBOT quet
|
||||
// duoc, giu lai va nan theo pose da toi uu -- phan "RViz" that su, bu cho tam
|
||||
// phang cua v3dSetMap ("da quet toi dau").
|
||||
//
|
||||
// Ba cho CO Y khac v3dSetWorld va v3dSetCloud, moi cho vi mot ly do:
|
||||
// VE BANG DIEM, khong phai bang hop. Du lieu ben duoi van la tap voxel (do la
|
||||
// cach khu trung lap va giu bang thong), nhung mot khoi hop 5-10 cm nhin ra
|
||||
// Minecraft chu khong ra mot ban quet. Diem cho dung cam giac cua dam may
|
||||
// camera, va dung bang mau voi lop cloud truc tiep nen hai thu doc nhu mot.
|
||||
//
|
||||
// 1. Dung lai theo NOI DUNG (`v.dirty`), khong theo kich thuoc. v3dSetWorld
|
||||
// cache theo `w x h @ ox,oy` -- dung cho mot ban do TINH, sai hoan toan o
|
||||
// day vi tap voxel doi lien tuc trong khi bao ngoai dung yen.
|
||||
// Ba cho CO Y khac v3dSetCloud (dam may TRUC TIEP, mot khung):
|
||||
//
|
||||
// 2. KHONG dispose/dung lai hinh moi khung nhu v3dSetCloud. InstancedMesh co
|
||||
// so luong co dinh, nen cap phat du `capacity` roi chi doi `count`. O
|
||||
// 100k the thi kieu cua cloud khong song noi.
|
||||
// 1. Dung lai theo NOI DUNG (`v.dirty`), khong phai moi khung. Tap nay doi
|
||||
// toi da ~4 lan/giay chu khong 8-10, va no to gap tram lan.
|
||||
//
|
||||
// 3. KHONG do bong. v3dSetWorld bat ca castShadow lan receiveShadow; nem
|
||||
// 100k the vao shadow map 2048^2 la mat frame rate. Dung "sua" lai.
|
||||
function v3dSetVoxels(v, visible) {
|
||||
// 2. Cap phat theo CAPACITY roi dung setDrawRange, khong dispose/dung lai
|
||||
// BufferGeometry moi lan. v3dSetCloud lam vay voi 2000 diem thi khong sao;
|
||||
// o 100k diem do la 1.2 MB rac moi lan cap nhat.
|
||||
//
|
||||
// 3. Toa do la TUYET DOI trong frame map -- khong nhan pose. Dam may truc
|
||||
// tiep nam o base_footprint nen phai xoay theo robot; tap nay da o he ban
|
||||
// do tu luc xuat.
|
||||
function v3dSetMapCloud(v, visible) {
|
||||
if (!V3D.ready) return;
|
||||
if (!v || !visible || v.set.size === 0) {
|
||||
if (V3D.voxelMesh) V3D.voxelMesh.visible = false;
|
||||
if (V3D.mapCloud) V3D.mapCloud.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const n = v.set.size;
|
||||
const needNew = !V3D.voxelMesh || n > V3D.voxelCap ||
|
||||
(V3D.voxelMesh && V3D.voxelRes !== v.res);
|
||||
const needNew = !V3D.mapCloud || n > V3D.mapCloudCap || V3D.mapCloudRes !== v.res;
|
||||
if (needNew) {
|
||||
if (V3D.voxelMesh) {
|
||||
V3D.root.remove(V3D.voxelMesh);
|
||||
V3D.voxelMesh.geometry.dispose();
|
||||
V3D.voxelMesh.material.dispose();
|
||||
if (V3D.mapCloud) {
|
||||
V3D.root.remove(V3D.mapCloud);
|
||||
V3D.mapCloud.geometry.dispose();
|
||||
V3D.mapCloud.material.dispose();
|
||||
}
|
||||
// Cap phat du de lon them mot doan ma khong phai cap phat lai moi khung.
|
||||
let cap = 1024;
|
||||
let cap = 4096;
|
||||
while (cap < Math.ceil(n * 1.5)) cap *= 2;
|
||||
const geo = new THREE.BoxGeometry(v.res, v.res, v.res);
|
||||
const mat = new THREE.MeshStandardMaterial({ roughness: 0.9, metalness: 0.0 });
|
||||
V3D.voxelMesh = new THREE.InstancedMesh(geo, mat, cap);
|
||||
// Bounding sphere cua InstancedMesh lay tu hinh GOC (mot hop 0.1 m), nen
|
||||
// de mac dinh thi three.js cull ca ban do ngay khi goc toa do ra khoi khung.
|
||||
V3D.voxelMesh.frustumCulled = false;
|
||||
V3D.voxelMesh.castShadow = false;
|
||||
V3D.voxelMesh.receiveShadow = false;
|
||||
V3D.voxelCap = cap;
|
||||
V3D.voxelRes = v.res;
|
||||
V3D.root.add(V3D.voxelMesh);
|
||||
v.dirty = true; // hinh moi -> phai do lai du lieu
|
||||
const geo = new THREE.BufferGeometry();
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(cap * 3), 3));
|
||||
geo.setAttribute('color', new THREE.BufferAttribute(new Float32Array(cap * 3), 3));
|
||||
// Co diem theo do phan giai: o 0.05 m thi 0.04 cho ra mot mat lien chu
|
||||
// khong phai mot ram cham roi rac.
|
||||
const mat = new THREE.PointsMaterial({ size: v.res * 0.8, vertexColors: true });
|
||||
V3D.mapCloud = new THREE.Points(geo, mat);
|
||||
// Bounding sphere tinh tu capacity con thua (toan so 0 o goc), nen cull se
|
||||
// sai. Tap nay trai ca toa nha, cull no khong tiet kiem duoc gi.
|
||||
V3D.mapCloud.frustumCulled = false;
|
||||
V3D.mapCloudCap = cap;
|
||||
V3D.mapCloudRes = v.res;
|
||||
V3D.root.add(V3D.mapCloud);
|
||||
v.dirty = true; // bo dem moi -> phai do lai
|
||||
}
|
||||
|
||||
V3D.voxelMesh.visible = true;
|
||||
V3D.mapCloud.visible = true;
|
||||
if (!v.dirty) return;
|
||||
v.dirty = false;
|
||||
|
||||
const m4 = new THREE.Matrix4();
|
||||
const col = new THREE.Color();
|
||||
const pos = V3D.mapCloud.geometry.attributes.position.array;
|
||||
const col = V3D.mapCloud.geometry.attributes.color.array;
|
||||
const half = v.res * 0.5;
|
||||
let i = 0;
|
||||
for (const key of v.set) {
|
||||
// Giai khoa tai cho: goi voxelUnpack() 100k lan moi lan dung lai la
|
||||
// 100k mang tam.
|
||||
// Giai khoa TAI CHO: goi voxelUnpack() 100k lan la 100k mang tam.
|
||||
const z = (key % 65536) - 32768;
|
||||
const k1 = (key - (z + 32768)) / 65536;
|
||||
const y = (k1 % 65536) - 32768;
|
||||
const x = (k1 - (y + 32768)) / 65536 - 32768;
|
||||
|
||||
// Tam o, khong phai goc o. ROS (x, y, z) -> three (x, z, -y) -- giong
|
||||
// toScene(), nhung noi thang vao day: toScene() cap phat mot Vector3 moi
|
||||
// lan goi, va 100k lan cap phat moi lan dung lai la mot con bao GC.
|
||||
// Tam o. ROS (x, y, z) -> three (x, z, -y), noi thang thay vi goi
|
||||
// toScene(): ham do cap phat mot Vector3 moi lan.
|
||||
const wx = v.ox + x * v.res + half;
|
||||
const wy = v.oy + y * v.res + half;
|
||||
const wz = v.oz + z * v.res + half;
|
||||
m4.makeTranslation(wx, wz, -wy);
|
||||
V3D.voxelMesh.setMatrixAt(i, m4);
|
||||
const b = i * 3;
|
||||
pos[b] = wx;
|
||||
pos[b + 1] = wz;
|
||||
pos[b + 2] = -wy;
|
||||
|
||||
// Cung thang mau voi point cloud, gian ra toi 2 m: hai lop phai doc nhu
|
||||
// mot he, khong phai hai he mau canh nhau.
|
||||
// Cung thang mau voi lop cloud truc tiep (v3dSetCloud), gian ra toi 2 m.
|
||||
const t = Math.max(0, Math.min(1, wz / 2.0));
|
||||
col.setRGB((80 + 175 * t) / 255, (200 - 90 * t) / 255, (120 + 60 * t) / 255);
|
||||
V3D.voxelMesh.setColorAt(i, col);
|
||||
col[b] = (80 + 175 * t) / 255;
|
||||
col[b + 1] = (200 - 90 * t) / 255;
|
||||
col[b + 2] = (120 + 60 * t) / 255;
|
||||
++i;
|
||||
}
|
||||
V3D.voxelMesh.count = i;
|
||||
V3D.voxelMesh.instanceMatrix.needsUpdate = true;
|
||||
if (V3D.voxelMesh.instanceColor) V3D.voxelMesh.instanceColor.needsUpdate = true;
|
||||
|
||||
V3D.mapCloud.geometry.setDrawRange(0, i);
|
||||
V3D.mapCloud.geometry.attributes.position.needsUpdate = true;
|
||||
V3D.mapCloud.geometry.attributes.color.needsUpdate = true;
|
||||
}
|
||||
|
||||
// The gioi 3D: o BI CHIEM -> hop, dung nhu Gazebo dung tuong tu ban do.
|
||||
@@ -939,12 +946,27 @@ function v3dSetOverlays(on) {
|
||||
});
|
||||
}
|
||||
|
||||
function v3dRender(canvas, follow) {
|
||||
// `splitSlam` = ve HAI viewport trong cung mot canvas:
|
||||
// trai = canh nhu dang co (the gioi + moi thu, theo lop nguoi dung chon)
|
||||
// phai = CHI nhung gi SLAM dung ra (the gioi bi ep an)
|
||||
//
|
||||
// Mot renderer, hai lan render, cat bang scissor -- KHONG mo WebGLRenderer thu
|
||||
// hai. Hai GL context tren cung mot trang la gap doi bo nho texture va mot
|
||||
// nguon loi "context lost" kinh dien tren Jetson.
|
||||
//
|
||||
// Camera dung CHUNG co y: hai khung cung goc nhin thi moi doi chieu duoc "ngoai
|
||||
// doi cho nay co cai ban, SLAM quet ra gi". Lech goc la mat ca y nghia.
|
||||
function v3dRender(canvas, follow, splitSlam) {
|
||||
if (!V3D.ready) return;
|
||||
const w = canvas.clientWidth, h = canvas.clientHeight;
|
||||
if (canvas.width !== w || canvas.height !== h) {
|
||||
V3D.renderer.setSize(w, h, false);
|
||||
V3D.camera.aspect = w / Math.max(1, h);
|
||||
}
|
||||
// Ti le khung hinh tinh theo NUA chieu rong khi chia doi, khong thi hinh bi
|
||||
// keo ngang o ca hai ben.
|
||||
const aspect = (splitSlam ? w / 2 : w) / Math.max(1, h);
|
||||
if (V3D.camera.aspect !== aspect) {
|
||||
V3D.camera.aspect = aspect;
|
||||
V3D.camera.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
@@ -960,5 +982,50 @@ function v3dRender(canvas, follow) {
|
||||
o.dist * Math.sin(o.el),
|
||||
cz + o.dist * Math.cos(o.el) * Math.sin(o.az));
|
||||
V3D.camera.lookAt(cx, 0.2, cz);
|
||||
V3D.renderer.render(V3D.scene, V3D.camera);
|
||||
|
||||
const r = V3D.renderer;
|
||||
if (!splitSlam) {
|
||||
r.setScissorTest(false);
|
||||
r.setViewport(0, 0, w, h);
|
||||
r.render(V3D.scene, V3D.camera);
|
||||
return;
|
||||
}
|
||||
|
||||
const half = Math.floor(w / 2);
|
||||
r.setScissorTest(true);
|
||||
|
||||
// Hai nua an hai thu KHAC NHAU, va phep an nay chi la MOT CHIEU: no tat bot,
|
||||
// khong bao gio bat len. Nguoi dung tick lop nao thi lop do moi co cua de
|
||||
// hien -- khong dung v3dSetWorldVisible()/visible=true o day, vi mot cai
|
||||
// `= true` se lam nut tick tren thanh cong cu thanh noi doi.
|
||||
const hide = (list) => {
|
||||
const hid = [];
|
||||
for (const o of list) {
|
||||
if (o && o.visible) { o.visible = false; hid.push(o); }
|
||||
}
|
||||
return hid;
|
||||
};
|
||||
const show = (hid) => { for (const o of hid) o.visible = true; };
|
||||
|
||||
// --- Nua TRAI: THE GIOI, khong co dau ra cua SLAM ---
|
||||
//
|
||||
// Dam may da quet va tam ban do SLAM deu bi tat o day. Chung la thu SLAM
|
||||
// DUNG RA; de chung chong len su that thi khung trai het tra loi duoc cau
|
||||
// hoi cua no ("ngoai doi cho nay co gi"), va bat lop `cloud da quet` se thay
|
||||
// no sang o CA HAI ben -- dung cai da bi bao la sai.
|
||||
let hid = hide([V3D.mapCloud, V3D.mapMesh]);
|
||||
r.setViewport(0, 0, half, h);
|
||||
r.setScissor(0, 0, half, h);
|
||||
r.render(V3D.scene, V3D.camera);
|
||||
show(hid);
|
||||
|
||||
// --- Nua PHAI: chi SLAM, khong co the gioi ---
|
||||
hid = hide([V3D.meshWorld, V3D.worldMesh]);
|
||||
r.setViewport(half, 0, w - half, h);
|
||||
r.setScissor(half, 0, w - half, h);
|
||||
r.render(V3D.scene, V3D.camera);
|
||||
show(hid);
|
||||
|
||||
r.setScissorTest(false);
|
||||
r.setViewport(0, 0, w, h);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
<div class="layers">
|
||||
<label><input type="checkbox" id="lyWorld" checked> the gioi</label>
|
||||
<label><input type="checkbox" id="lyMap" checked> map SLAM</label>
|
||||
<!-- Ban do voxel 3D. TAT mac dinh: no chi co du lieu khi slam.yaml dat
|
||||
camera_3d: true, va bat san se lam nguoi dung tuong tinh nang hong
|
||||
trong khi that ra no dang tat o cau hinh. -->
|
||||
<label><input type="checkbox" id="lyVoxel"> voxel 3D</label>
|
||||
<!-- Dam may DA QUET (tich luy, nan theo pose toi uu) -- khac lop `cloud`
|
||||
ben duoi von chi la MOT khung truc tiep. TAT mac dinh: no chi co du
|
||||
lieu khi slam.yaml dat camera_3d: true, va bat san se lam nguoi dung
|
||||
tuong tinh nang hong trong khi that ra no dang tat o cau hinh. -->
|
||||
<label><input type="checkbox" id="lyMapCloud"> cloud da quet</label>
|
||||
<label><input type="checkbox" id="lyScan" checked> scan</label>
|
||||
<label><input type="checkbox" id="lyCloud" checked> cloud</label>
|
||||
<label><input type="checkbox" id="lyPath" checked> path</label>
|
||||
|
||||
@@ -152,7 +152,9 @@ button.danger:hover { background: var(--bad); color: #fff; }
|
||||
(khong gi) : #main -- 2D mot khung
|
||||
.three : #main3d -- 3D mot khung
|
||||
.split : #main | #mainR -- 2D | 2D
|
||||
.split.three : #main3d | #mainR -- 3D (Gazebo) | 2D SLAM (RViz) */
|
||||
.split.three : #main3d | #mainR -- 3D (Gazebo) | 2D SLAM (RViz)
|
||||
.split3d : #main3d mot minh, tu cat lam doi bang scissor
|
||||
-- 3D the gioi | 3D dam may SLAM */
|
||||
#mainR, #main3d { display: none; }
|
||||
.canvas-wrap.three #main { display: none; }
|
||||
.canvas-wrap.three #main3d { display: block; }
|
||||
@@ -162,6 +164,17 @@ button.danger:hover { background: var(--bad); color: #fff; }
|
||||
.canvas-wrap.split #mainR { display: block; position: absolute;
|
||||
right: 0; top: 0; width: 50%; height: 100%;
|
||||
border-left: 1px solid #2a3442; }
|
||||
/* Chia doi 3D|3D: KHONG co canvas thu hai. `#main3d` chiem ca be ngang va
|
||||
`v3dRender()` ve hai lan vao hai nua bang scissor. Duong ke giua la CSS chu
|
||||
khong phai mot border cua the, vi khong co the nao o day ma vien. */
|
||||
.canvas-wrap.split3d #main { display: none; }
|
||||
.canvas-wrap.split3d #mainR { display: none; }
|
||||
.canvas-wrap.split3d #main3d { display: block; width: 100%; }
|
||||
.canvas-wrap.split3d::after {
|
||||
content: ''; position: absolute; left: 50%; top: 0; bottom: 0;
|
||||
width: 1px; background: #2a3442; pointer-events: none;
|
||||
}
|
||||
|
||||
.pane-label {
|
||||
position: absolute; top: 6px;
|
||||
font: 11px/1.4 ui-monospace, monospace;
|
||||
|
||||
Reference in New Issue
Block a user