slam.yaml: profiles sim/real -- odom sigma va ICP ratio tach theo moi truong
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "vslam/config.h"
|
||||
#include "vslam/geometry.h"
|
||||
#include "vslam/occupancy_export.h"
|
||||
#include "vslam/occupancy_map_io.h"
|
||||
@@ -207,6 +208,10 @@ int main(int argc, char** argv) {
|
||||
// (0.1 m / 0.1 rad) -- dung cai runtime dang gui.
|
||||
double odom_sigma_lin = -1.0, odom_sigma_ang = -1.0;
|
||||
std::map<std::string, std::string> extra;
|
||||
// --profile sim|real: nap slam.yaml THAT (--config DIR, mac dinh
|
||||
// $VSLAM_CONFIG_DIR) va ap profile do. Khong co thi giu cach cu: mac dinh
|
||||
// cua code + --param.
|
||||
std::string profile, config_dir;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
const std::string a = argv[i];
|
||||
@@ -222,6 +227,8 @@ int main(int argc, char** argv) {
|
||||
else if (a == "--with-images") with_images = true;
|
||||
else if (a == "--ref-db") ref_db = next();
|
||||
else if (a == "--ref") ref_kind = next();
|
||||
else if (a == "--profile") profile = next();
|
||||
else if (a == "--config") config_dir = next();
|
||||
else if (a == "--odom-sigma") { // "LIN_M,ANG_RAD"
|
||||
const std::string v = next();
|
||||
const size_t c = v.find(',');
|
||||
@@ -245,7 +252,10 @@ int main(int argc, char** argv) {
|
||||
std::printf(
|
||||
"cach dung: %s --db X.db [--localize] [--kidnap M,DEG]\n"
|
||||
" [--limit N] [--optimizer 0|1|2|3] [--export-map out.pgm]\n"
|
||||
" [--ref opt|odom] [--odom-sigma LIN_M,ANG_RAD]\n",
|
||||
" [--ref opt|odom] [--odom-sigma LIN_M,ANG_RAD]\n"
|
||||
" [--profile sim|real [--config DIR]] nap slam.yaml that\n"
|
||||
" (DIR mac dinh $VSLAM_CONFIG_DIR) va ap profile do;\n"
|
||||
" --param / --odom-sigma van ghi de len tren\n",
|
||||
argv[0]);
|
||||
return 0;
|
||||
}
|
||||
@@ -398,7 +408,31 @@ int main(int argc, char** argv) {
|
||||
cfg.database_path = work_db; // rong = DB trong RAM (che do mapping)
|
||||
cfg.optimizer_strategy = optimizer;
|
||||
cfg.visual_loop = visual_loop;
|
||||
cfg.overrides = extra;
|
||||
if (!profile.empty()) {
|
||||
// Chay DUNG bo so ma node se chay trong moi truong do, thay vi mac dinh
|
||||
// cua struct (ma phai go lai tung key bang --param).
|
||||
if (config_dir.empty()) {
|
||||
const char* env = std::getenv("VSLAM_CONFIG_DIR");
|
||||
config_dir = env != nullptr ? env : "configuration_files";
|
||||
}
|
||||
vslam::RtabmapConfig y;
|
||||
try {
|
||||
y = vslam::LoadRtabmapConfig(vslam::ConfigNode::LoadFile(config_dir + "/slam.yaml"));
|
||||
} catch (const std::exception& e) {
|
||||
std::fprintf(stderr, "%s/slam.yaml: %s\n", config_dir.c_str(), e.what());
|
||||
return 1;
|
||||
}
|
||||
const vslam::StatusResponse pst = vslam::ApplySlamProfile(profile, &y);
|
||||
if (!pst.ok()) {
|
||||
std::fprintf(stderr, "%s\n", pst.message.c_str());
|
||||
return 1;
|
||||
}
|
||||
cfg.odom_sigma_m = y.odom_sigma_m;
|
||||
cfg.odom_sigma_rad = y.odom_sigma_rad;
|
||||
cfg.overrides = y.overrides;
|
||||
std::printf("%s/slam.yaml, profile %s\n", config_dir.c_str(), profile.c_str());
|
||||
}
|
||||
for (const auto& kv : extra) cfg.overrides[kv.first] = kv.second;
|
||||
for (const auto& kv : extra) {
|
||||
std::printf("param: %s = %s\n", kv.first.c_str(), kv.second.c_str());
|
||||
}
|
||||
@@ -492,7 +526,9 @@ int main(int argc, char** argv) {
|
||||
odom_sigma_lin > 0.0
|
||||
? (std::to_string(odom_sigma_lin) + " m, " +
|
||||
std::to_string(odom_sigma_ang) + " rad").c_str()
|
||||
: ("mac dinh slam.yaml (" + std::to_string(cfg.odom_sigma_m) + " m, " +
|
||||
: ((profile.empty() ? std::string("mac dinh cua code (")
|
||||
: "slam.yaml profile " + profile + " (") +
|
||||
std::to_string(cfg.odom_sigma_m) + " m, " +
|
||||
std::to_string(cfg.odom_sigma_rad) + " rad)").c_str());
|
||||
std::fflush(stdout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user