MCPcopy Create free account
hub / github.com/MOLAorg/mola / initialize

Method initialize

mola_kernel/src/interfaces/RawDataSourceBase.cpp:66–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void RawDataSourceBase::initialize(const Yaml& cfg)
67{
68 MRPT_TRY_START
69
70 // Handle optional sensor preview GUI:
71 if (cfg.has("gui_preview_sensors"))
72 {
73 auto ds_preview = cfg["gui_preview_sensors"];
74 for (const auto& s : ds_preview.asSequence())
75 {
76 auto sensor = mrpt::containers::yaml(s);
77 const auto label = sensor["raw_sensor_label"].as<std::string>();
78 const auto decimation = sensor.getOrDefault<unsigned int>("decimation", 1);
79 const auto win_pos = sensor.getOrDefault<std::string>("win_pos", "");
80
81 // store here to help computing sensor rate in the GUI
82 sensor["sensor_rate_decimation"] = decimation;
83
84 // Allow quickly disabling sections:
85 if (!sensor.getOrDefault("enabled", true))
86 {
87 continue;
88 }
89
90 ASSERTMSG_(
91 sensor_preview_gui_.find(label) == sensor_preview_gui_.end(),
92 mrpt::format("Duplicated sensor label in `gui_preview_sensors`: `%s`", label.c_str()));
93 auto& sv = sensor_preview_gui_[label] =
94 mrpt::make_impl<RawDataSourceBase::SensorViewerImpl>();
95
96 sv->decimation = decimation;
97 sv->sensor_label = label;
98 sv->win_pos = win_pos;
99 sv->extra_parameters = sensor;
100 // sv->win: Create a window when the sensor actually publishes.
101 }
102 }
103
104 // Handle optional export to rawlog file
105 if (auto fil = cfg.getOrDefault<std::string>("export_to_rawlog", ""); !fil.empty())
106 {
107 MRPT_LOG_INFO_STREAM("Exporting to rawlog file: " << fil);
108 if (!export_to_rawlog_out_.open(fil))
109 {
110 THROW_EXCEPTION_FMT("Error opening for write: `%s`", fil.c_str());
111 }
112 }
113
114 // Optional force load lazy-load observations:
115 YAML_LOAD_MEMBER_OPT(force_load_lazy_load, bool);
116 YAML_LOAD_MEMBER_OPT(quit_mola_app_on_dataset_end, bool);
117
118 // children params:
119 this->initialize_rds(cfg);
120
121 MRPT_TRY_END
122}
123

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
initialize_rdsMethod · 0.45

Tested by

no test coverage detected