Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ROBOOP::Config Class Reference

#include <config.h>

List of all members.


Detailed Description

Handle configuration files.

The file syntax used is:

  • [section_name]
  • one or more entries for that section:
    field_name: value

White space is ignored, but a newline must follow each section or field entry

The minimal entries required to avoid warnings are (can be any order):

  • [chain_name]
    • Name: - a string identifier
    • DH: - whether or not the chain specification is standard Denavit-Hartenberg (non-zero), or modified Denavit-Hartenberg (0)
    • Fix: - ?
    • MinPara: - ?
    • dof: - number of links in the chain
    • Motor: - ?
    • Stl: - ?
  • For each link N: 1..dof
    [chain_name_LINKN]
    • joint_type: - revolute (0), prismatic (1)
    • theta: - DH theta parameter
    • d: - DH d parameter
    • a: - DH a parameter
    • alpha: - DH alpha parameter
    • theta_min: - minimum achievable joint position
    • theta_max: - maximum achievable joint position
    • m: - mass of link
    • cx: - x position of center of gravity for link
    • cy: - y position of center of gravity for link
    • cz: - z position of center of gravity for link
    • Ixx: - xx entry of inertia matrix
    • Ixy: - xy entry of inertia matrix
    • Ixz: - xz entry of inertia matrix
    • Iyy: - yy entry of inertia matrix
    • Iyz: - yz entry of inertia matrix
    • Izz: - zz entry of inertia matrix

Additional entries may be defined, but will be silently ignored.

Definition at line 122 of file config.h.


Public Member Functions

 Config ()
 Config (const std::string &filename_, bool doRead=false)
 Constructor.
 Config (const Config &x)
 Constructor.
Configoperator= (const Config &x)
 Overload = operator.
short read_conf ()
 Read a configuration file.
void print ()
 Print the configuration data.
bool section_exists (const std::string &section) const
 Test to see if a section exists.
bool parameter_exists (const std::string &section, const std::string &parameter) const
 Test to see if a parameter exists within a section.
short select_string (const std::string section, const std::string parameter, std::string &value) const
 Get a parameter data, of a certain section, into the string value.
short select_bool (const std::string section, const std::string parameter, bool &value) const
 Get a parameter data, of a certain section, into the bool value.
short select_short (const std::string section, const std::string parameter, short &value) const
 Get a parameter data, of a certain section, into the short value.
short select_int (const std::string section, const std::string parameter, int &value) const
 Get a parameter data, of a certain section, into the int value.
short select_float (const std::string section, const std::string parameter, float &value) const
 Get a parameter data, of a certain section, into the float value.
short select_double (const std::string section, const std::string parameter, double &value) const
 Get a parameter data, of a certain section, into the double value.
short select_real (const std::string section, const std::string parameter, Real &value) const
 Get a parameter data, of a certain section, into the Real value.
short write_conf (const std::string name, const std::string file_title, const int space_between_column)
 Write the configuration information, contained in conf, on disk.
void add_string (const std::string section, const std::string parameter, const std::string value)
 Added the value(string) of the parameter in the section in the configuration data.
void add_bool (const std::string section, const std::string parameter, const bool value)
 Added the value (bool) of the parameter in the section in the configuration data.
void add_int (const std::string section, const std::string parameter, const int value)
 Added the value (int) of the parameter in the section in the configuration data.
void add_float (const std::string section, const std::string parameter, const float value)
 Added the value (float) of the parameter in the section in the configuration data.
void add_double (const std::string section, const std::string parameter, const double value)
 Added the value (double) of the parameter in the section in the configuration data.
void add_real (const std::string section, const std::string parameter, const Real value)
 Added the value (Real) of the parameter in the section in the configuration data.

Private Types

typedef std::map< std::string,
std::map< std::string,
std::string > > 
confdata_t
 holds configuration data - a map from section name to sub-map of parameters to values

Private Attributes

confdata_t conf
 Data store from/to configuration file.
std::string filename
 Configuration file name.

Member Typedef Documentation

typedef std::map<std::string, std::map<std::string, std::string> > ROBOOP::Config::confdata_t [private]

holds configuration data - a map from section name to sub-map of parameters to values

Definition at line 166 of file config.h.


Constructor & Destructor Documentation

ROBOOP::Config::Config (  )  [inline]

Definition at line 124 of file config.h.

ROBOOP::Config::Config ( const std::string &  filename_,
bool  doRead = false 
)

Constructor.

Definition at line 75 of file config.cpp.

ROBOOP::Config::Config ( const Config x  ) 

Constructor.

Definition at line 83 of file config.cpp.


Member Function Documentation

Config & ROBOOP::Config::operator= ( const Config x  ) 

Overload = operator.

Definition at line 89 of file config.cpp.

short ROBOOP::Config::read_conf (  ) 

Read a configuration file.

This function reads the configuration file specified in the constructor parameter. The information is stored in the variable conf.

A configuration file contains section(s) (between [ ]), and the section(s) contains parameter(s) with there respective value(s). The section and the parameter are always access via a string. Below is an exemple: one section named PUMA560_mDH, and two parameters.

[PUMA560_mDH] DH: 0 dof: 6

