Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

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

Tekkotsu v1.4
Generated Sat Jul 19 00:06:29 2003 by Doxygen 1.3.2