update
This commit is contained in:
@@ -1147,7 +1147,7 @@ void Runtime::WebLoop() {
|
||||
// xem sensors.yaml) nen cung goc thoi gian voi `clock_->Now()`. Lech
|
||||
// hon ca cua so lich su nghia la gia thiet do khong con dung -> khong bu.
|
||||
if (best != nullptr && best_dt <= kPoseMatchMaxSec) {
|
||||
snap.cloud_delta = Pose2DCompose(Pose2DInverse(ekf_pose), best->pose);
|
||||
snap.cloud_delta = Pose2DBetween(ekf_pose, best->pose);
|
||||
snap.have_cloud_delta = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,8 @@ const R_BLANKED = 0xFFFD; // bi sector mask cat (than robot che)
|
||||
|
||||
const state = {
|
||||
pose: null, gt: null, scan: null, cloud: null, path: null,
|
||||
// Pose tai thoi diem khung CLOUD toi. Xem cloudAnchorPose().
|
||||
cloudPose: null,
|
||||
map: null, mapImage: null, mapVersion: 0,
|
||||
bytes: 0, lastBytes: 0, wireRate: 0,
|
||||
};
|
||||
@@ -161,6 +163,9 @@ function onBinary(dv) {
|
||||
pts[i * 3 + 2] = dv.getInt16(b + 4, true) * scale;
|
||||
}
|
||||
state.cloud = pts;
|
||||
// Publish() gui khung STATE truoc khung CLOUD trong cung mot lan goi, nen
|
||||
// `state.pose` o day dung la pose ma server da dung de tinh `cloud_delta`.
|
||||
state.cloudPose = state.pose;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -429,6 +434,30 @@ function drawRobot(ctx, x, y, yaw, color, alpha, pal) {
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// Pose de ve CLOUD, khong phai pose robot.
|
||||
//
|
||||
// Server da quy cloud ve he base_footprint tai thoi diem GUI (EncodeCloud +
|
||||
// cloud_delta). Nhung cloud chi toi 2 Hz con trang ve lai moi khung hinh: ve
|
||||
// bang pose moi nhat thi ngay sau khi nhan, sai so moc lai tu 0 len
|
||||
// `v * 0.5 s`. Phai neo dam may vao pose LUC KHUNG DO TOI.
|
||||
//
|
||||
// Tra ve pose TUONG DOI so voi `robotPose` dang ve, khong phai pose tuyet
|
||||
// doi: khung "the gioi" ve tai pose ground truth va no can cung phep bu nay.
|
||||
function cloudAnchorPose(robotPose) {
|
||||
if (!state.cloudPose || !state.pose || !robotPose) return robotPose;
|
||||
const dx = state.cloudPose.x - state.pose.x;
|
||||
const dy = state.cloudPose.y - state.pose.y;
|
||||
const cn = Math.cos(state.pose.yaw), sn = Math.sin(state.pose.yaw);
|
||||
const lx = cn * dx + sn * dy;
|
||||
const ly = -sn * dx + cn * dy;
|
||||
const c = Math.cos(robotPose.yaw), s = Math.sin(robotPose.yaw);
|
||||
return {
|
||||
x: robotPose.x + c * lx - s * ly,
|
||||
y: robotPose.y + s * lx + c * ly,
|
||||
yaw: robotPose.yaw + (state.cloudPose.yaw - state.pose.yaw),
|
||||
};
|
||||
}
|
||||
|
||||
// Ve MOT khung.
|
||||
//
|
||||
// `grid`/`gridImage` : ban do de ve (THE GIOI hay SLAM)
|
||||
@@ -498,10 +527,13 @@ function drawScene(targetCv, targetCtx, grid, gridImage, robotPose, showGt, mapT
|
||||
}
|
||||
|
||||
if (state.cloud && on('lyCloud')) {
|
||||
// Cloud KHONG dung `p` -- xem cloudAnchorPose().
|
||||
const cp = cloudAnchorPose(p);
|
||||
const cc = Math.cos(cp.yaw), cs = Math.sin(cp.yaw);
|
||||
const pts = state.cloud;
|
||||
for (let i = 0; i < pts.length; i += 3) {
|
||||
const x = p.x + c * pts[i] - s * pts[i + 1];
|
||||
const y = p.y + s * pts[i] + c * pts[i + 1];
|
||||
const x = cp.x + cc * pts[i] - cs * pts[i + 1];
|
||||
const y = cp.y + cs * pts[i] + cc * pts[i + 1];
|
||||
const z = pts[i + 2];
|
||||
// To mau theo do cao: day la view debug perception, va do cao la
|
||||
// thu duy nhat dang nhin o goc tu tren xuong.
|
||||
@@ -992,7 +1024,7 @@ function draw3d() {
|
||||
}
|
||||
|
||||
v3dSetScan(on('lyScan') ? state.scan : null, state.pose, state.robot);
|
||||
v3dSetCloud(on('lyCloud') ? state.cloud : null, state.pose);
|
||||
v3dSetCloud(on('lyCloud') ? state.cloud : null, cloudAnchorPose(state.pose));
|
||||
|
||||
// THE GIOI: tuong 3D dung tu ban do mo phong -- day la phan "Gazebo".
|
||||
// Dung MOT lan (ban do the gioi la tinh), roi chi bat/tat.
|
||||
|
||||
Reference in New Issue
Block a user