Skip to content
Snippets Groups Projects
Commit 122a3384 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Document FactorySensor

parent 50c40374
No related branches found
No related tags found
1 merge request!350Resolve "Factory documentation"
...@@ -27,27 +27,21 @@ namespace wolf ...@@ -27,27 +27,21 @@ namespace wolf
* *
* Specific object creation is invoked by `create(TYPE, params ... )`, and the TYPE of sensor is identified with a string. * Specific object creation is invoked by `create(TYPE, params ... )`, and the TYPE of sensor is identified with a string.
* Currently, the following sensor types are implemented, * Currently, the following sensor types are implemented,
* - "SensorOdom2d" for SensorOdom2d * - "SensorOdom2d" for SensorOdom2d
* - "SensorOdom3d" for SensorOdom3d * - "SensorOdom3d" for SensorOdom3d
* - "SensorDiffDrive" for SensorDiffDrive * - "SensorDiffDrive" for SensorDiffDrive
* - "SensorCamera" for SensorCamera // in plugin 'vision' * - "SensorCamera" for SensorCamera // in plugin 'vision'
* - "SensorLaser2d" for SensorLaser2d // in plugin 'laser' * - "SensorLaser2d" for SensorLaser2d // in plugin 'laser'
* *
* among others * among others.
* *
* TYPE is always a std::string with literally the same text as the derived class name, e.g.: * Find general Factory documentation in class Factory:
* - SensorCamera -> `"SensorCamera"` * - Access the factory
* - SensorLaser2d -> `"SensorLaser2d"` * - Register/unregister creators
* - etc. * - Invoke object creation
* *
* The methods to create specific sensors are called __creators__. * This documentation shows you how to use the FactorySensor specifically:
* Creators must be registered to the factory before they can be invoked for sensor creation.
*
* Find general Factory documentation in class Factory.
*
* This documentation shows you how to:
* - Write sensor creators. * - Write sensor creators.
* - Register and unregister creators
* - Create sensors * - Create sensors
* *
* #### Write sensor creators * #### Write sensor creators
...@@ -57,7 +51,7 @@ namespace wolf ...@@ -57,7 +51,7 @@ namespace wolf
* static SensorBasePtr create(const std::string& _name, Eigen::VectorXd& _params_extrinsics, ParamsSensorBasePtr _params_sensor); * static SensorBasePtr create(const std::string& _name, Eigen::VectorXd& _params_extrinsics, ParamsSensorBasePtr _params_sensor);
* \endcode * \endcode
* *
* The follow the general implementation shown below: * They follow the general implementation shown below:
* *
* \code * \code
* static SensorBasePtr create(const std::string& _unique_name, Eigen::VectorXd& _params_extrinsics, ParamsSensorBasePtr _params_sensor) * static SensorBasePtr create(const std::string& _unique_name, Eigen::VectorXd& _params_extrinsics, ParamsSensorBasePtr _params_sensor)
...@@ -78,40 +72,6 @@ namespace wolf ...@@ -78,40 +72,6 @@ namespace wolf
* } * }
* \endcode * \endcode
* *
*
*
* #### Registering sensor creators
* Prior to invoking the creation of a sensor of a particular type,
* you must register the creator for this type into the factory.
*
* Registering sensor creators into the factory is done through registerCreator().
* You provide a sensor type string (above), and a pointer to a static method
* that knows how to create your specific sensor, e.g.:
*
* \code
* FactorySensor::get().registerCreator("SensorCamera", SensorCamera::create);
* \endcode
*
* The method SensorCamera::create(...) is the creator written in the previous section.
*
* #### Achieving automatic registration
* Currently, registering is performed in each specific SensorXxxx source file, sensor_xxxx.cpp.
* For example, in sensor_camera.cpp we find the line:
*
* \code
* const bool registered_camera = FactorySensor::get().registerCreator("SensorCamera", SensorCamera::create);
* \endcode
*
* which is a static invocation (i.e., it is placed at global scope outside of the SensorCamera class).
* Therefore, at application level, all sensors that have a .cpp file compiled are automatically registered.
*
* #### Unregistering sensor creators
* The method unregisterCreator() unregisters the SensorXxx::create() method. It only needs to be passed the string of the sensor type.
*
* \code
* FactorySensor::get().unregisterCreator("SensorCamera");
* \endcode
*
* #### Creating sensors * #### Creating sensors
* Note: Prior to invoking the creation of a sensor of a particular type, * Note: Prior to invoking the creation of a sensor of a particular type,
* you must register the creator for this type into the factory. * you must register the creator for this type into the factory.
...@@ -119,7 +79,7 @@ namespace wolf ...@@ -119,7 +79,7 @@ namespace wolf
* To create e.g. a SensorCamera, you type: * To create e.g. a SensorCamera, you type:
* *
* \code * \code
* FactorySensor::get().create("SensorCamera", "Front-left camera", params_extrinsics, params_camera); * auto camera_ptr = FactorySensor::get().create("SensorCamera", "Front-left camera", params_extrinsics, params_camera);
* \endcode * \endcode
* *
* where ABSOLUTELY ALL input parameters are important. In particular, the sensor name "Front-left camera" will be used to identify this camera * where ABSOLUTELY ALL input parameters are important. In particular, the sensor name "Front-left camera" will be used to identify this camera
...@@ -130,7 +90,7 @@ namespace wolf ...@@ -130,7 +90,7 @@ namespace wolf
* - FactoryProcessor: to create processors that will be bound to sensors. * - FactoryProcessor: to create processors that will be bound to sensors.
* - Problem::installSensor() : to install sensors in WOLF Problem. * - Problem::installSensor() : to install sensors in WOLF Problem.
* *
* #### Example 1: writing a specific sensor creator * #### Example 1: writing a SensorCamera creator
* Here is an example of SensorCamera::create() extracted from sensor_camera.cpp: * Here is an example of SensorCamera::create() extracted from sensor_camera.cpp:
* *
* \code * \code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment