Skip to content

Commit d440144

Browse files
authored
auto detect IMU/points topics and acc_scale (#293)
1 parent 9285412 commit d440144

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

config/config_ros.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// --- TF config ---
1616
// GLIM publishes TF subtrees "map -> odom -> base_frame" and "imu -> lidar".
17-
// imu_frame_id : IMU frame ID
18-
// lidar_frame_id : LiDAR frame ID
17+
// imu_frame_id : IMU frame ID (If blank, auto-detected from IMU topic)
18+
// lidar_frame_id : LiDAR frame ID (If blank, auto-detected from points topic)
1919
// base_frame_id : Base frame ID. If blank, IMU frame ID is used.
2020
// odom_frame_id : Odometry frame ID
2121
// map_frame_id : Map frame ID
@@ -52,11 +52,11 @@
5252
// IMU config
5353
"imu_time_offset": 0.0,
5454
"points_time_offset": 0.0,
55-
"acc_scale": 1.0,
55+
"acc_scale": 0.0, // Auto-detect if zero
5656
// TF config
57-
"imu_frame_id": "imu",
58-
"lidar_frame_id": "lidar",
59-
"base_frame_id": "",
57+
"imu_frame_id": "", // Auto-detect if blank
58+
"lidar_frame_id": "", // Auto-detect if blank
59+
"base_frame_id": "", // If blank, IMU frame ID is used
6060
"odom_frame_id": "odom",
6161
"map_frame_id": "map",
6262
"publish_imu2lidar": true,

include/glim/util/config.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ class Config {
1919
Config(const std::string& config_filename);
2020
virtual ~Config();
2121

22+
/**
23+
* @brief Check if a parameter exists
24+
* @param module_name Module name
25+
* @param param_name Parameter name
26+
* @return True if the parameter exists, otherwise false
27+
*/
28+
bool has_param(const std::string& module_name, const std::string& param_name) const;
29+
2230
/**
2331
* @brief Get a parameter
2432
* @param module_name Module name

src/glim/util/config.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ Config::Config(const std::string& config_filename) {
2626

2727
Config::~Config() {}
2828

29+
bool Config::has_param(const std::string& module_name, const std::string& param_name) const {
30+
const auto& json = std::any_cast<const nlohmann::json&>(config);
31+
auto module = json.find(module_name);
32+
if (module == json.end()) {
33+
return false;
34+
}
35+
36+
return module->find(param_name) != module->end();
37+
}
38+
2939
void Config::save(const std::string& path) const {
3040
const auto& json = std::any_cast<const nlohmann::json&>(config);
3141

0 commit comments

Comments
 (0)