diff --git a/libs/vslam_web/www/app.js b/libs/vslam_web/www/app.js
index d09889d..bd831b1 100644
--- a/libs/vslam_web/www/app.js
+++ b/libs/vslam_web/www/app.js
@@ -999,6 +999,11 @@ function draw3d() {
// Overlay cam bien (frustum, vanh cliff): tat mac dinh cho giong Gazebo.
v3dSetOverlays(on('lyCam'));
+ // Than robot / bo truc TF. Bo "than robot" va bat "tf" de chi con ba bo
+ // truc -- che do de kiem cam bien co nam dung cho khong.
+ v3dSetBodyVisible(on('lyBody'));
+ v3dSetFramesVisible(on('lyTf'));
+
if (state.worldMap) v3dSetWorld(state.worldMap, 2.0);
v3dSetWorldVisible(on('lyWorld'));
diff --git a/libs/vslam_web/www/app3d.js b/libs/vslam_web/www/app3d.js
index f95cfc6..99ee744 100644
--- a/libs/vslam_web/www/app3d.js
+++ b/libs/vslam_web/www/app3d.js
@@ -157,6 +157,39 @@ function v3dBindMouse(canvas) {
// ---------------------------------------------------------------------------
// Mo hinh robot, dung tu khoi `robot` cua JSON.
// ---------------------------------------------------------------------------
+// Bo truc cho MOT frame tinh, kem nhan ten.
+//
+// Dung tu chinh `shape` ma backend da gui (laser_x/y/z, cam_x/y/z, cam_pitch)
+// nen KHONG phai them gi o phia C++.
+//
+// Vi sao co lop nay: khi PCL khong chong khit scan thi cau hoi luon la "cam
+// bien nao dang o sai cho", va mot khoi hop mau xanh khong tra loi duoc. Ba
+// bo truc dat dung vi tri thi tra loi duoc ngay bang mat.
+function v3dFrameAxes(name, x, y, z, pitch, size) {
+ const g = new THREE.Group();
+ g.add(new THREE.AxesHelper(size || 0.15));
+ // Dung toScene() nhu moi cho khac, khong chep lai phep doi truc: hai ban
+ // chep cua cung mot phep doi se lech nhau ngay lan sua dau tien.
+ g.position.copy(toScene(x || 0, y || 0, z || 0));
+ // Chuc xuong: cung quy uoc voi camG trong v3dBuildRobot.
+ if (pitch) g.rotation.z = -pitch;
+ g.userData.frameName = name;
+ return g;
+}
+
+// Ba frame tinh: base_link, laser_link, camera_link.
+function v3dBuildFrames(r) {
+ const g = new THREE.Group();
+ // base_link o TAM TRUC banh. Ca nhom duoc nang len wheel_radius giong
+ // v3dBuildRobot de san nam o y = 0.
+ g.position.y = r.wheel_radius;
+ g.add(v3dFrameAxes('base_link', 0, 0, 0, 0, 0.25));
+ g.add(v3dFrameAxes('laser_link', r.laser_x, r.laser_y, r.laser_z, 0, 0.18));
+ g.add(v3dFrameAxes('camera_link', r.cam_x, r.cam_y, r.cam_z,
+ r.cam_pitch, 0.18));
+ return g;
+}
+
function v3dBuildRobot(r) {
const g = new THREE.Group();
@@ -302,7 +335,13 @@ function v3dSetShape(r) {
if (V3D.robotGroup) V3D.root.remove(V3D.robotGroup);
V3D.robotGroup = new THREE.Group();
- V3D.robotGroup.add(v3dBuildRobot(r));
+ V3D.bodyMesh = v3dBuildRobot(r);
+ V3D.robotGroup.add(V3D.bodyMesh);
+ // Bo truc di CUNG robotGroup nen no bam theo pose -- dung cai can: xem cam
+ // bien nam dau khi robot da di chuyen, khong phai o goc toa do.
+ V3D.framesMesh = v3dBuildFrames(r);
+ V3D.framesMesh.visible = false;
+ V3D.robotGroup.add(V3D.framesMesh);
{
const rings = v3dCliffRings(r);
rings.userData.overlay = true;
@@ -760,6 +799,19 @@ function v3dSetView(name) {
o.tx = 0; o.ty = 0;
}
+// Than robot va bo truc TF: bat/tat doc lap.
+//
+// `body = false, frames = true` cho ra che do "chi TF": huu ich khi can nhin
+// cam bien nam dau ma khong bi khoi hop 0.85 m che mat.
+function v3dSetBodyVisible(on) {
+ if (V3D.bodyMesh) V3D.bodyMesh.visible = !!on;
+ if (V3D.gtGroup) V3D.gtGroup.visible = !!on;
+}
+
+function v3dSetFramesVisible(on) {
+ if (V3D.framesMesh) V3D.framesMesh.visible = !!on;
+}
+
function v3dSetOverlays(on) {
if (!V3D.ready || !V3D.root) return;
V3D.root.traverse((o) => {
diff --git a/libs/vslam_web/www/index.html b/libs/vslam_web/www/index.html
index 415319a..81aa918 100644
--- a/libs/vslam_web/www/index.html
+++ b/libs/vslam_web/www/index.html
@@ -15,6 +15,8 @@
+
+
diff --git a/test/www/test_robot_marker.js b/test/www/test_robot_marker.js
index 70be869..4df31f1 100644
--- a/test/www/test_robot_marker.js
+++ b/test/www/test_robot_marker.js
@@ -60,6 +60,10 @@ global.THREE = {
setMatrixAt() {} dispose() {} },
Matrix4: class { compose() {} }, Quaternion: class { setFromAxisAngle() {} },
Color: class { constructor() { this.set = () => {}; } },
+ // v3dBuildFrames dung AxesHelper de ve bo truc TF. Bai kiem nay khong do
+ // bo truc, nhung stub phai co du thu ma code CHAM TOI -- thieu mot lop la
+ // ca file khong nap duoc va moi phep do ben duoi im lang bien mat.
+ AxesHelper: class { constructor(s) { Object.assign(this, node()); this.size = s; } },
};
const www = path.resolve(__dirname, '../../libs/vslam_web/www');