Skip to content
Snippets Groups Projects
Commit 4384a99a authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

mostly doc

parent ae8b2c50
No related branches found
No related tags found
1 merge request!448Draft: Resolve "Implementation of new nodes creation"
Pipeline #11170 failed
......@@ -70,9 +70,10 @@ namespace wolf
*
* \code
* static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const ParamsServer& _server);
* static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const std::string& _yaml_filepath);
* \endcode
*
* They follow the general implementation shown below:
* They follow the general implementations shown below:
*
* \code
* static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const ParamsServer& _server)
......@@ -85,6 +86,22 @@ namespace wolf
*
* return sensor;
* }
* static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const std::string& _yaml_filepath)
* {
* // parse the yaml file
* auto parser = ParserYaml(_yaml_filepath, "", true);
*
* // load the parameters
* auto server = ParamsServer(parser.getParams());
*
* // Do create the Sensor Parameters --- example: ParamsSensorCamera
* auto params = std::make_shared<ParamsSensorCamera>(_unique_name, server);
*
* // Do create the Sensor object --- example: SensorCamera
* auto sensor = std::make_shared<SensorCamera>(_unique_name, _dim, params, server);
*
* return sensor;
* }
* \endcode
*
* #### Creating sensors
......@@ -97,6 +114,12 @@ namespace wolf
* auto camera_ptr = FactorySensor::create("SensorCamera", "Front-left camera", 3, param_server);
* \endcode
*
* or:
*
* \code
* auto camera_ptr = FactorySensorYaml::create("SensorCamera", "Front-left camera", 3, yaml_filepath);
* \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!
*
......@@ -121,12 +144,16 @@ namespace wolf
* namespace {
* const bool registered_camera = FactorySensor::registerCreator("SensorCamera", SensorCamera::create);
* }
* namespace {
* const bool registered_camera_yaml = FactorySensorYaml::registerCreator("SensorCamera", SensorCamera::create);
* }
* main () { ... }
* \endcode
* or inside your main(), where a direct call is possible:
* \code
* main () {
* FactorySensor::registerCreator("SensorCamera", SensorCamera::create);
* FactorySensor::registerCreatorYaml("SensorCamera", SensorCamera::create);
* ...
* }
* \endcode
......@@ -136,9 +163,11 @@ namespace wolf
* \code
* namespace {
* const bool registered_camera = FactorySensor::registerCreator("SensorCamera", SensorCamera::create);
* const bool registered_camera_yaml = FactorySensorYaml::registerCreator("SensorCamera", SensorCamera::create);
* }
* \endcode
* Automatic registration is recommended in wolf, and implemented in the classes shipped with it using the macro WOLF_REGISTER_SENSOR(SensorType).
* Automatic registration is recommended in wolf, and implemented in the classes shipped with it using the macros
* WOLF_REGISTER_SENSOR(SensorType) and WOLF_REGISTER_SENSOR_YAML(SensorType).
* You are free to comment out these lines and place them wherever you consider it more convenient for your design.
*
* #### Example 2: creating sensors
......@@ -160,24 +189,18 @@ namespace wolf
* // the parameter server or a yaml file
*
* SensorBasePtr camera_1_ptr =
* FactorySensor::create ( "SensorCamera" ,
* "Front-left camera" ,
* extrinsics_1 ,
* intrinsics_1 );
* FactorySensor::create ( "SensorCamera",
* "Front-left camera" ,
* 3 ,
* parameter_server );
*
* // A second camera... with a different name!
*
* Eigen::VectorXd extrinsics_2(7);
*
* ParamsSensorCameraPtr intrinsics_2 =
* FactoryParamsSensor::create("ParamsSensorCamera",
* camera_2.yaml);
*
* SensorBasePtr camera_2_ptr =
* FactorySensor::create( "SensorCamera" ,
* "Front-right camera" ,
* extrinsics_2 ,
* intrinsics_2 );
* "Front-right camera" ,
* 3 ,
* yaml_filename );
*
* return 0;
* }
......
......@@ -58,27 +58,27 @@ namespace wolf {
* ParamsSensorClassPtr _params)
*
*/
#define WOLF_SENSOR_CREATE(SensorClass, ParamsSensorClass) \
static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const ParamsServer& _server) \
{ \
auto params = std::make_shared<ParamsSensorClass>(_unique_name, _server); \
\
auto sensor = std::make_shared<SensorClass>(_unique_name, _dim, params, _server); \
\
return sensor; \
} \
static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const std::string& _yaml_file) \
{ \
auto parser = ParserYaml(_yaml_file, "", true); \
\
auto server = ParamsServer(parser.getParams()); \
\
auto params = std::make_shared<ParamsSensorClass>(_unique_name, server); \
\
auto sensor = std::make_shared<SensorClass>(_unique_name, _dim, params, server); \
\
return sensor; \
} \
#define WOLF_SENSOR_CREATE(SensorClass, ParamsSensorClass) \
static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const ParamsServer& _server) \
{ \
auto params = std::make_shared<ParamsSensorClass>(_unique_name, _server); \
\
auto sensor = std::make_shared<SensorClass>(_unique_name, _dim, params, _server); \
\
return sensor; \
} \
static SensorBasePtr create(const std::string& _unique_name, SizeEigen _dim, const std::string& _yaml_filepath) \
{ \
auto parser = ParserYaml(_yaml_filepath, "", true); \
\
auto server = ParamsServer(parser.getParams()); \
\
auto params = std::make_shared<ParamsSensorClass>(_unique_name, server); \
\
auto sensor = std::make_shared<SensorClass>(_unique_name, _dim, params, server); \
\
return sensor; \
} \
/** \brief base struct for intrinsic sensor parameters
*
......
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