Saving and loading parameters.
More...
#include <libraries/fdcl_param/include/fdcl/param.hpp>
|
| param (std::string file_name) |
|
void | open (std::string fname) |
|
void | close (void) |
|
void | read (const std::string param_name, bool &value) |
|
void | read (const std::string param_name, double &value) |
|
void | read (const std::string param_name, int &value) |
|
void | read (const std::string param_name, std::string &value) |
|
void | read (const std::string param_name, Eigen::Matrix< double, 3, 3 > &value) |
|
void | read (const std::string param_name, Eigen::Matrix< double, 4, 1 > &value) |
|
void | read (const std::string param_name, Eigen::Matrix< double, 3, 1 > &value) |
|
void | read (const std::string param_name, Eigen::Matrix< double, 15, 15 > &value) |
|
void | read (const std::string param_name, Eigen::Matrix< double, 2, 1 > &value) |
|
template<typename Derived > |
void | read (const std::string param_name, Eigen::MatrixBase< Derived > &value) |
|
void | save (const std::string param_name, bool value) |
|
void | save (const std::string param_name, double value) |
|
void | save (const std::string param_name, int value) |
|
void | save (const std::string param_name, const std::string value) |
|
void | save (const std::string param_name, Eigen::Matrix< double, 3, 3 > &value) |
|
template<typename Derived > |
void | save (const std::string param_name, Eigen::MatrixBase< Derived > &value) |
|
Saving and loading parameters.
This class reads parameters from and to external files. This makes easier to update parameters in the code, without compiling the code again when a single parameter is changed. Please follow the below guidelines for making the config files:
- Try to use the file extension with ".cfg", this is not required, though helps to keep the consistency
- Parameters are expected to be grouped: each parameter must have a group name and a parameter name
for example: GPS: on: 0 port: "/dev/ttyS0" IMU: on: 1
- Parameters in the same group must include ONE space character at the begining of the line, and NO spaces at the begining of the line for groups
void fdcl::param::close |
( |
void |
| ) |
|
void fdcl::param::open |
( |
std::string |
fname | ) |
|
Open the config files for reading/ writing
- Parameters
-
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
bool & |
value |
|
) |
| |
Reads a boolean type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
double & |
value |
|
) |
| |
Reads a double type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
int & |
value |
|
) |
| |
Reads a int type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
std::string & |
value |
|
) |
| |
Reads a string type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
Eigen::Matrix< double, 3, 3 > & |
value |
|
) |
| |
Reads a Matrix3 type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
Eigen::Matrix< double, 4, 1 > & |
value |
|
) |
| |
Reads a Vector4 type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
Eigen::Matrix< double, 3, 1 > & |
value |
|
) |
| |
Reads a Vector3 type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
Eigen::Matrix< double, 2, 1 > & |
value |
|
) |
| |
Reads a Vector2 type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
template<typename Derived >
void fdcl::param::read |
( |
const std::string |
param_name, |
|
|
Eigen::MatrixBase< Derived > & |
value |
|
) |
| |
Reads a any Eigen vector type parameter from the config file
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
void fdcl::param::save |
( |
const std::string |
param_name, |
|
|
bool |
value |
|
) |
| |
void fdcl::param::save |
( |
const std::string |
param_name, |
|
|
double |
value |
|
) |
| |
void fdcl::param::save |
( |
const std::string |
param_name, |
|
|
int |
value |
|
) |
| |
void fdcl::param::save |
( |
const std::string |
param_name, |
|
|
const std::string |
value |
|
) |
| |
void fdcl::param::save |
( |
const std::string |
param_name, |
|
|
Eigen::Matrix< double, 3, 3 > & |
value |
|
) |
| |
void save(const std::string param_name, Matrix3 value) Saves a given Matrix3 type parameter to the config files
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
template<typename Derived >
void fdcl::param::save |
( |
const std::string |
param_name, |
|
|
Eigen::MatrixBase< Derived > & |
value |
|
) |
| |
void save(const std::string param_name, Eigen::MatrixBase<Derived> value)
Saves a given Eigen type parameter to the config files
- Parameters
-
param_name | name of the parameter |
value | varaiable to save the read parameter value |
std::string fdcl::param::file_name |
name of the config file where the data is is saved or read from
std::fstream fdcl::param::file_stream |
fstream object for the config file
bool fdcl::param::is_open = false |
check if the file is open
The documentation for this class was generated from the following file:
- cpp/libraries/fdcl_param/include/fdcl/param.hpp