Homepage Demos Overview Downloads Tutorials Reference
Credits

Config.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Config_h
00003 #define INCLUDED_Config_h
00004 
00005 #include <vector>
00006 #include <string>
00007 #include "RobotInfo.h"
00008 
00009 //!provides global access to system configuration information
00010 class Config {
00011  public:
00012   //!constructor
00013   Config(const char* filename)
00014     : wireless(), vision(), main(), behaviors(), controller(), motion(),
00015     worldmodel2(), sound()
00016     { readConfig(filename); }
00017   //!destructor
00018   ~Config() {}
00019 
00020   //!section IDs
00021   enum section_t {
00022     sec_wireless=0,  //!< denotes wireless section of config file
00023     sec_vision,      //!< denotes vision section of config file
00024     sec_main,        //!< denotes main section of config file, for misc. settings
00025     sec_behaviors,   //!< denotes behaviors section of config file
00026     sec_controller,  //!< denotes controller section of config file
00027     sec_motion,      //!< denotes motion section of config file
00028     sec_worldmodel2, //!< denotes worldmodel section of config file
00029     sec_sound,       //!< denotes sound section of config file
00030     sec_invalid      //!< denotes an invalid section of config file
00031   };
00032 
00033   //!wirless information
00034   struct wireless_config {
00035     int id; //!< id number (in case you have more than one AIBO)
00036       
00037     wireless_config () : id(1) {} //!< constructor
00038   } wireless;
00039 
00040   //!vision information
00041   struct vision_config {
00042     int white_balance;    //!< white balance
00043     int gain;             //!< gain
00044     int shutter_speed;    //!< shutter speed
00045     int resolution;       //!< resolution
00046     char thresh[50];      //!< thresholds
00047     char colors[50];      //!< colors
00048     int raw_port;         //!< port to send raw frames on
00049     int rle_port;         //!< port to send RLE frames on
00050     int obj_port;         //!< port to send object info on
00051     int raw_encoding;     //!< resolution and other details for raw output
00052       
00053     //!constructor
00054     vision_config() : white_balance(3), gain(2), shutter_speed(2), resolution(2), thresh(), colors(), raw_port(0), rle_port(0), obj_port(0), raw_encoding(0) {}
00055   } vision;
00056   
00057   //!core functionality information
00058   struct main_config {
00059     int console_port;  //!< port to send/receive "console" information on (separate from system console)
00060     int stderr_port;   //!< port to send error information to
00061     int error_level;   //!< controls amount of info to error port
00062     int debug_level;   //!< controls amount of debug info
00063     int verbose_level; //!< controls verbosity of info
00064     int wsjoints_port; //!< port to send joint positions on
00065     int wspids_port;   //!< port to send pid info on
00066     int headControl_port;    //!< port for receiving head commands
00067     int walkControl_port;    //!< port for receiving walk commands
00068     int estopControl_port;     //!< port for receiving walk commands
00069     int aibo3d_port;   //!< port for send/receive of joint positions from Aibo 3D GUI
00070     int wmmonitor_port; //!< port for monitoring Watchable Memory
00071     bool use_VT100;    //!< if true, enables VT100 console codes (currently only in Controller menus - 1.3)
00072 
00073     //!constructor
00074     main_config()
00075       : console_port(0), stderr_port(0), error_level(0), debug_level(0),
00076         verbose_level(0),wsjoints_port(0),wspids_port(0),headControl_port(0),
00077         walkControl_port(0),estopControl_port(0),aibo3d_port(0),
00078         wmmonitor_port(0), use_VT100(true)
00079     { }
00080   } main;
00081 
00082   //!placeholder
00083   struct behaviors_config {
00084   } behaviors;
00085     
00086   //!controller information
00087   struct controller_config {
00088     int gui_port;        //!< port to listen for the GUI to connect to aibo on
00089     char select_snd[50]; //!< sound file to use for "select" action
00090     char next_snd[50];   //!< sound file to use for "next" action
00091     char prev_snd[50];   //!< sound file to use for "prev" action
00092     char read_snd[50];   //!< sound file to use for "read from std-in" action
00093     char cancel_snd[50]; //!< sound file to use for "cancel" action
00094 
00095     //!constructor
00096     controller_config() : gui_port(0) {
00097       select_snd[0]=next_snd[0]=prev_snd[0]=read_snd[0]=cancel_snd[0]='\0';
00098     }
00099   } controller;
00100     
00101   //!motion information
00102   struct motion_config {
00103     std::string root;       //!< path on memory stick to "motion" files - for instance, position (.pos) and motion sequence (.mot)
00104     char estop_on_snd[50];  //!< sound file to use when e-stop turned on
00105     char estop_off_snd[50]; //!< sound file to use when e-stop turned off
00106     float max_head_tilt_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s
00107     float max_head_pan_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s
00108     float max_head_roll_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s
00109 
00110     //!returns an absolute path if @a is relative (to root), otherwise just @a name
00111     std::string makePath(std::string name) { 
00112       return (name[0]!='/')?root+"/"+name:name;
00113     }
00114 
00115     //!constructor
00116     motion_config() : root(), max_head_tilt_speed(0), max_head_pan_speed(0), max_head_roll_speed(0) {
00117       estop_on_snd[0]=estop_off_snd[0]='\0';
00118       max_head_tilt_speed=0;
00119       max_head_pan_speed=0;
00120       max_head_roll_speed=0;
00121     }
00122   } motion;
00123 
00124   //!world model information
00125   struct worldmodel2_config {
00126     //@{
00127     //!ports to use for sending world model information
00128     int dm_port, hm_port, gm_port, fs_port; //@}
00129 
00130     //!constructor
00131     worldmodel2_config() : dm_port(0), hm_port(0), gm_port(0), fs_port(0) {}
00132   } worldmodel2;
00133   
00134   //!sound information
00135   struct sound_config {
00136     std::string root;         //!< path to sound clips
00137     unsigned int sample_rate; //!< sample rate to send to system, currently only 8000 or 16000 supported
00138     unsigned int sample_bits; //!< sample bit depth, either 8 or 16
00139     std::vector<std::string> preload; //!< list of sounds to preload at boot
00140       
00141     //!returns an absolute path if @a is relative (to root), otherwise just @a name
00142     std::string makePath(std::string name) { 
00143       return (name[0]!='/')?root+"/"+name:name;
00144     }
00145 
00146     //!constructor
00147     sound_config() : root(), sample_rate(0), sample_bits(0), preload() {}
00148   } sound;
00149 
00150   //! call this function when it's time to read the configuration file
00151   void readConfig(const char* filename);
00152   //! returns the section structure corresponding to the section name given
00153   section_t parseSection(const char* key);
00154   //! pass the section, item name string, item value string - sets the value and returns pointer to the item changed
00155   void* setValue(section_t section, const char *key, const char *value, bool updated=false);
00156 
00157 
00158 protected:
00159 
00160   //! returns bool value corresponding to a @a value of "t", "f", "true", "false", "y", "n", "yes", "no", or zero/nonzero number
00161   static bool extractBool(const char* value);
00162 };
00163 
00164 //!allows global access to current settings
00165 extern Config* config;
00166 
00167 /*! @file
00168  * @brief Describes Config, which provides global access to system configuration information
00169  * @author alokl (Creator)
00170  *
00171  * $Author: ejt $
00172  * $Name: tekkotsu-1_5 $
00173  * $Revision: 1.19 $
00174  * $State: Rel $
00175  * $Date: 2003/09/07 22:14:19 $
00176  */
00177 
00178 #endif

Tekkotsu v1.5
Generated Fri Oct 10 15:51:58 2003 by Doxygen 1.3.4