drivers,sim: moi khung anh mot bo dem rieng (sua tranh chap voi SlamLoop o RealSense/sim/replay); sim: IMU dong hoc tu quy dao 6-DoF, tan so phat/tre/bias, ground truth vao .vsr, vslam_record --robot --gt
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "vslam/driver_interfaces.h"
|
||||
#include "vslam/record_format.h"
|
||||
#include "vslam/record_io.h"
|
||||
#include "vslam/robot_model.h"
|
||||
#include "vslam/sim_source.h"
|
||||
|
||||
namespace {
|
||||
@@ -137,6 +138,10 @@ std::vector<Scenario> Scenarios() {
|
||||
int main(int argc, char** argv) {
|
||||
std::string name, out_dir = ".";
|
||||
bool list = false;
|
||||
// Mac dinh GIU hinh hoc cu cua SimConfig va KHONG ghi su that: bo hoi quy
|
||||
// (tools/regress.sh) so voi ban ghi dung bang cach do.
|
||||
std::string robot_yaml;
|
||||
bool write_gt = false;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
const std::string a = argv[i];
|
||||
@@ -144,10 +149,17 @@ int main(int argc, char** argv) {
|
||||
if (a == "--scenario") name = next();
|
||||
else if (a == "--out-dir") out_dir = next();
|
||||
else if (a == "--list") list = true;
|
||||
else if (a == "--robot") robot_yaml = next();
|
||||
else if (a == "--gt") write_gt = true;
|
||||
else if (a == "--help") {
|
||||
std::printf("cach dung: %s --scenario TEN --out-dir D\n"
|
||||
std::printf("cach dung: %s --scenario TEN --out-dir D [--robot robot.yaml] [--gt]\n"
|
||||
" %s --list\n"
|
||||
" %s --scenario all --out-dir D\n", argv[0], argv[0], argv[0]);
|
||||
" %s --scenario all --out-dir D\n"
|
||||
" --robot F hinh hoc robot THAT (banh, LiDAR, camera, IMU) tu robot.yaml\n"
|
||||
" thay vi so mac dinh cu cua SimConfig\n"
|
||||
" --gt ghi them tu the THAT 6-DoF (stream ground_truth) moi\n"
|
||||
" buoc vat ly, de cham diem offline\n",
|
||||
argv[0], argv[0], argv[0]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -159,6 +171,15 @@ int main(int argc, char** argv) {
|
||||
return name.empty() && !list ? 2 : 0;
|
||||
}
|
||||
|
||||
vslam::RobotModel robot;
|
||||
if (!robot_yaml.empty()) {
|
||||
const vslam::StatusResponse rs = robot.LoadFile(robot_yaml);
|
||||
if (!rs.ok()) {
|
||||
std::fprintf(stderr, "%s: %s\n", robot_yaml.c_str(), rs.message.c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int written = 0;
|
||||
for (const Scenario& s : all) {
|
||||
if (name != "all" && name != s.name) continue;
|
||||
@@ -176,6 +197,7 @@ int main(int argc, char** argv) {
|
||||
cfg.lidar_cut_at = s.lidar_cut_at;
|
||||
cfg.lidar_cut_for = s.lidar_cut_for;
|
||||
cfg.camera_rate_hz = s.camera_hz;
|
||||
if (!robot_yaml.empty()) vslam::SimConfigFromRobot(robot, &cfg);
|
||||
|
||||
vslam::SimSource sim(cfg);
|
||||
if (!sim.Open().ok()) {
|
||||
@@ -206,7 +228,9 @@ int main(int argc, char** argv) {
|
||||
vslam::RecordWriterConfig wc;
|
||||
wc.path = path;
|
||||
wc.compress = false; // nen = khong tat dinh giua cac phien ban zstd
|
||||
wc.config_json = std::string("{\"scenario\":\"") + s.name + "\",\"seed\":1234}";
|
||||
wc.config_json = std::string("{\"scenario\":\"") + s.name + "\",\"seed\":1234" +
|
||||
(robot_yaml.empty() ? "" : ",\"robot\":\"" + robot_yaml + "\"") +
|
||||
(write_gt ? ",\"ground_truth\":true" : "") + "}";
|
||||
|
||||
vslam::RecordWriter w(wc);
|
||||
const vslam::StatusResponse st = w.Open();
|
||||
@@ -251,6 +275,15 @@ int main(int argc, char** argv) {
|
||||
vslam::EncodeEncoderPayload(e.left_rad, e.right_rad, &b_enc);
|
||||
w.Write(vslam::VsrStream::kEncoder, e.stamp, b_enc);
|
||||
});
|
||||
std::string b_gt;
|
||||
if (write_gt) {
|
||||
sim.SetGroundTruthCallback([&](vslam::UnixTime t, const vslam::SimPose3& p) {
|
||||
const double v[6] = {p.x, p.y, p.z, p.roll, p.pitch, p.yaw};
|
||||
b_gt.clear();
|
||||
vslam::EncodeGroundTruthPayload(v, &b_gt);
|
||||
w.Write(vslam::VsrStream::kGroundTruth, t, b_gt);
|
||||
});
|
||||
}
|
||||
if (sim.camera() != nullptr) {
|
||||
sim.camera()->SetCallback([&](const vslam::CameraFrame& f) {
|
||||
if (!f.depth) return;
|
||||
|
||||
Reference in New Issue
Block a user