diff --git a/hello_wolf/hello_wolf_config.yaml b/hello_wolf/hello_wolf_config.yaml index 62b8738103ca4ff4f14b32fd9ee70d001762648c..afd6a9fcde82eb03bb2a67c9f197387e84fd9b58 100644 --- a/hello_wolf/hello_wolf_config.yaml +++ b/hello_wolf/hello_wolf_config.yaml @@ -4,25 +4,25 @@ config: frame_structure: "PO" dimension: 2 prior: - timestamp: 0.0 - state: [0,0,0] - cov: [[3,3],.01,0,0,0,.01,0,0,0,.01] - time_tolerance: 0.1 + timestamp: 0.0 + state: [0,0,0] + cov: [[3,3],.01,0,0,0,.01,0,0,0,.01] + time_tolerance: 0.1 sensors: - - type: "ODOM 2D" - name: "sen odom" + type: "ODOM 2D" + name: "sen odom" extrinsic: - pose: [0,0, 0] - k_disp_to_disp: 0.1 - k_rot_to_rot: 0.1 + pose: [0,0, 0] + k_disp_to_disp: 0.1 + k_rot_to_rot: 0.1 - - type: "RANGE BEARING" - name: "sen rb" + type: "RANGE BEARING" + name: "sen rb" extrinsic: - pose: [1,1, 0, 0] + pose: [1,1, 0] noise_range_metres_std: 0.1 noise_bearing_degrees_std: 0.5 @@ -42,12 +42,12 @@ config: unmeasured_perturbation_std: 0.001 - - type: "RANGE BEARING" - name: "prc rb" - sensor_name: "sen rb" - voting_active: false + type: "RANGE BEARING" + name: "prc rb" + sensor_name: "sen rb" + voting_active: false voting_aux_active: false - time_tolerance: 0.1 + time_tolerance: 0.1 files: diff --git a/hello_wolf/processor_range_bearing.cpp b/hello_wolf/processor_range_bearing.cpp index 5685c411998415689aa8d795b4f8c61417382f3d..654e3fbfe4a28a59a1bc7454ece77d2c871fbfd4 100644 --- a/hello_wolf/processor_range_bearing.cpp +++ b/hello_wolf/processor_range_bearing.cpp @@ -115,22 +115,22 @@ ProcessorBasePtr ProcessorRangeBearing::create(const std::string& _unique_name, return prc; } -ProcessorBasePtr ProcessorRangeBearing::createAutoConf(const std::string& _unique_name, - const ParamsServer& _server, - const SensorBasePtr _sensor_ptr) -{ - SensorRangeBearingPtr sensor_rb = std::static_pointer_cast<SensorRangeBearing>(_sensor_ptr); - ProcessorParamsRangeBearingPtr params = std::make_shared<ProcessorParamsRangeBearing>(_unique_name, _server); - - // construct processor - ProcessorRangeBearingPtr prc = std::make_shared<ProcessorRangeBearing>(sensor_rb, params); - - // setup processor - prc->setName(_unique_name); - - return prc; -} - +//ProcessorBasePtr ProcessorRangeBearing::createAutoConf(const std::string& _unique_name, +// const ParamsServer& _server, +// const SensorBasePtr _sensor_ptr) +//{ +// SensorRangeBearingPtr sensor_rb = std::static_pointer_cast<SensorRangeBearing>(_sensor_ptr); +// ProcessorParamsRangeBearingPtr params = std::make_shared<ProcessorParamsRangeBearing>(_unique_name, _server); +// +// // construct processor +// ProcessorRangeBearingPtr prc = std::make_shared<ProcessorRangeBearing>(sensor_rb, params); +// +// // setup processor +// prc->setName(_unique_name); +// +// return prc; +//} +// Eigen::Vector2s ProcessorRangeBearing::observe(const Eigen::Vector2s& lmk_w) const { return polar(toSensor(lmk_w)); diff --git a/hello_wolf/processor_range_bearing.h b/hello_wolf/processor_range_bearing.h index 2bc4767c14f0c9619534d3bd6f6ae1dc5d4f506b..2c7002bdcbf7c4b8a113e4b58d8fbd087bac0efa 100644 --- a/hello_wolf/processor_range_bearing.h +++ b/hello_wolf/processor_range_bearing.h @@ -53,9 +53,10 @@ class ProcessorRangeBearing : public ProcessorBase static ProcessorBasePtr create(const std::string& _unique_name, const ProcessorParamsBasePtr _params, const SensorBasePtr sensor_ptr = nullptr); - static ProcessorBasePtr createAutoConf(const std::string& _unique_name, - const ParamsServer& _server, - const SensorBasePtr _sensor_ptr = nullptr); +// static ProcessorBasePtr createAutoConf(const std::string& _unique_name, +// const ParamsServer& _server, +// const SensorBasePtr _sensor_ptr = nullptr); + WOLF_CREATE_PROCESSOR_AUTO(ProcessorRangeBearing, ProcessorParamsRangeBearing, SensorRangeBearing); protected: // Implementation of pure virtuals from ProcessorBase diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 3537f96032ba64bbbb901f722bd64bdf10bbe0ab..bbda7ba8345cf4f0cc27fbf2ede72c122afb06ee 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -19,6 +19,37 @@ class SensorBase; namespace wolf { +/* + * Macro for defining Autoconf processor creator. + * + * In order to use this macro, the derived processor class, ProcessorClass, + * must have a constructor available with one of the following APIs: + * + * ProcessorClass(const SensorClassPtr _sensor, const ProcessorParamsClassPtr _params); + * ProcessorClass(const SensorClassPtr _sensor, const ProcessorParamsBasePtr _params); + * ProcessorClass(const SensorBasePtr _sensor, const ProcessorParamsClassPtr _params); + * ProcessorClass(const SensorBasePtr _sensor, const ProcessorParamsBasePtr _params); + * + * We recommend writing one of such constructors in your derived processors. + */ +#define WOLF_CREATE_PROCESSOR_AUTO(ProcessorClass, ProcessorParamsClass, SensorClass) \ +static ProcessorBasePtr createAutoConf(const std::string& _unique_name, \ + const ParamsServer& _server, \ + const SensorBasePtr _sensor) \ +{ \ + auto sensor = std::static_pointer_cast<SensorClass>(_sensor); \ + auto params = std::make_shared<ProcessorParamsClass>(_unique_name, _server); \ + \ + auto processor = std::make_shared<ProcessorClass>(sensor, params); \ + \ + processor ->setName(_unique_name); \ + \ + return processor; \ +} + + + + /** \brief Key frame class pack * * To store a key_frame with an associated time tolerance. diff --git a/include/core/sensor/sensor_base.h b/include/core/sensor/sensor_base.h index d31326fc27e724d6a3e81e34ae1a3bdd85e06494..18fe0568e40df4f914e3dd3aba7a55b706fe2c15 100644 --- a/include/core/sensor/sensor_base.h +++ b/include/core/sensor/sensor_base.h @@ -22,10 +22,13 @@ namespace wolf { /* * Macro for defining Autoconf sensor creator. * - * In order to use this macro, the derived sensor class, SensorClass, must have a constructor available like so: + * In order to use this macro, the derived sensor class, SensorClass, + * must have a constructor available with one of the following APIs: * * SensorClass(const VectorXs & _extrinsics, const IntrinsicsClassPtr _intrinsics); + * SensorClass(const VectorXs & _extrinsics, const IntrinsicsBasePtr _intrinsics); * + * We recommend writing one of such constructors in your derived sensors. */ #define WOLF_CREATE_SENSOR_AUTO(SensorClass, IntrinsicsClass, ExtrinsicsSize) \ static SensorBasePtr createAutoConf(const std::string& _unique_name, const ParamsServer& _server) \