From 641db2e914e62dad70096fe3c56ffbe8f3c2d002 Mon Sep 17 00:00:00 2001 From: trung09122002 Date: Mon, 21 Sep 2026 10:23:51 +0700 Subject: [PATCH] update --- app/src/app_config.cc | 4 +++- configuration_files/sensors.yaml | 14 ++++++++++++++ .../vslam_drivers/include/vslam/driver_config.h | 17 +++++++++++++++-- libs/vslam_drivers/src/zlac_base.cc | 5 +++-- libs/vslam_drivers/thirdparty/PROVENANCE.md | 7 +++++++ libs/vslam_web/www/app3d.js | 8 +++++++- 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/app/src/app_config.cc b/app/src/app_config.cc index 08bc5c9..44ea1db 100644 --- a/app/src/app_config.cc +++ b/app/src/app_config.cc @@ -224,7 +224,7 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) { const StatusResponse r = Reject(b, "sensors.yaml base", {"can_channel", "can_node_id", "dcf_path", - "encoder_counts_per_rev"}); + "encoder_counts_per_rev", "accel_ramp_ms"}); if (!r.ok()) return r; } out->base_driver.protocol = BaseProtocol::kZlacCanOpen; @@ -244,6 +244,8 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) { } out->base_driver.encoder_counts_per_rev = static_cast(b.get("encoder_counts_per_rev", 0)); + out->base_driver.accel_ramp_ms = + static_cast(b.get("accel_ramp_ms", 1200)); // Hinh hoc va gioi han SAO tu robot.yaml, khong doc rieng. robot.yaml la // nguon duy nhat; mot ban sao trong sensors.yaml se troi khoi no ma khong diff --git a/configuration_files/sensors.yaml b/configuration_files/sensors.yaml index 7c7989d..478a4a6 100644 --- a/configuration_files/sensors.yaml +++ b/configuration_files/sensors.yaml @@ -212,4 +212,18 @@ base: # vong bang tay, doc lai. Hieu so chinh la count/vong that -- dat vao day. # cansend can0 601#40.64.60.01.00.00.00.00 # candump can0,581:7FF -n 1 + # + # ⚠️ base_kit KHONG tra loi duoc cau hoi nay. motor_params.yaml cua ho khong + # co tham so nao ve encoder, vi zlac_ros_node chi doc VAN TOC (0x606C, don vi + # rpm da co san) -- khong bao gio phai doi count sang radian. Chi du an nay + # doc 0x6064 nen chi du an nay can con so do. encoder_counts_per_rev: 0 + + # Thoi gian ramp tang/giam toc (0x6083 / 0x6084), ms tu 0 den toc do dinh + # muc. SO CANG LON CANG CHAM. + # + # 1200 lay tu base_kit/src/Zlac_ros/config/motor_params.yaml (acc_dec_val). + # Mac dinh cua ZlacMotorDriver la 500 -- tang toc nhanh gap 2.4 lan, du de + # banh truot that tren san tron. Day la tham so cua THIET BI va base_kit da + # chinh no tren chinh con robot nay, nen theo ho. + accel_ramp_ms: 1200 diff --git a/libs/vslam_drivers/include/vslam/driver_config.h b/libs/vslam_drivers/include/vslam/driver_config.h index e00987a..7ea0185 100644 --- a/libs/vslam_drivers/include/vslam/driver_config.h +++ b/libs/vslam_drivers/include/vslam/driver_config.h @@ -242,10 +242,23 @@ struct BaseConfig { std::string dcf_path; // Encoder resolution cua ZLAC8015D, dem/vong SAU hop so, doc qua 0x6064. - // 0 = doc tu thiet bi luc Open() (0x608F:1 Encoder Increments) thay vi tin - // mot hang so chep tay. + // + // ⚠️ 0 = dung mac dinh 16384 trong zlac_base.cc (4096 wire x 4 cau phuong), + // va con so do CHUA duoc kiem chung. base_kit KHONG giup duoc gi o day: ho + // chi doc van toc (0x606C, don vi rpm) nen khong bao gio can biet count/vong + // -- tham so nay khong ton tai trong motor_params.yaml cua ho. + // Cach do: quay banh tay dung mot vong, so hieu 0x6064:1 truoc/sau. uint32_t encoder_counts_per_rev = 0; + // Thoi gian ramp gui xuong 0x6083/0x6084 (Profile acceleration/deceleration), + // don vi ms tu 0 den toc do dinh muc. SO CANG LON, RAMP CANG CHAM. + // + // 1200 la gia tri base_kit dung (motor_params.yaml: acc_dec_val). Mac dinh + // cua ZlacMotorDriver::enableHardware() la 500, tuc tang toc NHANH GAP 2.4 + // LAN, du de banh truot that tren san tron. base_kit da chinh so nay tren + // chinh con robot nay nen no thang -- day la tham so cua THIET BI. + uint32_t accel_ramp_ms = 1200; + // --- Dung khi protocol = kVendorSerial --- std::string port = "/dev/ttyUSB0"; uint32_t baud = 115200; diff --git a/libs/vslam_drivers/src/zlac_base.cc b/libs/vslam_drivers/src/zlac_base.cc index 04df328..16e4202 100644 --- a/libs/vslam_drivers/src/zlac_base.cc +++ b/libs/vslam_drivers/src/zlac_base.cc @@ -116,7 +116,7 @@ class ZlacWrapper : public BaseInterface { "(systemctl status motor_control zlac_ros)" "\n - dcf_path: " + cfg_.dcf_path); } - if (!impl_->enableHardware()) { + if (!impl_->enableHardware(cfg_.accel_ramp_ms)) { impl_.reset(); return StatusResponse::Error( StatusCode::kUnavailable, @@ -129,7 +129,8 @@ class ZlacWrapper : public BaseInterface { VSLAM_INFO("base: ZLAC8015D tren " << cfg_.can_channel << " node " << static_cast(cfg_.can_node_id) << ", banh r=" << cfg_.wheel_radius << " m cach nhau " << cfg_.wheel_separation - << " m, " << counts_per_rev_ << " count/vong"); + << " m, " << counts_per_rev_ << " count/vong, ramp " + << cfg_.accel_ramp_ms << " ms"); running_ = true; poll_thread_ = std::thread([this] { PollLoop(); }); diff --git a/libs/vslam_drivers/thirdparty/PROVENANCE.md b/libs/vslam_drivers/thirdparty/PROVENANCE.md index a386f95..4f49a16 100644 --- a/libs/vslam_drivers/thirdparty/PROVENANCE.md +++ b/libs/vslam_drivers/thirdparty/PROVENANCE.md @@ -69,12 +69,19 @@ mot khung ga khac: | Tham so | base_kit | o day | Vi sao | |---|---|---|---| | `angle_offset_deg` / `angle_flip` | 90 / false | 180 / true | phep thu: nguoi dung ben TRAI robot, man hinh phai hien ben TRAI | +| `acc_dec` (0x6083/84) | 1200 | 1200 | DA KEO VE. Mac dinh cua `enableHardware()` la 500 -- nhanh gap 2.4 lan | | `box_min_y` / `box_max_y` | -0.25 / 0.0 | -0.25 / 0.25 | bon cot o day doi xung (y = +-0.136); hop mot ben bo sot hai cot | | toan bo `robot.yaml` | -- | -- | vi tri banh / LiDAR / camera do tren robot nay | Quy tac gon: **do duoc tren robot nay thi PHEP DO thang; khong do duoc thi `base_kit` thang.** +⚠️ Va co loai thu ba: cai `base_kit` KHONG BIET. `encoder_counts_per_rev` la +mot -- `motor_params.yaml` khong co tham so encoder nao, vi `zlac_ros_node` +chi doc van toc (`0x606C`, don vi rpm da co san) nen khong bao gio phai doi +count sang radian. Chi du an nay doc `0x6064`, nen chi du an nay phai do. +Dung tim cau tra loi o ben do. + Moi lan lech khoi `base_kit` deu co mot phep do dung sau, khong lan nao la so thich. Truoc khi keo mot gia tri cua ho ve, hoi: gia tri nay noi ve THIET BI hay ve KHUNG GA? diff --git a/libs/vslam_web/www/app3d.js b/libs/vslam_web/www/app3d.js index a0956f3..3c7df1a 100644 --- a/libs/vslam_web/www/app3d.js +++ b/libs/vslam_web/www/app3d.js @@ -827,8 +827,14 @@ function v3dSetView(name) { // `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) { + // ⚠️ CHI dung than robot. KHONG dung toi gtGroup. + // + // gtGroup (hinh ground truth) da co nguoi quan ly rieng trong app.js: no chi + // hien khi CO du lieu gt, ma gt chi ton tai khi chay mo phong. Ham nay tung + // set ca gtGroup.visible, va vi no chay SAU khoi do moi khung nen no ghi de + // -- ket qua la o che do --live hien mot hinh khung day mau xanh la nam li + // o goc toa do, khong bao gio di theo robot. if (V3D.bodyMesh) V3D.bodyMesh.visible = !!on; - if (V3D.gtGroup) V3D.gtGroup.visible = !!on; } function v3dSetFramesVisible(on) {