update
This commit is contained in:
@@ -999,6 +999,11 @@ function draw3d() {
|
|||||||
// Overlay cam bien (frustum, vanh cliff): tat mac dinh cho giong Gazebo.
|
// Overlay cam bien (frustum, vanh cliff): tat mac dinh cho giong Gazebo.
|
||||||
v3dSetOverlays(on('lyCam'));
|
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);
|
if (state.worldMap) v3dSetWorld(state.worldMap, 2.0);
|
||||||
v3dSetWorldVisible(on('lyWorld'));
|
v3dSetWorldVisible(on('lyWorld'));
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,39 @@ function v3dBindMouse(canvas) {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Mo hinh robot, dung tu khoi `robot` cua JSON.
|
// 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) {
|
function v3dBuildRobot(r) {
|
||||||
const g = new THREE.Group();
|
const g = new THREE.Group();
|
||||||
|
|
||||||
@@ -302,7 +335,13 @@ function v3dSetShape(r) {
|
|||||||
|
|
||||||
if (V3D.robotGroup) V3D.root.remove(V3D.robotGroup);
|
if (V3D.robotGroup) V3D.root.remove(V3D.robotGroup);
|
||||||
V3D.robotGroup = new THREE.Group();
|
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);
|
const rings = v3dCliffRings(r);
|
||||||
rings.userData.overlay = true;
|
rings.userData.overlay = true;
|
||||||
@@ -760,6 +799,19 @@ function v3dSetView(name) {
|
|||||||
o.tx = 0; o.ty = 0;
|
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) {
|
function v3dSetOverlays(on) {
|
||||||
if (!V3D.ready || !V3D.root) return;
|
if (!V3D.ready || !V3D.root) return;
|
||||||
V3D.root.traverse((o) => {
|
V3D.root.traverse((o) => {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
<label><input type="checkbox" id="lyCloud" checked> cloud</label>
|
<label><input type="checkbox" id="lyCloud" checked> cloud</label>
|
||||||
<label><input type="checkbox" id="lyPath" checked> path</label>
|
<label><input type="checkbox" id="lyPath" checked> path</label>
|
||||||
<label><input type="checkbox" id="lyCam"> overlay cam bien</label>
|
<label><input type="checkbox" id="lyCam"> overlay cam bien</label>
|
||||||
|
<label><input type="checkbox" id="lyBody" checked> than robot</label>
|
||||||
|
<label><input type="checkbox" id="lyTf"> tf</label>
|
||||||
<label><input type="checkbox" id="lyGt" checked> ground truth</label>
|
<label><input type="checkbox" id="lyGt" checked> ground truth</label>
|
||||||
<label><input type="checkbox" id="lyFollow"> bam robot</label>
|
<label><input type="checkbox" id="lyFollow"> bam robot</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ global.THREE = {
|
|||||||
setMatrixAt() {} dispose() {} },
|
setMatrixAt() {} dispose() {} },
|
||||||
Matrix4: class { compose() {} }, Quaternion: class { setFromAxisAngle() {} },
|
Matrix4: class { compose() {} }, Quaternion: class { setFromAxisAngle() {} },
|
||||||
Color: class { constructor() { this.set = () => {}; } },
|
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');
|
const www = path.resolve(__dirname, '../../libs/vslam_web/www');
|
||||||
|
|||||||
Reference in New Issue
Block a user