From e6921d4d24c82399ee51fc50730887463a75d7c9 Mon Sep 17 00:00:00 2001 From: jcasals <jcasals@iri.upc.edu> Date: Fri, 3 Apr 2020 12:58:06 +0200 Subject: [PATCH] Rename X_factory.h -> factory_X.h Rename {sensor, processor, solver}_factory.h -> factory_{sensor, processor, solver}.h --- CMakeLists.txt | 6 +- hello_wolf/processor_range_bearing.cpp | 2 +- hello_wolf/sensor_range_bearing.cpp | 2 +- hello_wolf/yaml/sensor_odom_2d.yaml | 2 +- include/core/common/factory.h | 18 +++--- include/core/problem/problem.h | 6 +- ...rocessor_factory.h => factory_processor.h} | 52 ++++++++-------- .../{sensor_factory.h => factory_sensor.h} | 60 +++++++++---------- .../{solver_factory.h => factory_solver.h} | 46 +++++++------- src/ceres_wrapper/ceres_manager.cpp | 2 +- src/problem/problem.cpp | 16 ++--- src/processor/processor_diff_drive.cpp | 2 +- src/processor/processor_odom_2d.cpp | 2 +- src/processor/processor_odom_3d.cpp | 2 +- src/sensor/sensor_diff_drive.cpp | 2 +- src/sensor/sensor_odom_2d.cpp | 2 +- src/sensor/sensor_odom_3d.cpp | 2 +- src/yaml/processor_odom_3d_yaml.cpp | 4 +- src/yaml/sensor_odom_2d_yaml.cpp | 4 +- src/yaml/sensor_odom_3d_yaml.cpp | 4 +- .../dummy/processor_tracker_feature_dummy.cpp | 2 +- test/gtest_problem.cpp | 2 +- test/gtest_processor_base.cpp | 2 +- .../gtest_processor_tracker_feature_dummy.cpp | 2 +- ...gtest_processor_tracker_landmark_dummy.cpp | 2 +- test/yaml/processor_odom_3d.yaml | 2 +- test/yaml/sensor_odom_2d.yaml | 2 +- test/yaml/sensor_odom_3d.yaml | 2 +- 28 files changed, 126 insertions(+), 126 deletions(-) rename include/core/processor/{processor_factory.h => factory_processor.h} (83%) rename include/core/sensor/{sensor_factory.h => factory_sensor.h} (83%) rename include/core/solver/{solver_factory.h => factory_solver.h} (85%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cab800a23..9ae5db6ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,7 +263,7 @@ SET(HDRS_PROCESSOR include/core/processor/motion_buffer.h include/core/processor/processor_base.h include/core/processor/processor_diff_drive.h - include/core/processor/processor_factory.h + include/core/processor/factory_processor.h include/core/processor/processor_logging.h include/core/processor/processor_loopclosure.h include/core/processor/processor_motion.h @@ -277,13 +277,13 @@ SET(HDRS_PROCESSOR SET(HDRS_SENSOR include/core/sensor/sensor_base.h include/core/sensor/sensor_diff_drive.h - include/core/sensor/sensor_factory.h + include/core/sensor/factory_sensor.h include/core/sensor/sensor_odom_2d.h include/core/sensor/sensor_odom_3d.h ) SET(HDRS_SOLVER include/core/solver/solver_manager.h - include/core/solver/solver_factory.h + include/core/solver/factory_solver.h ) SET(HDRS_YAML diff --git a/hello_wolf/processor_range_bearing.cpp b/hello_wolf/processor_range_bearing.cpp index 69c3651d4..fb51ed537 100644 --- a/hello_wolf/processor_range_bearing.cpp +++ b/hello_wolf/processor_range_bearing.cpp @@ -160,7 +160,7 @@ bool ProcessorRangeBearing::storeCapture(CaptureBasePtr _cap_ptr) } /* namespace wolf */ // Register in the SensorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("ProcessorRangeBearing", ProcessorRangeBearing) diff --git a/hello_wolf/sensor_range_bearing.cpp b/hello_wolf/sensor_range_bearing.cpp index 3eea032b2..4bf5db050 100644 --- a/hello_wolf/sensor_range_bearing.cpp +++ b/hello_wolf/sensor_range_bearing.cpp @@ -38,7 +38,7 @@ SensorRangeBearing::~SensorRangeBearing() } /* namespace wolf */ // Register in the SensorFactory -#include "core/sensor/sensor_factory.h" +#include "core/sensor/factory_sensor.h" namespace wolf { WOLF_REGISTER_SENSOR("SensorRangeBearing", SensorRangeBearing) diff --git a/hello_wolf/yaml/sensor_odom_2d.yaml b/hello_wolf/yaml/sensor_odom_2d.yaml index 3ad720485..2149405a7 100644 --- a/hello_wolf/yaml/sensor_odom_2d.yaml +++ b/hello_wolf/yaml/sensor_odom_2d.yaml @@ -1,4 +1,4 @@ -type: "SensorOdom2d" # This must match the KEY used in the SensorFactory. Otherwise it is an error. +type: "SensorOdom2d" # This must match the KEY used in the FactorySensor. Otherwise it is an error. k_disp_to_disp: 0.1 # m^2 / m k_rot_to_rot: 0.1 # rad^2 / rad diff --git a/include/core/common/factory.h b/include/core/common/factory.h index 0d02a89c3..34c214bd6 100644 --- a/include/core/common/factory.h +++ b/include/core/common/factory.h @@ -28,8 +28,8 @@ namespace wolf * This class implements a generic factory as a singleton. * * > IMPORTANT: This template factory can be used to construct many different objects except: - * > - Objects deriving from SensorBase --> see SensorFactory - * > - Objects deriving from ProcessorBase --> see ProcessorFactory + * > - Objects deriving from SensorBase --> see FactorySensor + * > - Objects deriving from ProcessorBase --> see FactoryProcessor * > * > The reason for this is that the two cases above need a more elaborated API than the one in this template class. * @@ -86,8 +86,8 @@ namespace wolf * The first thing to know is that we have defined typedefs for the templates that we are using. For example: * * \code - * typedef Factory<ParamsSensorBase, std::string> ParamsSensorFactory; - * typedef Factory<ParamsProcessorBase, std::string> ParamsProcessorFactory; + * typedef Factory<ParamsSensorBase, std::string> FactoryParamsSensor; + * typedef Factory<ParamsProcessorBase, std::string> FactoryParamsProcessor; * typedef Factory<LandmarkBase, YAML::Node> LandmarkFactory; * \endcode * @@ -145,7 +145,7 @@ namespace wolf * For example, in sensor_camera_yaml.cpp we find the line: * * \code - * const bool registered_camera_intr = ParamsSensorFactory::get().registerCreator("CAMERA", createParamsSensorCamera); + * const bool registered_camera_intr = FactoryParamsSensor::get().registerCreator("CAMERA", createParamsSensorCamera); * \endcode * * which is a static invocation (i.e., it is placed at global scope outside of the ParamsSensorCamera class). @@ -218,15 +218,15 @@ namespace wolf * \endcode * * ### More information - * - ParamsSensorFactory: typedef of this template to create intrinsic structs deriving from ParamsSensorBase directly from YAML files. - * - ParamsProcessorFactory: typedef of this template to create processor params structs deriving from ParamsProcessorBase directly from YAML files. + * - FactoryParamsSensor: typedef of this template to create intrinsic structs deriving from ParamsSensorBase directly from YAML files. + * - FactoryParamsProcessor: typedef of this template to create processor params structs deriving from ParamsProcessorBase directly from YAML files. * - LandmarkFactory: typedef of this template to create landmarks deriving from LandmarkBase directly from YAML nodes. * - Problem::loadMap() : to load a maps directly from YAML files. * - You can also check the code in the example file ````src/examples/test_map_yaml.cpp````. * * #### See also - * - SensorFactory: to create sensors - * - ProcessorFactory: to create processors. + * - FactorySensor: to create sensors + * - FactoryProcessor: to create processors. * - Problem::installSensor() : to install sensors in WOLF Problem. * - Problem::installProcessor() : to install processors in WOLF Problem. * diff --git a/include/core/problem/problem.h b/include/core/problem/problem.h index 1f76367e6..dc485c527 100644 --- a/include/core/problem/problem.h +++ b/include/core/problem/problem.h @@ -19,8 +19,8 @@ struct ParamsProcessorBase; #include "core/frame/frame_base.h" #include "core/state_block/state_block.h" #include "core/utils/params_server.h" -#include "core/sensor/sensor_factory.h" -#include "core/processor/processor_factory.h" +#include "core/sensor/factory_sensor.h" +#include "core/processor/factory_processor.h" #include "core/processor/is_motion.h" // std includes @@ -91,7 +91,7 @@ class Problem : public std::enable_shared_from_this<Problem> * \param _sen_type type of sensor * \param _unique_sensor_name unique sensor name, used to identify the particular instance of the sensor * \param _extrinsics a vector of extrinsic parameters: size 2 for 2d position, 3 for 2d pose, 3 for 3d position, 7 for 3d pose. - * \param _intrinsics_filename the name of a file containing the intrinsic parameters in a format compatible with the intrinsics creator registered in ParamsSensorFactory under the key _sen_type. + * \param _intrinsics_filename the name of a file containing the intrinsic parameters in a format compatible with the intrinsics creator registered in FactoryParamsSensor under the key _sen_type. */ SensorBasePtr installSensor(const std::string& _sen_type, // const std::string& _unique_sensor_name, // diff --git a/include/core/processor/processor_factory.h b/include/core/processor/factory_processor.h similarity index 83% rename from include/core/processor/processor_factory.h rename to include/core/processor/factory_processor.h index 947955d4b..e744f5325 100644 --- a/include/core/processor/processor_factory.h +++ b/include/core/processor/factory_processor.h @@ -1,12 +1,12 @@ /** - * \file processor_factory.h + * \file factory_processor.h * * Created on: May 4, 2016 * \author: jsola */ -#ifndef PROCESSOR_FACTORY_H_ -#define PROCESSOR_FACTORY_H_ +#ifndef FACTORY_PROCESSOR_H_ +#define FACTORY_PROCESSOR_H_ namespace wolf { @@ -47,17 +47,17 @@ namespace wolf * - Write a processor creator for ProcessorOdom2d (example). * * #### Accessing the Factory - * The ProcessorFactory class is a singleton: it can only exist once in your application. + * The FactoryProcessor class is a singleton: it can only exist once in your application. * To obtain an instance of it, use the static method get(), * * \code - * ProcessorFactory::get() + * FactoryProcessor::get() * \endcode * * You can then call the methods you like, e.g. to create a processor, you type: * * \code - * ProcessorFactory::get().create(...); // see below for creating processors ... + * FactoryProcessor::get().create(...); // see below for creating processors ... * \endcode * * #### Registering processor creators @@ -69,7 +69,7 @@ namespace wolf * that knows how to create your specific processor, e.g.: * * \code - * ProcessorFactory::get().registerCreator("ProcessorOdom2d", ProcessorOdom2d::create); + * FactoryProcessor::get().registerCreator("ProcessorOdom2d", ProcessorOdom2d::create); * \endcode * * The method ProcessorOdom2d::create() exists in the ProcessorOdom2d class as a static method. @@ -96,7 +96,7 @@ namespace wolf * For example, in processor_odom_2d.cpp we find the line: * * \code - * const bool registered_odom_2d = ProcessorFactory::get().registerCreator("ProcessorOdom2d", ProcessorOdom2d::create); + * const bool registered_odom_2d = FactoryProcessor::get().registerCreator("ProcessorOdom2d", ProcessorOdom2d::create); * \endcode * * which is a static invocation (i.e., it is placed at global scope outside of the ProcessorOdom2d class). @@ -107,7 +107,7 @@ namespace wolf * It only needs to be passed the string of the processor type. * * \code - * ProcessorFactory::get().unregisterCreator("ProcessorOdom2d"); + * FactoryProcessor::get().unregisterCreator("ProcessorOdom2d"); * \endcode * * #### Creating processors @@ -117,7 +117,7 @@ namespace wolf * To create a ProcessorOdom2d, you type: * * \code - * ProcessorFactory::get().create("ProcessorOdom2d", "main odometry", params_ptr); + * FactoryProcessor::get().create("ProcessorOdom2d", "main odometry", params_ptr); * \endcode * * #### Example 1 : using the Factories alone @@ -125,21 +125,21 @@ namespace wolf * and bind it to a SensorOdom2d: * * \code - * #include "core/sensor/sensor_odom_2d.h" // provides SensorOdom2d and SensorFactory - * #include "core/processor/processor_odom_2d.h" // provides ProcessorOdom2d and ProcessorFactory + * #include "core/sensor/sensor_odom_2d.h" // provides SensorOdom2d and FactorySensor + * #include "core/processor/processor_odom_2d.h" // provides ProcessorOdom2d and FactoryProcessor * * // Note: SensorOdom2d::create() is already registered, automatically. * // Note: ProcessorOdom2d::create() is already registered, automatically. * - * // First create the sensor (See SensorFactory for details) - * SensorBasePtr sensor_ptr = SensorFactory::get().create ( "FactorOdom2d" , "Main odometer" , extrinsics , &intrinsics ); + * // First create the sensor (See FactorySensor for details) + * SensorBasePtr sensor_ptr = FactorySensor::get().create ( "FactorOdom2d" , "Main odometer" , extrinsics , &intrinsics ); * * // To create a odometry integrator, provide a type="ODOM 2d", a name="main odometry", and a pointer to the parameters struct: * * ParamsProcessorOdom2d params({...}); // fill in the derived struct (note: ProcessorOdom2d actually has no input params) * * ProcessorBasePtr processor_ptr = - * ProcessorFactory::get().create ( "ProcessorOdom2d" , "main odometry" , ¶ms ); + * FactoryProcessor::get().create ( "ProcessorOdom2d" , "main odometry" , ¶ms ); * * // Bind processor to sensor * sensor_ptr->addProcessor(processor_ptr); @@ -168,40 +168,40 @@ namespace wolf // ParamsProcessor factory struct ParamsProcessorBase; typedef Factory<ParamsProcessorBase, - const std::string&> ParamsProcessorFactory; + const std::string&> FactoryParamsProcessor; template<> -inline std::string ParamsProcessorFactory::getClass() +inline std::string FactoryParamsProcessor::getClass() { - return "ParamsProcessorFactory"; + return "FactoryParamsProcessor"; } // Processor factory typedef Factory<ProcessorBase, const std::string&, - const ParamsProcessorBasePtr> ProcessorFactory; + const ParamsProcessorBasePtr> FactoryProcessor; template<> -inline std::string ProcessorFactory::getClass() +inline std::string FactoryProcessor::getClass() { - return "ProcessorFactory"; + return "FactoryProcessor"; } #define WOLF_REGISTER_PROCESSOR(ProcessorType, ProcessorName) \ namespace{ const bool WOLF_UNUSED ProcessorName##Registered = \ - wolf::ProcessorFactory::get().registerCreator(ProcessorType, ProcessorName::create); } \ + wolf::FactoryProcessor::get().registerCreator(ProcessorType, ProcessorName::create); } \ typedef Factory<ProcessorBase, const std::string&, - const ParamsServer&> AutoConfProcessorFactory; + const ParamsServer&> AutoConfFactoryProcessor; template<> -inline std::string AutoConfProcessorFactory::getClass() +inline std::string AutoConfFactoryProcessor::getClass() { - return "AutoConfProcessorFactory"; + return "AutoConfFactoryProcessor"; } #define WOLF_REGISTER_PROCESSOR_AUTO(ProcessorType, ProcessorName) \ namespace{ const bool WOLF_UNUSED ProcessorName##AutoConfRegistered = \ - wolf::AutoConfProcessorFactory::get().registerCreator(ProcessorType, ProcessorName::create); } \ + wolf::AutoConfFactoryProcessor::get().registerCreator(ProcessorType, ProcessorName::create); } \ } /* namespace wolf */ diff --git a/include/core/sensor/sensor_factory.h b/include/core/sensor/factory_sensor.h similarity index 83% rename from include/core/sensor/sensor_factory.h rename to include/core/sensor/factory_sensor.h index daf01499a..cae320bba 100644 --- a/include/core/sensor/sensor_factory.h +++ b/include/core/sensor/factory_sensor.h @@ -1,12 +1,12 @@ /** - * \file sensor_factory.h + * \file factory_sensor.h * * Created on: Apr 25, 2016 * \author: jsola */ -#ifndef SENSOR_FACTORY_H_ -#define SENSOR_FACTORY_H_ +#ifndef FACTORY_SENSOR_H_ +#define FACTORY_SENSOR_H_ namespace wolf { @@ -47,17 +47,17 @@ namespace wolf * - Write a sensor creator for SensorCamera (example). * * #### Accessing the factory - * The SensorFactory class is a <a href="http://stackoverflow.com/questions/1008019/c-singleton-design-pattern#1008289">singleton</a>: it can only exist once in your application. + * The FactorySensor class is a <a href="http://stackoverflow.com/questions/1008019/c-singleton-design-pattern#1008289">singleton</a>: it can only exist once in your application. * To obtain an instance of it, use the static method get(), * * \code - * SensorFactory::get() + * FactorySensor::get() * \endcode * * You can then call the methods you like, e.g. to create a sensor, you type: * * \code - * SensorFactory::get().create(...); // see below for creating sensors ... + * FactorySensor::get().create(...); // see below for creating sensors ... * \endcode * * #### Registering sensor creators @@ -69,7 +69,7 @@ namespace wolf * that knows how to create your specific sensor, e.g.: * * \code - * SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * \endcode * * The method SensorCamera::create() exists in the SensorCamera class as a static method. @@ -89,7 +89,7 @@ namespace wolf * For example, in sensor_camera.cpp we find the line: * * \code - * const bool registered_camera = SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * \endcode * * which is a static invocation (i.e., it is placed at global scope outside of the SensorCamera class). @@ -99,7 +99,7 @@ namespace wolf * The method unregisterCreator() unregisters the SensorXxx::create() method. It only needs to be passed the string of the sensor type. * * \code - * SensorFactory::get().unregisterCreator("CAMERA"); + * FactorySensor::get().unregisterCreator("CAMERA"); * \endcode * * #### Creating sensors @@ -109,15 +109,15 @@ namespace wolf * To create e.g. a SensorCamera, you type: * * \code - * SensorFactory::get().create("CAMERA", "Front-left camera", extrinsics, intrinsics_ptr); + * FactorySensor::get().create("CAMERA", "Front-left camera", extrinsics, intrinsics_ptr); * \endcode * * where ABSOLUTELY ALL input parameters are important. In particular, the sensor name "Front-left camera" will be used to identify this camera * and to assign it the appropriate processors. DO NOT USE IT WITH DUMMY PARAMETERS! * * #### See also - * - ParamsSensorFactory: to create intrinsic structs deriving from ParamsSensorBase directly from YAML files. - * - ProcessorFactory: to create processors that will be bound to sensors. + * - FactoryParamsSensor: to create intrinsic structs deriving from ParamsSensorBase directly from YAML files. + * - FactoryProcessor: to create processors that will be bound to sensors. * - Problem::installSensor() : to install sensors in WOLF Problem. * * #### Example 1: writing a specific sensor creator @@ -148,14 +148,14 @@ namespace wolf * Put the code either at global scope (you must define a dummy variable for this), * \code * namespace { - * const bool registered_camera = SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * } * main () { ... } * \endcode * or inside your main(), where a direct call is possible: * \code * main () { - * SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * ... * } * \endcode @@ -164,7 +164,7 @@ namespace wolf * Put the code at the last line of the sensor_xxx.cpp file, * \code * namespace { - * const bool registered_camera = SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * } * \endcode * Automatic registration is recommended in wolf, and implemented in the classes shipped with it. @@ -174,7 +174,7 @@ namespace wolf * We finally provide the necessary steps to create a sensor of class SensorCamera in our application: * * \code - * #include "sensor_factory.h" + * #include "factory_sensor.h" * #include "core/sensor/sensor_camera.h" // provides SensorCamera * * // Note: SensorCamera::create() is already registered, automatically. @@ -189,10 +189,10 @@ namespace wolf * // a pointer to the intrinsics struct: * * Eigen::VectorXd extrinsics_1(7); // give it some values... - * ParamsSensorCamera intrinsics_1({...}); // see ParamsSensorFactory to fill in the derived struct + * ParamsSensorCamera intrinsics_1({...}); // see FactoryParamsSensor to fill in the derived struct * * SensorBasePtr camera_1_ptr = - * SensorFactory::get().create ( "CAMERA" , "Front-left camera" , extrinsics_1 , &intrinsics_1 ); + * FactorySensor::get().create ( "CAMERA" , "Front-left camera" , extrinsics_1 , &intrinsics_1 ); * * // A second camera... with a different name! * @@ -200,7 +200,7 @@ namespace wolf * ParamsSensorCamera intrinsics_2({...}); * * SensorBasePtr camera_2_ptr = - * SensorFactory::get().create( "CAMERA" , "Front-right camera" , extrinsics_2 , &intrinsics_2 ); + * FactorySensor::get().create( "CAMERA" , "Front-right camera" , extrinsics_2 , &intrinsics_2 ); * * return 0; * } @@ -212,42 +212,42 @@ namespace wolf // ParamsSensor factory struct ParamsSensorBase; typedef Factory<ParamsSensorBase, - const std::string&> ParamsSensorFactory; + const std::string&> FactoryParamsSensor; template<> -inline std::string ParamsSensorFactory::getClass() +inline std::string FactoryParamsSensor::getClass() { - return "ParamsSensorFactory"; + return "FactoryParamsSensor"; } // Sensor factory typedef Factory<SensorBase, const std::string&, - const Eigen::VectorXd&, const ParamsSensorBasePtr> SensorFactory; + const Eigen::VectorXd&, const ParamsSensorBasePtr> FactorySensor; template<> -inline std::string SensorFactory::getClass() +inline std::string FactorySensor::getClass() { - return "SensorFactory"; + return "FactorySensor"; } #define WOLF_REGISTER_SENSOR(SensorType, SensorName) \ namespace{ const bool WOLF_UNUSED SensorName##Registered = \ - SensorFactory::get().registerCreator(SensorType, SensorName::create); } \ + FactorySensor::get().registerCreator(SensorType, SensorName::create); } \ typedef Factory<SensorBase, const std::string&, - const ParamsServer&> AutoConfSensorFactory; + const ParamsServer&> AutoConfFactorySensor; template<> -inline std::string AutoConfSensorFactory::getClass() +inline std::string AutoConfFactorySensor::getClass() { - return "AutoConfSensorFactory"; + return "AutoConfFactorySensor"; } #define WOLF_REGISTER_SENSOR_AUTO(SensorType, SensorName) \ namespace{ const bool WOLF_UNUSED SensorName##AutoConfRegistered = \ - AutoConfSensorFactory::get().registerCreator(SensorType, SensorName::create); } \ + AutoConfFactorySensor::get().registerCreator(SensorType, SensorName::create); } \ } /* namespace wolf */ diff --git a/include/core/solver/solver_factory.h b/include/core/solver/factory_solver.h similarity index 85% rename from include/core/solver/solver_factory.h rename to include/core/solver/factory_solver.h index d80fe24f7..4c9971d90 100644 --- a/include/core/solver/solver_factory.h +++ b/include/core/solver/factory_solver.h @@ -1,12 +1,12 @@ /** - * \file solver_factory.h + * \file factory_solver.h * * Created on: Dec 17, 2018 * \author: jcasals */ -#ifndef SOLVER_FACTORY_H_ -#define SOLVER_FACTORY_H_ +#ifndef FACTORY_SOLVER_H_ +#define FACTORY_SOLVER_H_ namespace wolf { @@ -47,17 +47,17 @@ namespace wolf * - Write a sensor creator for SensorCamera (example). * * #### Accessing the factory - * The SensorFactory class is a <a href="http://stackoverflow.com/questions/1008019/c-singleton-design-pattern#1008289">singleton</a>: it can only exist once in your application. + * The FactorySensor class is a <a href="http://stackoverflow.com/questions/1008019/c-singleton-design-pattern#1008289">singleton</a>: it can only exist once in your application. * To obtain an instance of it, use the static method get(), * * \code - * SensorFactory::get() + * FactorySensor::get() * \endcode * * You can then call the methods you like, e.g. to create a sensor, you type: * * \code - * SensorFactory::get().create(...); // see below for creating sensors ... + * FactorySensor::get().create(...); // see below for creating sensors ... * \endcode * * #### Registering sensor creators @@ -69,7 +69,7 @@ namespace wolf * that knows how to create your specific sensor, e.g.: * * \code - * SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * \endcode * * The method SensorCamera::create() exists in the SensorCamera class as a static method. @@ -89,7 +89,7 @@ namespace wolf * For example, in sensor_camera.cpp we find the line: * * \code - * const bool registered_camera = SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * \endcode * * which is a static invocation (i.e., it is placed at global scope outside of the SensorCamera class). @@ -99,7 +99,7 @@ namespace wolf * The method unregisterCreator() unregisters the SensorXxx::create() method. It only needs to be passed the string of the sensor type. * * \code - * SensorFactory::get().unregisterCreator("CAMERA"); + * FactorySensor::get().unregisterCreator("CAMERA"); * \endcode * * #### Creating sensors @@ -109,15 +109,15 @@ namespace wolf * To create e.g. a SensorCamera, you type: * * \code - * SensorFactory::get().create("CAMERA", "Front-left camera", extrinsics, intrinsics_ptr); + * FactorySensor::get().create("CAMERA", "Front-left camera", extrinsics, intrinsics_ptr); * \endcode * * where ABSOLUTELY ALL input parameters are important. In particular, the sensor name "Front-left camera" will be used to identify this camera * and to assign it the appropriate processors. DO NOT USE IT WITH DUMMY PARAMETERS! * * #### See also - * - ParamsSensorFactory: to create intrinsic structs deriving from ParamsSensorBase directly from YAML files. - * - ProcessorFactory: to create processors that will be bound to sensors. + * - FactoryParamsSensor: to create intrinsic structs deriving from ParamsSensorBase directly from YAML files. + * - FactoryProcessor: to create processors that will be bound to sensors. * - Problem::installSensor() : to install sensors in WOLF Problem. * * #### Example 1: writing a specific sensor creator @@ -148,14 +148,14 @@ namespace wolf * Put the code either at global scope (you must define a dummy variable for this), * \code * namespace { - * const bool registered_camera = SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * } * main () { ... } * \endcode * or inside your main(), where a direct call is possible: * \code * main () { - * SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * ... * } * \endcode @@ -164,7 +164,7 @@ namespace wolf * Put the code at the last line of the sensor_xxx.cpp file, * \code * namespace { - * const bool registered_camera = SensorFactory::get().registerCreator("CAMERA", SensorCamera::create); + * const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * } * \endcode * Automatic registration is recommended in wolf, and implemented in the classes shipped with it. @@ -174,7 +174,7 @@ namespace wolf * We finally provide the necessary steps to create a sensor of class SensorCamera in our application: * * \code - * #include "sensor_factory.h" + * #include "factory_sensor.h" * #include "sensor_camera.h" // provides SensorCamera * * // Note: SensorCamera::create() is already registered, automatically. @@ -189,10 +189,10 @@ namespace wolf * // a pointer to the intrinsics struct: * * Eigen::VectorXd extrinsics_1(7); // give it some values... - * ParamsSensorCamera intrinsics_1({...}); // see ParamsSensorFactory to fill in the derived struct + * ParamsSensorCamera intrinsics_1({...}); // see FactoryParamsSensor to fill in the derived struct * * SensorBasePtr camera_1_ptr = - * SensorFactory::get().create ( "CAMERA" , "Front-left camera" , extrinsics_1 , &intrinsics_1 ); + * FactorySensor::get().create ( "CAMERA" , "Front-left camera" , extrinsics_1 , &intrinsics_1 ); * * // A second camera... with a different name! * @@ -200,7 +200,7 @@ namespace wolf * ParamsSensorCamera intrinsics_2({...}); * * SensorBasePtr camera_2_ptr = - * SensorFactory::get().create( "CAMERA" , "Front-right camera" , extrinsics_2 , &intrinsics_2 ); + * FactorySensor::get().create( "CAMERA" , "Front-right camera" , extrinsics_2 , &intrinsics_2 ); * * return 0; * } @@ -211,17 +211,17 @@ namespace wolf typedef Factory<SolverManager, const ProblemPtr&, - const ParamsServer&> SolverFactory; + const ParamsServer&> FactorySolver; template<> -inline std::string SolverFactory::getClass() +inline std::string FactorySolver::getClass() { - return "SolverFactory"; + return "FactorySolver"; } #define WOLF_REGISTER_SOLVER(SolverType, SolverName) \ namespace{ const bool WOLF_UNUSED SolverName##Registered = \ - wolf::SolverFactory::get().registerCreator(SolverType, SolverName::create); } \ + wolf::FactorySolver::get().registerCreator(SolverType, SolverName::create); } \ } /* namespace wolf */ diff --git a/src/ceres_wrapper/ceres_manager.cpp b/src/ceres_wrapper/ceres_manager.cpp index 0d8cba6f9..c358c072f 100644 --- a/src/ceres_wrapper/ceres_manager.cpp +++ b/src/ceres_wrapper/ceres_manager.cpp @@ -515,7 +515,7 @@ const Eigen::SparseMatrixd CeresManager::computeHessian() const } // namespace wolf -#include "core/solver/solver_factory.h" +#include "core/solver/factory_solver.h" namespace wolf { WOLF_REGISTER_SOLVER("CERES", CeresManager) } // namespace wolf diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 1d5ad2ec6..785d95f2f 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -8,8 +8,8 @@ #include "core/processor/processor_tracker.h" #include "core/capture/capture_pose.h" #include "core/factor/factor_base.h" -#include "core/sensor/sensor_factory.h" -#include "core/processor/processor_factory.h" +#include "core/sensor/factory_sensor.h" +#include "core/processor/factory_processor.h" #include "core/state_block/state_block.h" #include "core/utils/logging.h" #include "core/utils/params_server.h" @@ -179,7 +179,7 @@ SensorBasePtr Problem::installSensor(const std::string& _sen_type, // const Eigen::VectorXd& _extrinsics, // ParamsSensorBasePtr _intrinsics) { - SensorBasePtr sen_ptr = SensorFactory::get().create(_sen_type, _unique_sensor_name, _extrinsics, _intrinsics); + SensorBasePtr sen_ptr = FactorySensor::get().create(_sen_type, _unique_sensor_name, _extrinsics, _intrinsics); sen_ptr->link(getHardware()); return sen_ptr; } @@ -194,7 +194,7 @@ SensorBasePtr Problem::installSensor(const std::string& _sen_type, // if (_intrinsics_filename != "") { assert(file_exists(_intrinsics_filename) && "Cannot install sensor: intrinsics' YAML file does not exist."); - ParamsSensorBasePtr intr_ptr = ParamsSensorFactory::get().create(_sen_type, _intrinsics_filename); + ParamsSensorBasePtr intr_ptr = FactoryParamsSensor::get().create(_sen_type, _intrinsics_filename); return installSensor(_sen_type, _unique_sensor_name, _extrinsics, intr_ptr); } else @@ -206,7 +206,7 @@ SensorBasePtr Problem::installSensor(const std::string& _sen_type, // const std::string& _unique_sensor_name, // const ParamsServer& _server) { - SensorBasePtr sen_ptr = AutoConfSensorFactory::get().create(_sen_type, _unique_sensor_name, _server); + SensorBasePtr sen_ptr = AutoConfFactorySensor::get().create(_sen_type, _unique_sensor_name, _server); sen_ptr->link(getHardware()); return sen_ptr; } @@ -223,7 +223,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // return ProcessorBasePtr(); } - ProcessorBasePtr prc_ptr = ProcessorFactory::get().create(_prc_type, _unique_processor_name, _prc_params); + ProcessorBasePtr prc_ptr = FactoryProcessor::get().create(_prc_type, _unique_processor_name, _prc_params); //Dimension check int prc_dim = prc_ptr->getDim(); @@ -253,7 +253,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // else { assert(file_exists(_params_filename) && "Cannot install processor: parameters' YAML file does not exist."); - ParamsProcessorBasePtr prc_params = ParamsProcessorFactory::get().create(_prc_type, _params_filename); + ParamsProcessorBasePtr prc_params = FactoryParamsProcessor::get().create(_prc_type, _params_filename); return installProcessor(_prc_type, _unique_processor_name, sen_ptr, prc_params); } } @@ -267,7 +267,7 @@ ProcessorBasePtr Problem::installProcessor(const std::string& _prc_type, // if (sen_ptr == nullptr) throw std::runtime_error("Cannot bind processor. Reason: Sensor \"" + _corresponding_sensor_name + "\" not found. Check sensor name, it must match in sensor and processor!"); - ProcessorBasePtr prc_ptr = AutoConfProcessorFactory::get().create(_prc_type, _unique_processor_name, _server); + ProcessorBasePtr prc_ptr = AutoConfFactoryProcessor::get().create(_prc_type, _unique_processor_name, _server); //Dimension check int prc_dim = prc_ptr->getDim(); diff --git a/src/processor/processor_diff_drive.cpp b/src/processor/processor_diff_drive.cpp index f8c5c8c0a..ea18e4334 100644 --- a/src/processor/processor_diff_drive.cpp +++ b/src/processor/processor_diff_drive.cpp @@ -174,7 +174,7 @@ FactorBasePtr ProcessorDiffDrive::emplaceFactor(FeatureBasePtr _feature, // Register in the ProcessorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("ProcessorDiffDrive", ProcessorDiffDrive); WOLF_REGISTER_PROCESSOR_AUTO("ProcessorDiffDrive", ProcessorDiffDrive); diff --git a/src/processor/processor_odom_2d.cpp b/src/processor/processor_odom_2d.cpp index 12266db4b..b5814ab2a 100644 --- a/src/processor/processor_odom_2d.cpp +++ b/src/processor/processor_odom_2d.cpp @@ -171,7 +171,7 @@ FeatureBasePtr ProcessorOdom2d::emplaceFeature(CaptureMotionPtr _capture_motion) } /* namespace wolf */ // Register in the ProcessorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("ProcessorOdom2d", ProcessorOdom2d); WOLF_REGISTER_PROCESSOR_AUTO("ProcessorOdom2d", ProcessorOdom2d); diff --git a/src/processor/processor_odom_3d.cpp b/src/processor/processor_odom_3d.cpp index cca930aec..4ed5bbc0e 100644 --- a/src/processor/processor_odom_3d.cpp +++ b/src/processor/processor_odom_3d.cpp @@ -247,7 +247,7 @@ FactorBasePtr ProcessorOdom3d::emplaceFactor(FeatureBasePtr _feature_motion, Cap } // Register in the SensorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("ProcessorOdom3d", ProcessorOdom3d); WOLF_REGISTER_PROCESSOR_AUTO("ProcessorOdom3d", ProcessorOdom3d); diff --git a/src/sensor/sensor_diff_drive.cpp b/src/sensor/sensor_diff_drive.cpp index ae48fcceb..6655edcd4 100644 --- a/src/sensor/sensor_diff_drive.cpp +++ b/src/sensor/sensor_diff_drive.cpp @@ -48,7 +48,7 @@ SensorDiffDrive::~SensorDiffDrive() } /* namespace wolf */ // Register in the SensorFactory -#include "core/sensor/sensor_factory.h" +#include "core/sensor/factory_sensor.h" namespace wolf { WOLF_REGISTER_SENSOR("SensorDiffDrive", SensorDiffDrive); WOLF_REGISTER_SENSOR_AUTO("SensorDiffDrive", SensorDiffDrive); diff --git a/src/sensor/sensor_odom_2d.cpp b/src/sensor/sensor_odom_2d.cpp index 57af930f6..7b019ae7d 100644 --- a/src/sensor/sensor_odom_2d.cpp +++ b/src/sensor/sensor_odom_2d.cpp @@ -37,7 +37,7 @@ double SensorOdom2d::getRotVarToRotNoiseFactor() const } // Register in the SensorFactory -#include "core/sensor/sensor_factory.h" +#include "core/sensor/factory_sensor.h" namespace wolf { WOLF_REGISTER_SENSOR("SensorOdom2d", SensorOdom2d); WOLF_REGISTER_SENSOR_AUTO("SensorOdom2d", SensorOdom2d); diff --git a/src/sensor/sensor_odom_3d.cpp b/src/sensor/sensor_odom_3d.cpp index a79995b85..179b55e45 100644 --- a/src/sensor/sensor_odom_3d.cpp +++ b/src/sensor/sensor_odom_3d.cpp @@ -40,7 +40,7 @@ SensorOdom3d::~SensorOdom3d() } // namespace wolf // Register in the SensorFactory -#include "core/sensor/sensor_factory.h" +#include "core/sensor/factory_sensor.h" namespace wolf { WOLF_REGISTER_SENSOR("SensorOdom3d", SensorOdom3d); WOLF_REGISTER_SENSOR_AUTO("SensorOdom3d", SensorOdom3d); diff --git a/src/yaml/processor_odom_3d_yaml.cpp b/src/yaml/processor_odom_3d_yaml.cpp index bd05bf330..0a0884454 100644 --- a/src/yaml/processor_odom_3d_yaml.cpp +++ b/src/yaml/processor_odom_3d_yaml.cpp @@ -47,8 +47,8 @@ static ParamsProcessorBasePtr createProcessorOdom3dParams(const std::string & _f return nullptr; } -// Register in the SensorFactory -const bool WOLF_UNUSED registered_prc_odom_3d = ParamsProcessorFactory::get().registerCreator("ProcessorOdom3d", createProcessorOdom3dParams); +// Register in the FactorySensor +const bool WOLF_UNUSED registered_prc_odom_3d = FactoryParamsProcessor::get().registerCreator("ProcessorOdom3d", createProcessorOdom3dParams); } // namespace [unnamed] diff --git a/src/yaml/sensor_odom_2d_yaml.cpp b/src/yaml/sensor_odom_2d_yaml.cpp index d59cd4dec..b8ef1a083 100644 --- a/src/yaml/sensor_odom_2d_yaml.cpp +++ b/src/yaml/sensor_odom_2d_yaml.cpp @@ -39,8 +39,8 @@ static ParamsSensorBasePtr createParamsSensorOdom2d(const std::string & _filenam return nullptr; } -// Register in the SensorFactory -const bool WOLF_UNUSED registered_odom_2d_intr = ParamsSensorFactory::get().registerCreator("SensorOdom2d", createParamsSensorOdom2d); +// Register in the FactorySensor +const bool WOLF_UNUSED registered_odom_2d_intr = FactoryParamsSensor::get().registerCreator("SensorOdom2d", createParamsSensorOdom2d); } // namespace [unnamed] diff --git a/src/yaml/sensor_odom_3d_yaml.cpp b/src/yaml/sensor_odom_3d_yaml.cpp index e437bedcb..5b700eb82 100644 --- a/src/yaml/sensor_odom_3d_yaml.cpp +++ b/src/yaml/sensor_odom_3d_yaml.cpp @@ -41,8 +41,8 @@ static ParamsSensorBasePtr createParamsSensorOdom3d(const std::string & _filenam return nullptr; } -// Register in the SensorFactory -const bool WOLF_UNUSED registered_odom_3d_intr = ParamsSensorFactory::get().registerCreator("SensorOdom3d", createParamsSensorOdom3d); +// Register in the FactorySensor +const bool WOLF_UNUSED registered_odom_3d_intr = FactoryParamsSensor::get().registerCreator("SensorOdom3d", createParamsSensorOdom3d); } // namespace [unnamed] diff --git a/test/dummy/processor_tracker_feature_dummy.cpp b/test/dummy/processor_tracker_feature_dummy.cpp index 4c7636e1b..4693ff76f 100644 --- a/test/dummy/processor_tracker_feature_dummy.cpp +++ b/test/dummy/processor_tracker_feature_dummy.cpp @@ -111,7 +111,7 @@ ProcessorBasePtr ProcessorTrackerFeatureDummy::create(const std::string& _unique } // namespace wolf // Register in the ProcessorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("ProcessorTrackerFeatureDummy", ProcessorTrackerFeatureDummy) } // namespace wolf diff --git a/test/gtest_problem.cpp b/test/gtest_problem.cpp index 01c361d8c..187c0994b 100644 --- a/test/gtest_problem.cpp +++ b/test/gtest_problem.cpp @@ -32,7 +32,7 @@ using namespace Eigen; // Register in the ProcessorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("TRACKER FEATURE DUMMY", ProcessorTrackerFeatureDummy) } // namespace wolf diff --git a/test/gtest_processor_base.cpp b/test/gtest_processor_base.cpp index a9a178e09..f41c0dec4 100644 --- a/test/gtest_processor_base.cpp +++ b/test/gtest_processor_base.cpp @@ -25,7 +25,7 @@ using namespace Eigen; // Register in the ProcessorFactory -#include "core/processor/processor_factory.h" +#include "core/processor/factory_processor.h" namespace wolf { WOLF_REGISTER_PROCESSOR("TRACKER FEATURE DUMMY", ProcessorTrackerFeatureDummy) } // namespace wolf diff --git a/test/gtest_processor_tracker_feature_dummy.cpp b/test/gtest_processor_tracker_feature_dummy.cpp index db3d21954..f7579f2cd 100644 --- a/test/gtest_processor_tracker_feature_dummy.cpp +++ b/test/gtest_processor_tracker_feature_dummy.cpp @@ -1,7 +1,7 @@ // wolf includes #include "core/utils/utils_gtest.h" -#include "core/sensor/sensor_factory.h" +#include "core/sensor/factory_sensor.h" #include "dummy/processor_tracker_feature_dummy.h" #include "core/capture/capture_void.h" diff --git a/test/gtest_processor_tracker_landmark_dummy.cpp b/test/gtest_processor_tracker_landmark_dummy.cpp index 3eb37a026..8963211c4 100644 --- a/test/gtest_processor_tracker_landmark_dummy.cpp +++ b/test/gtest_processor_tracker_landmark_dummy.cpp @@ -1,7 +1,7 @@ // wolf includes #include "core/utils/utils_gtest.h" -#include "core/sensor/sensor_factory.h" +#include "core/sensor/factory_sensor.h" #include "dummy/processor_tracker_landmark_dummy.h" #include "core/capture/capture_void.h" diff --git a/test/yaml/processor_odom_3d.yaml b/test/yaml/processor_odom_3d.yaml index 65b00b967..672421b5d 100644 --- a/test/yaml/processor_odom_3d.yaml +++ b/test/yaml/processor_odom_3d.yaml @@ -1,4 +1,4 @@ -type: "ProcessorOdom3d" # This must match the KEY used in the SensorFactory. Otherwise it is an error. +type: "ProcessorOdom3d" # This must match the KEY used in the FactorySensor. Otherwise it is an error. time_tolerance: 0.01 # seconds diff --git a/test/yaml/sensor_odom_2d.yaml b/test/yaml/sensor_odom_2d.yaml index 0841d40b3..2d26af901 100644 --- a/test/yaml/sensor_odom_2d.yaml +++ b/test/yaml/sensor_odom_2d.yaml @@ -1,4 +1,4 @@ -type: "SensorOdom2d" # This must match the KEY used in the SensorFactory. Otherwise it is an error. +type: "SensorOdom2d" # This must match the KEY used in the FactorySensor. Otherwise it is an error. k_disp_to_disp: 0.02 # m^2 / m k_rot_to_rot: 0.01 # rad^2 / rad diff --git a/test/yaml/sensor_odom_3d.yaml b/test/yaml/sensor_odom_3d.yaml index 58db1c088..8eb2b2350 100644 --- a/test/yaml/sensor_odom_3d.yaml +++ b/test/yaml/sensor_odom_3d.yaml @@ -1,4 +1,4 @@ -type: "SensorOdom3d" # This must match the KEY used in the SensorFactory. Otherwise it is an error. +type: "SensorOdom3d" # This must match the KEY used in the FactorySensor. Otherwise it is an error. k_disp_to_disp: 0.02 # m^2 / m k_disp_to_rot: 0.02 # rad^2 / m -- GitLab