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
*
* 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.
* - ````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:
*
......
......@@ -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.
* Currently, the following sensor types are implemented,
* - "CAMERA" for SensorCamera
* - "ODOM 2d" for SensorOdom2d
* - "GPS FIX" for SensorGPSFix
* - "SensorCamera" for SensorCamera
* - "SensorOdom2d" for SensorOdom2d
* - "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,
* and you build a string in CAPITALS with space separators, e.g.:
* TYPE is always a std::string with literally the same text as the derived class name, e.g.:
* - SensorCamera -> ````"CAMERA"````
* - SensorLaser2d -> ````"LASER 2d"````
* - etc.
......@@ -69,7 +69,7 @@ namespace wolf
* that knows how to create your specific sensor, e.g.:
*
* \code
* FactorySensor::get().registerCreator("CAMERA", SensorCamera::create);
* FactorySensor::get().registerCreator("SensorCamera", 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 = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create);
* 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).
......@@ -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
* FactorySensor::get().unregisterCreator("CAMERA");
* FactorySensor::get().unregisterCreator("SensorCamera");
* \endcode
*
* #### Creating sensors
......@@ -109,7 +109,7 @@ namespace wolf
* To create e.g. a SensorCamera, you type:
*
* \code
* FactorySensor::get().create("CAMERA", "Front-left camera", extrinsics, intrinsics_ptr);
* FactorySensor::get().create("SensorCamera", "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
......@@ -130,10 +130,11 @@ namespace wolf
* assert(_extrinsics_pq.size() == 7 && "Bad extrinsics vector length. Should be 7 for 3d.");
*
* // 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
* 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);
*
* return sen_ptr;
......@@ -148,7 +149,7 @@ namespace wolf
* Put the code either at global scope (you must define a dummy variable for this),
* \code
* namespace {
* const bool registered_camera = FactorySensor::get().registerCreator("CAMERA", SensorCamera::create);
* const bool registered_camera = FactorySensor::get().registerCreator("SensorCamera", SensorCamera::create);
* }
* main () { ... }
* \endcode
......@@ -183,30 +184,29 @@ namespace wolf
* int main() {
*
* // To create a camera, provide:
* // a type = "CAMERA",
* // a type = "SensorCamera",
* // a name = "Front-left camera",
* // an extrinsics vector, and
* // a pointer to the intrinsics struct:
*
* Eigen::VectorXd extrinsics_1(7); // give it some values...
* ParamsSensorCamera intrinsics_1({...}); // see FactoryParamsSensor to fill in the derived struct
* Eigen::VectorXd extrinsics_1(7); // give it some values...
* ParamsSensorCameraPtr intrinsics_1 = FactoryParamsSensor::get().create("ParamsSensorCamera", camera_1.yaml); // see FactoryParamsSensor to fill in the derived struct
*
* 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!
*
* Eigen::VectorXd extrinsics_2(7);
* ParamsSensorCamera intrinsics_2({...});
* Eigen::VectorXd extrinsics_2(7);
* ParamsSensorCameraPtr intrinsics_2 = FactoryParamsSensor::get().create("ParamsSensorCamera", camera_2.yaml);
*
* 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;
* }
* \endcode
*
* You can also check the code in the example file ````src/examples/test_wolf_factories.cpp````.
*/
// 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