upload
This commit is contained in:
112
app/src/app_config.h
Normal file
112
app/src/app_config.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef VSLAM_APP_APP_CONFIG_H
|
||||
#define VSLAM_APP_APP_CONFIG_H
|
||||
|
||||
// Nap sau file YAML thanh cac struct config ma tung lib da dinh nghia.
|
||||
//
|
||||
// ================== VI SAO O `app/` CHU KHONG O TUNG LIB ==================
|
||||
// Thiet ke sach hon la "moi lib tu doc config cua no". Nhung lam vay bat moi
|
||||
// lib phu thuoc yaml-cpp, ke ca `vslam_odometry` va `vslam_safety` -- hai lib
|
||||
// ma ca ly do ton tai la KHONG co dep ngoai nao, de review duoc doc lap va
|
||||
// build duoc truoc moi thu khac.
|
||||
//
|
||||
// Nen phep nap nam o day. Doi lai, moi khi them mot truong config thi phai
|
||||
// sua hai cho. De giam cho do: MOI khoi deu goi `UnknownKeys()` va TU CHOI
|
||||
// khoi dong khi co khoa la, nen mot truong duoc them vao YAML ma quen noi o
|
||||
// day se bao loi ngay chu khong am tham bi bo qua.
|
||||
//
|
||||
// ================== KHONG CO GIA TRI NAO O HAI NOI ==================
|
||||
// `cliff_detect.nominal_tz` KHONG doc tu pipeline.yaml -- no la he qua cua
|
||||
// robot.yaml (camera_link.z + wheel_radius) va duoc dat tu `RobotModel`.
|
||||
// Tuong tu, gioi han base trong safety.yaml duoc KIEM cheo voi robot.yaml
|
||||
// thay vi tin mot trong hai.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "vslam/cliff_detect.h"
|
||||
#include "vslam/depth_filter.h"
|
||||
#include "vslam/ekf_se2.h"
|
||||
#include "vslam/gravity_align.h"
|
||||
#include "vslam/perception_pipeline.h"
|
||||
#include "vslam/robot_model.h"
|
||||
#include "vslam/safety_monitor.h"
|
||||
#include "vslam/scan_sanitizer.h"
|
||||
#include "vslam/vslam_common.h"
|
||||
#include "vslam/web_server.h"
|
||||
#include "vslam/wheel_odometry.h"
|
||||
|
||||
#ifdef VSLAM_HAVE_SLAM
|
||||
#include "vslam/rtabmap_params.h"
|
||||
#endif
|
||||
|
||||
namespace vslam {
|
||||
|
||||
// Tan so toi da dung lai occupancy grid tu do thi SLAM. Xem system.yaml.
|
||||
struct SlamRuntimeConfig {
|
||||
double map_rebuild_rate_hz = 0.5;
|
||||
};
|
||||
|
||||
struct ThreadConfig {
|
||||
int safety_priority = 50;
|
||||
int driver_priority = 45;
|
||||
int estimator_priority = 40;
|
||||
bool use_realtime = true;
|
||||
double safety_rate_hz = 20.0;
|
||||
};
|
||||
|
||||
struct RecordConfig {
|
||||
bool enabled = false;
|
||||
std::string dir = "/var/lib/vslam/records";
|
||||
size_t max_queue_bytes = 64u * 1024u * 1024u;
|
||||
double depth_rate_hz = 10.0;
|
||||
bool record_infra1 = false;
|
||||
bool record_infra2 = false;
|
||||
bool compress = false;
|
||||
};
|
||||
|
||||
struct SensorRates {
|
||||
double lidar_hz = 25.0;
|
||||
double camera_hz = 30.0;
|
||||
double imu_hz = 200.0;
|
||||
bool camera_enable = true;
|
||||
uint32_t camera_width = 640;
|
||||
uint32_t camera_height = 480;
|
||||
uint32_t camera_decimate = 2;
|
||||
};
|
||||
|
||||
// Toan bo cau hinh cua mot lan chay.
|
||||
struct AppConfig {
|
||||
RobotModel robot; // robot.yaml -- nguon DUY NHAT cho hinh hoc
|
||||
|
||||
ScanSanitizerConfig sanitizer; // sensors.yaml
|
||||
SensorRates sensors;
|
||||
|
||||
WheelOdometryConfig wheel_odom; // robot.yaml + pipeline.yaml
|
||||
EkfSe2Config ekf; // pipeline.yaml
|
||||
PerceptionConfig perception; // pipeline.yaml + robot.yaml
|
||||
|
||||
SafetyConfig safety; // safety.yaml
|
||||
#ifdef VSLAM_HAVE_SLAM
|
||||
RtabmapConfig slam; // slam.yaml
|
||||
#endif
|
||||
|
||||
WebConfig web; // system.yaml
|
||||
ThreadConfig threads;
|
||||
SlamRuntimeConfig slam_runtime;
|
||||
RecordConfig record;
|
||||
std::string log_level = "info";
|
||||
|
||||
AppConfig() = default;
|
||||
AppConfig(const AppConfig&) = delete;
|
||||
AppConfig& operator=(const AppConfig&) = delete;
|
||||
};
|
||||
|
||||
// Nap tat ca tu `dir` (mac dinh `ConfigDir()`).
|
||||
//
|
||||
// Tra loi dau tien gap phai, KHONG gom het: mot file config sai thi cac gia
|
||||
// tri sau no khong con dang tin, va mot danh sach dai lam nguoi doc bo qua
|
||||
// dong dau.
|
||||
StatusResponse LoadAppConfig(const std::string& dir, AppConfig* out);
|
||||
|
||||
} // namespace vslam
|
||||
|
||||
#endif // VSLAM_APP_APP_CONFIG_H
|
||||
Reference in New Issue
Block a user