| 29 | FrontEndBase::FrontEndBase() = default; |
| 30 | |
| 31 | void FrontEndBase::initialize(const Yaml& cfg) |
| 32 | { |
| 33 | MRPT_TRY_START |
| 34 | |
| 35 | if (cfg.has("raw_data_source")) |
| 36 | { |
| 37 | auto ds_source = cfg["raw_data_source"]; |
| 38 | |
| 39 | if (cfg.isSequence()) |
| 40 | { |
| 41 | for (const auto& v : cfg.asSequence()) |
| 42 | { |
| 43 | front_end_source_names_.insert(v.as<std::string>()); |
| 44 | } |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | front_end_source_names_.insert(ds_source.as<std::string>()); |
| 49 | } |
| 50 | |
| 51 | for (const auto& src_name : front_end_source_names_) |
| 52 | { |
| 53 | MRPT_LOG_DEBUG_STREAM( |
| 54 | "FrontEndBase::initialize(): subscribing to '" << src_name << "' for raw sensor input."); |
| 55 | |
| 56 | ASSERT_(this->nameServer_); |
| 57 | |
| 58 | auto data_src = nameServer_(src_name); |
| 59 | if (!data_src) |
| 60 | { |
| 61 | THROW_EXCEPTION_FMT("Cannot find data source module named `%s`", src_name.c_str()); |
| 62 | } |
| 63 | |
| 64 | auto rdsb = std::dynamic_pointer_cast<RawDataSourceBase>(data_src); |
| 65 | if (!rdsb) |
| 66 | { |
| 67 | THROW_EXCEPTION_FMT( |
| 68 | "Could not cast data source module named `%s` to RawDataSourceBase", src_name.c_str()); |
| 69 | } |
| 70 | |
| 71 | // Subscribe: |
| 72 | rdsb->attachToDataConsumer(*this); |
| 73 | } |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | // This may be OK if we are running outside of the context of mola-cli |
| 78 | MRPT_LOG_DEBUG_STREAM( |
| 79 | "No 'raw_data_source' entry found in the YAML definition for a " |
| 80 | "FrontEndBase: YAML contents:\n" |
| 81 | << cfg << "\n"); |
| 82 | } |
| 83 | |
| 84 | // Optional: attach to the visualizer: |
| 85 | { |
nothing calls this directly
no test coverage detected