Definition at line 97 of file config.cpp.

Referenced by Config(), and ROBOOP::Control_Select::set_control().

void ROBOOP::Config::print (  ) 

Print the configuration data.

Definition at line 240 of file config.cpp.

bool ROBOOP::Config::section_exists ( const std::string &  section  )  const

Test to see if a section exists.

Returns:
true if section is found

Definition at line 251 of file config.cpp.

bool ROBOOP::Config::parameter_exists ( const std::string &  section,
const std::string &  parameter 
) const

Test to see if a parameter exists within a section.

Returns:
true if parameter is found within section

Definition at line 260 of file config.cpp.

Referenced by ROBOOP::Robot_basic::Robot_basic().

short ROBOOP::Config::select_string ( const std::string  section,
const std::string  parameter,
std::string &  value 
) const

Get a parameter data, of a certain section, into the string value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 272 of file config.cpp.

Referenced by select_bool(), select_double(), select_float(), select_int(), select_real(), select_short(), and ROBOOP::Control_Select::set_control().

short ROBOOP::Config::select_bool ( const std::string  section,
const std::string  parameter,
bool &  value 
) const

Get a parameter data, of a certain section, into the bool value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 292 of file config.cpp.

Referenced by ROBOOP::Robot_basic::Robot_basic().

short ROBOOP::Config::select_short ( const std::string  section,
const std::string  parameter,
short &  value 
) const

Get a parameter data, of a certain section, into the short value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 344 of file config.cpp.

short ROBOOP::Config::select_int ( const std::string  section,
const std::string  parameter,
int &  value 
) const

Get a parameter data, of a certain section, into the int value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 318 of file config.cpp.

Referenced by ROBOOP::Robot_basic::Robot_basic(), and ROBOOP::Control_Select::set_control().

short ROBOOP::Config::select_float ( const std::string  section,
const std::string  parameter,
float &  value 
) const

Get a parameter data, of a certain section, into the float value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 370 of file config.cpp.

short ROBOOP::Config::select_double ( const std::string  section,
const std::string  parameter,
double &  value 
) const

Get a parameter data, of a certain section, into the double value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 396 of file config.cpp.

Referenced by ROBOOP::Robot_basic::Robot_basic().

short ROBOOP::Config::select_real ( const std::string  section,
const std::string  parameter,
Real value 
) const

Get a parameter data, of a certain section, into the Real value.

Returns:
0 or SECTION_OR_PARAMETER_DOES_NOT_EXIST if the data can not be found.

Definition at line 422 of file config.cpp.

Referenced by ROBOOP::Control_Select::set_control().

short ROBOOP::Config::write_conf ( const std::string  name,
const std::string  file_title,
const int  space_between_column 
)

Write the configuration information, contained in conf, on disk.

Parameters:
name,: Configuration file name.
file_title,: Title in the configuration file header.
space_between_column,: Number of blanks between : (of a parameter) and it's value.

Definition at line 448 of file config.cpp.

void ROBOOP::Config::add_string ( const std::string  section,
const std::string  parameter,
const std::string  value 
)

Added the value(string) of the parameter in the section in the configuration data.

The functions will added the parameter and the section if it does not already exist.

Definition at line 481 of file config.cpp.

Referenced by add_bool(), add_double(), add_float(), add_int(), and add_real().

void ROBOOP::Config::add_bool ( const std::string  section,
const std::string  parameter,
const bool  value 
)

Added the value (bool) of the parameter in the section in the configuration data.

The functions use add_string by first converting the value (bool) in value (string)

Definition at line 491 of file config.cpp.

void ROBOOP::Config::add_int ( const std::string  section,
const std::string  parameter,
const int  value 
)

Added the value (int) of the parameter in the section in the configuration data.

The functions use add_string by first converting the value (int) in value (string)

Definition at line 511 of file config.cpp.

void ROBOOP::Config::add_float ( const std::string  section,
const std::string  parameter,
const float  value 
)

Added the value (float) of the parameter in the section in the configuration data.

The functions use add_string by first converting the value (float) in value (string)

Definition at line 531 of file config.cpp.

void ROBOOP::Config::add_double ( const std::string  section,
const std::string  parameter,
const double  value 
)

Added the value (double) of the parameter in the section in the configuration data.

The functions use add_string by first converting the value (double) in value (string)

Definition at line 555 of file config.cpp.

void ROBOOP::Config::add_real ( const std::string  section,
const std::string  parameter,
const Real  value 
)

Added the value (Real) of the parameter in the section in the configuration data.

The functions use add_string by first converting the value (Real) in value (string)

Definition at line 579 of file config.cpp.


Member Data Documentation

Data store from/to configuration file.

Definition at line 168 of file config.h.

Referenced by add_string(), operator=(), parameter_exists(), print(), read_conf(), section_exists(), select_string(), and write_conf().

std::string ROBOOP::Config::filename [private]

Configuration file name.

Definition at line 169 of file config.h.

Referenced by operator=(), and read_conf().


The documentation for this class was generated from the following files:

ROBOOP v1.21a
Generated Thu Nov 22 00:51:35 2007 by Doxygen 1.5.4