diff --git a/include/core/common/factory.h b/include/core/common/factory.h index bd0a5a129c8f076d8d6f3842c1e753046daa4a79..c9aa0cd1980d55577179a07be2c6c819055d2b4b 100644 --- a/include/core/common/factory.h +++ b/include/core/common/factory.h @@ -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: * diff --git a/include/core/sensor/factory_sensor.h b/include/core/sensor/factory_sensor.h index ff0574aaadc6a52015a6c9e4f076a1ec64d968c0..d16b46bb216871cd87b9ec74916d4560ab4569f8 100644 --- a/include/core/sensor/factory_sensor.h +++ b/include/core/sensor/factory_sensor.h @@ -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