update
This commit is contained in:
@@ -58,7 +58,8 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
||||
const StatusResponse st = Open(dir, kSensorsConfigFile, &root);
|
||||
if (!st.ok()) return st;
|
||||
{
|
||||
const StatusResponse r = Reject(root, "sensors.yaml", {"lidar", "camera", "mcu"});
|
||||
const StatusResponse r =
|
||||
Reject(root, "sensors.yaml", {"lidar", "camera", "mcu", "base"});
|
||||
if (!r.ok()) return r;
|
||||
}
|
||||
|
||||
@@ -74,6 +75,19 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
||||
out->sanitizer.range_max = l.get<double>("range_max", 40.0);
|
||||
out->sensors.lidar_hz = l.get<double>("expected_rate_hz", 25.0);
|
||||
|
||||
// Driver LakiBeam. `host` la dia chi de BIND, khong phai IP cua LiDAR --
|
||||
// SDK chinh hang cung luon bind 0.0.0.0.
|
||||
out->lidar_driver.host_ip = l.get<std::string>("host", "0.0.0.0");
|
||||
out->lidar_driver.port = static_cast<uint16_t>(l.get<int>("port", 2368));
|
||||
out->lidar_driver.scan_freq_hz = out->sensors.lidar_hz;
|
||||
out->lidar_driver.frame_id = kLaserFrame;
|
||||
out->lidar_driver.sweep_duration_tolerance_sec =
|
||||
l.get<double>("stamp_mismatch_warn", 0.005);
|
||||
// ⚠️ range_unit_m, angle_offset_deg va inverted CO Y khong doc tu YAML.
|
||||
// Ca ba deu suy ra duoc (xem driver_config.h): don vi mm tu SDK, va goc
|
||||
// tu manual §8.1 + REP-103 + tu the gan up nguoc. De chung trong YAML moi
|
||||
// la de nguoi van hanh go bua vao mot thu da co dap an dung.
|
||||
|
||||
// Sector mask ghi bang DO trong YAML (doc duoc bang mat), dung bang RAD.
|
||||
// Doi mot lan o day, khong de moi noi tu doi.
|
||||
const ConfigNode masks = l["sector_masks"];
|
||||
@@ -102,6 +116,10 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
||||
out->sanitizer.sector_masks.push_back(SectorMask{a, b});
|
||||
}
|
||||
}
|
||||
// Driver chi dung range_min/max cua cai nay de dien header LaserScan; no
|
||||
// KHONG goi Apply(). Ve sinh scan la viec cua node (wiring.cc), dung mot
|
||||
// doi tuong duy nhat -- xem lakibeam_driver.cc.
|
||||
out->lidar_driver.sanitizer = out->sanitizer;
|
||||
|
||||
const ConfigNode c = root["camera"];
|
||||
{
|
||||
@@ -117,6 +135,15 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
||||
out->sensors.camera_hz = c.get<double>("fps", 30.0);
|
||||
out->sensors.camera_decimate = static_cast<uint32_t>(c.get<int>("decimate", 2));
|
||||
|
||||
out->camera_driver.depth_width = out->sensors.camera_width;
|
||||
out->camera_driver.depth_height = out->sensors.camera_height;
|
||||
out->camera_driver.fps = static_cast<uint32_t>(out->sensors.camera_hz);
|
||||
out->camera_driver.decimate = out->sensors.camera_decimate;
|
||||
out->camera_driver.enable_infra1 = c.get<bool>("enable_infra1", true);
|
||||
out->camera_driver.enable_infra2 = c.get<bool>("enable_infra2", true);
|
||||
out->camera_driver.use_global_time = c.get<bool>("prefer_global_time", true);
|
||||
out->camera_driver.depth_frame_id = kCameraDepthOpticalFrame;
|
||||
|
||||
const ConfigNode mc = root["mcu"];
|
||||
{
|
||||
const StatusResponse r =
|
||||
@@ -126,6 +153,38 @@ StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out) {
|
||||
if (!r.ok()) return r;
|
||||
}
|
||||
out->sensors.imu_hz = mc.get<double>("expected_imu_rate_hz", 200.0);
|
||||
|
||||
out->mcu_driver.port = mc.get<std::string>("port", "/dev/ttyACM0");
|
||||
out->mcu_driver.baud = static_cast<uint32_t>(mc.get<int>("baud", 115200));
|
||||
out->mcu_driver.imu_frame_id = kImuFrame;
|
||||
|
||||
// ---------- base ----------
|
||||
// Muc nay MOI. Encoder va motor di qua CANopen tren can0, khong qua serial
|
||||
// MCU nhu mcu_protocol.h gia dinh -- xem zlac_base.cc.
|
||||
const ConfigNode b = root["base"];
|
||||
{
|
||||
const StatusResponse r =
|
||||
Reject(b, "sensors.yaml base",
|
||||
{"can_channel", "can_node_id", "dcf_path",
|
||||
"encoder_counts_per_rev"});
|
||||
if (!r.ok()) return r;
|
||||
}
|
||||
out->base_driver.protocol = BaseProtocol::kZlacCanOpen;
|
||||
out->base_driver.can_channel = b.get<std::string>("can_channel", "can0");
|
||||
out->base_driver.can_node_id =
|
||||
static_cast<uint8_t>(b.get<int>("can_node_id", 1));
|
||||
out->base_driver.dcf_path = b.get<std::string>("dcf_path", "");
|
||||
out->base_driver.encoder_counts_per_rev =
|
||||
static_cast<uint32_t>(b.get<int>("encoder_counts_per_rev", 0));
|
||||
|
||||
// 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
|
||||
// ai phat hien -- va troi kieu im lang: robot van chay, chi sai ti le.
|
||||
out->base_driver.wheel_radius = geom.wheel_radius;
|
||||
out->base_driver.wheel_separation = geom.wheel_separation;
|
||||
out->base_driver.max_linear = out->robot.base().max_linear;
|
||||
out->base_driver.max_angular = out->robot.base().max_angular;
|
||||
out->base_driver.cmd_timeout_sec = out->robot.base().cmd_timeout;
|
||||
}
|
||||
|
||||
// ---------- pipeline.yaml ----------
|
||||
|
||||
Reference in New Issue
Block a user