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

Update FactorySensor doc

parent c907f392
No related branches found
No related tags found
1 merge request!350Resolve "Factory documentation"
Pipeline #5593 passed
...@@ -152,7 +152,7 @@ namespace wolf ...@@ -152,7 +152,7 @@ namespace wolf
* *
* This API includes an element of type TypeInput, which might be either a std::string, or a YAML::node: * This API includes an element of type TypeInput, which might be either a std::string, or a YAML::node:
* - ````std::string```` is used to indicate the name of a configuration file. These files are usually YAML files containing configuration data to create your object. * - ````std::string```` is used to indicate the name of a configuration file. These files are usually YAML files containing configuration data to create your object.
* - ````YAML::Node```` is used to access parts of a YAML file already encoded as nodes, such as when loading landmarks from a SLAM map stored as a YAML file. * - ````YAML::Node```` is used to access parts of a YAML file already encoded as nodes, such as when loading landmarks from a SLAM map stored as a YAML file.
* *
* Two examples: * Two examples:
* *
......
...@@ -27,12 +27,12 @@ namespace wolf ...@@ -27,12 +27,12 @@ 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,
* - "CAMERA" for SensorCamera * - "SensorCamera" for SensorCamera
* - "ODOM 2d" for SensorOdom2d * - "SensorOdom2d" for SensorOdom2d
* - "GPS FIX" for SensorGPSFix * - "SensorOdom3d" for SensorOdom3d
* - "SensorDiffDrive" for SensorDiffDrive
* *
* The rule to make new TYPE strings unique is that you skip the prefix 'Sensor' from your class name, * TYPE is always a std::string with literally the same text as the derived class name, e.g.:
* and you build a string in CAPITALS with space separators, e.g.:
* - SensorCamera -> ````"CAMERA"```` * - SensorCamera -> ````"CAMERA"````
* - SensorLaser2d -> ````"LASER 2d"```` * - SensorLaser2d -> ````"LASER 2d"````
* - etc. * - etc.
...@@ -69,7 +69,7 @@ namespace wolf ...@@ -69,7 +69,7 @@ namespace wolf
* that knows how to create your specific sensor, e.g.: * that knows how to create your specific sensor, e.g.:
* *
* \code * \code
* FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * FactorySensor::get().registerCreator("SensorCamera", SensorCamera::create);
* \endcode * \endcode
* *
* The method SensorCamera::create() exists in the SensorCamera class as a static method. * The method SensorCamera::create() exists in the SensorCamera class as a static method.
...@@ -89,7 +89,7 @@ namespace wolf ...@@ -89,7 +89,7 @@ namespace wolf
* For example, in sensor_camera.cpp we find the line: * For example, in sensor_camera.cpp we find the line:
* *
* \code * \code
* const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * const bool registered_camera = FactorySensor::get().registerCreator("SensorCamera", SensorCamera::create);
* \endcode * \endcode
* *
* which is a static invocation (i.e., it is placed at global scope outside of the SensorCamera class). * which is a static invocation (i.e., it is placed at global scope outside of the SensorCamera class).
...@@ -99,7 +99,7 @@ namespace wolf ...@@ -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. * The method unregisterCreator() unregisters the SensorXxx::create() method. It only needs to be passed the string of the sensor type.
* *
* \code * \code
* FactorySensor::get().unregisterCreator("CAMERA"); * FactorySensor::get().unregisterCreator("SensorCamera");
* \endcode * \endcode
* *
* #### Creating sensors * #### Creating sensors
...@@ -109,7 +109,7 @@ namespace wolf ...@@ -109,7 +109,7 @@ namespace wolf
* To create e.g. a SensorCamera, you type: * To create e.g. a SensorCamera, you type:
* *
* \code * \code
* FactorySensor::get().create("CAMERA", "Front-left camera", extrinsics, intrinsics_ptr); * FactorySensor::get().create("SensorCamera", "Front-left camera", extrinsics, intrinsics_ptr);
* \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,10 +130,11 @@ namespace wolf ...@@ -130,10 +130,11 @@ namespace wolf
* assert(_extrinsics_pq.size() == 7 && "Bad extrinsics vector length. Should be 7 for 3d."); * assert(_extrinsics_pq.size() == 7 && "Bad extrinsics vector length. Should be 7 for 3d.");
* *
* // cast instrinsics to good type * // cast instrinsics to good type
* ParamsSensorCamera* intrinsics_ptr = (ParamsSensorCamera*) _intrinsics; * ParamsSensorCameraPtr intrinsics_ptr = std::static_pointer_cast<ParamsSensorCamera>(_intrinsics);
* *
* // Do create the SensorCamera object, and complete its setup * // Do create the SensorCamera object, and complete its setup
* SensorCamera* sen_ptr = new SensorCamera(_extrinsics_pq, intrinsics_ptr); * SensorCameraPtr sen_ptr = std::make_shared<SensorCamera>(_extrinsics_pq, intrinsics_ptr);
*
* sen_ptr->setName(_unique_name); * sen_ptr->setName(_unique_name);
* *
* return sen_ptr; * return sen_ptr;
...@@ -148,7 +149,7 @@ namespace wolf ...@@ -148,7 +149,7 @@ namespace wolf
* Put the code either at global scope (you must define a dummy variable for this), * Put the code either at global scope (you must define a dummy variable for this),
* \code * \code
* namespace { * namespace {
* const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create); * const bool registered_camera = FactorySensor::get().registerCreator("SensorCamera", SensorCamera::create);
* } * }
* main () { ... } * main () { ... }
* \endcode * \endcode
...@@ -183,30 +184,29 @@ namespace wolf ...@@ -183,30 +184,29 @@ namespace wolf
* int main() { * int main() {
* *
* // To create a camera, provide: * // To create a camera, provide:
* // a type = "CAMERA", * // a type = "SensorCamera",
* // a name = "Front-left camera", * // a name = "Front-left camera",
* // an extrinsics vector, and * // an extrinsics vector, and
* // a pointer to the intrinsics struct: * // a pointer to the intrinsics struct:
* *
* Eigen::VectorXd extrinsics_1(7); // give it some values... * Eigen::VectorXd extrinsics_1(7); // give it some values...
* ParamsSensorCamera intrinsics_1({...}); // see FactoryParamsSensor to fill in the derived struct * ParamsSensorCameraPtr intrinsics_1 = FactoryParamsSensor::get().create("ParamsSensorCamera", camera_1.yaml); // see FactoryParamsSensor to fill in the derived struct
* *
* SensorBasePtr camera_1_ptr = * SensorBasePtr camera_1_ptr =
* FactorySensor::get().create ( "CAMERA" , "Front-left camera" , extrinsics_1 , &intrinsics_1 ); * FactorySensor::get().create ( "SensorCamera" , "Front-left camera" , extrinsics_1 , intrinsics_1 );
* *
* // A second camera... with a different name! * // A second camera... with a different name!
* *
* Eigen::VectorXd extrinsics_2(7); * Eigen::VectorXd extrinsics_2(7);
* ParamsSensorCamera intrinsics_2({...}); * ParamsSensorCameraPtr intrinsics_2 = FactoryParamsSensor::get().create("ParamsSensorCamera", camera_2.yaml);
* *
* SensorBasePtr camera_2_ptr = * SensorBasePtr camera_2_ptr =
* FactorySensor::get().create( "CAMERA" , "Front-right camera" , extrinsics_2 , &intrinsics_2 ); * FactorySensor::get().create( "SensorCamera" , "Front-right camera" , extrinsics_2 , intrinsics_2 );
* *
* return 0; * return 0;
* } * }
* \endcode * \endcode
* *
* You can also check the code in the example file ````src/examples/test_wolf_factories.cpp````.
*/ */
// ParamsSensor factory // ParamsSensor factory
......
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