Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_Config_h 00003 #define INCLUDED_Config_h 00004 00005 #include <vector> 00006 #include <string> 00007 #include "RobotInfo.h" 00008 #include <jpeglib.h> 00009 00010 //!provides global access to system configuration information 00011 class Config { 00012 public: 00013 //!constructor 00014 Config(const char* filename) 00015 : wireless(), vision(), main(), behaviors(), controller(), motion(), 00016 worldmodel2(), sound() 00017 { readConfig(filename); } 00018 //!destructor 00019 ~Config() {} 00020 00021 //!section IDs 00022 enum section_t { 00023 sec_wireless=0, //!< denotes wireless section of config file 00024 sec_vision, //!< denotes vision section of config file 00025 sec_main, //!< denotes main section of config file, for misc. settings 00026 sec_behaviors, //!< denotes behaviors section of config file 00027 sec_controller, //!< denotes controller section of config file 00028 sec_motion, //!< denotes motion section of config file 00029 sec_worldmodel2, //!< denotes worldmodel section of config file 00030 sec_sound, //!< denotes sound section of config file 00031 sec_invalid //!< denotes an invalid section of config file 00032 }; 00033 00034 //!wirless information 00035 struct wireless_config { 00036 int id; //!< id number (in case you have more than one AIBO) 00037 00038 wireless_config () : id(1) {} //!< constructor 00039 } wireless; 00040 00041 //!vision information 00042 struct vision_config { 00043 int white_balance; //!< white balance 00044 int gain; //!< gain 00045 int shutter_speed; //!< shutter speed 00046 int resolution; //!< resolution 00047 std::vector<std::string> thresh; //!< thresholds 00048 char colors[50]; //!< colors 00049 int rawcam_port; //!< port to send raw frames on 00050 int rle_port; //!< port to send RLE frames on 00051 int obj_port; //!< port to send object info on 00052 bool restore_image; //!< if true, replaces pixels holding image info with actual image pixels (as much as possible anyway) 00053 J_DCT_METHOD jpeg_dct_method; //!< pick between dct methods for jpeg compression 00054 00055 //! type of information to send, stored in Config::vision_config::rawcam_encoding 00056 enum encoding_t { 00057 ENCODE_COLOR, //!< send Y, U, and V channels 00058 ENCODE_SINGLE_CHANNEL, //!< send only a single channel (which channel to send is stored in Config::vision_config::rawcam_channel) This is also used for all seg cam images 00059 }; 00060 encoding_t rawcam_encoding; //!< holds whether to send color or single channel 00061 int rawcam_channel; //!< RawCameraGenerator::channel_id_t, if raw_encoding is single channel, this holds the channel to send (computed from rawcam_encoding, not set directly) 00062 00063 //! compression format to use, stored in Config::vision_config::rawcam_compression 00064 enum compression_t { 00065 COMPRESS_NONE, //!< no compression (other than subsampling) 00066 COMPRESS_JPEG, //!< JPEG compression 00067 COMPRESS_RLE //!< RLE compression 00068 }; 00069 compression_t rawcam_compression;//!< holds whether to send jpeg compression 00070 00071 int rawcam_compress_quality;//!< 0-100, compression quality (currently only used by jpeg) 00072 int rawcam_y_skip; //!< resolution level to transmit y channel at 00073 int rawcam_uv_skip; //!< resolution level to transmit uv channel at (ignored for jpeg compression) 00074 int rlecam_skip; //!< resolution level to transmit segmented images at 00075 int rlecam_channel; //!< channel of RLEGenerator to send 00076 compression_t rlecam_compression; //!< what compression to use on the segmented image 00077 00078 //!constructor 00079 vision_config() : white_balance(3), gain(2), shutter_speed(2), resolution(2), thresh(), colors(), rawcam_port(0), rle_port(0), obj_port(0), restore_image(true), jpeg_dct_method(JDCT_IFAST), rawcam_encoding(ENCODE_COLOR), rawcam_channel(0), rawcam_compression(COMPRESS_NONE), rawcam_compress_quality(75), rawcam_y_skip(0), rawcam_uv_skip(0), rlecam_skip(1), rlecam_channel(0), rlecam_compression(COMPRESS_RLE) {} 00080 } vision; 00081 00082 //!core functionality information 00083 struct main_config { 00084 int console_port; //!< port to send/receive "console" information on (separate from system console) 00085 int stderr_port; //!< port to send error information to 00086 int error_level; //!< controls amount of info to error port 00087 int debug_level; //!< controls amount of debug info 00088 int verbose_level; //!< controls verbosity of info 00089 int wsjoints_port; //!< port to send joint positions on 00090 int wspids_port; //!< port to send pid info on 00091 int headControl_port; //!< port for receiving head commands 00092 int walkControl_port; //!< port for receiving walk commands 00093 int estopControl_port; //!< port for receiving walk commands 00094 int aibo3d_port; //!< port for send/receive of joint positions from Aibo 3D GUI 00095 int wmmonitor_port; //!< port for monitoring Watchable Memory 00096 bool use_VT100; //!< if true, enables VT100 console codes (currently only in Controller menus - 1.3) 00097 00098 //!constructor 00099 main_config() 00100 : console_port(0), stderr_port(0), error_level(0), debug_level(0), 00101 verbose_level(0),wsjoints_port(0),wspids_port(0),headControl_port(0), 00102 walkControl_port(0),estopControl_port(0),aibo3d_port(0), 00103 wmmonitor_port(0), use_VT100(true) 00104 { } 00105 } main; 00106 00107 //!placeholder 00108 struct behaviors_config { 00109 } behaviors; 00110 00111 //!controller information 00112 struct controller_config { 00113 int gui_port; //!< port to listen for the GUI to connect to aibo on 00114 char select_snd[50]; //!< sound file to use for "select" action 00115 char next_snd[50]; //!< sound file to use for "next" action 00116 char prev_snd[50]; //!< sound file to use for "prev" action 00117 char read_snd[50]; //!< sound file to use for "read from std-in" action 00118 char cancel_snd[50]; //!< sound file to use for "cancel" action 00119 char error_snd[50]; //!< sound file to use to signal errors 00120 00121 //!constructor 00122 controller_config() : gui_port(0) { 00123 select_snd[0]=next_snd[0]=prev_snd[0]=read_snd[0]=cancel_snd[0]=error_snd[0]='\0'; 00124 } 00125 } controller; 00126 00127 //!motion information 00128 struct motion_config { 00129 std::string root; //!< path on memory stick to "motion" files - for instance, position (.pos) and motion sequence (.mot) 00130 std::string walk; //!< the walk parameter file to load by default for new WalkMC's 00131 char estop_on_snd[50]; //!< sound file to use when e-stop turned on 00132 char estop_off_snd[50]; //!< sound file to use when e-stop turned off 00133 float max_head_tilt_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s 00134 float max_head_pan_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s 00135 float max_head_roll_speed; //!< max speed for the head joints, used by HeadPointerMC; rad/s 00136 00137 //!returns an absolute path if @a is relative (to root), otherwise just @a name 00138 std::string makePath(std::string name) { 00139 return (name[0]!='/')?root+"/"+name:name; 00140 } 00141 00142 //!constructor 00143 motion_config() : root(), walk(), max_head_tilt_speed(0), max_head_pan_speed(0), max_head_roll_speed(0) { 00144 estop_on_snd[0]=estop_off_snd[0]='\0'; 00145 max_head_tilt_speed=0; 00146 max_head_pan_speed=0; 00147 max_head_roll_speed=0; 00148 } 00149 } motion; 00150 00151 //!world model information 00152 struct worldmodel2_config { 00153 //@{ 00154 //!ports to use for sending world model information 00155 int dm_port, hm_port, gm_port, fs_port; //@} 00156 00157 //!constructor 00158 worldmodel2_config() : dm_port(0), hm_port(0), gm_port(0), fs_port(0) {} 00159 } worldmodel2; 00160 00161 //!sound information 00162 struct sound_config { 00163 std::string root; //!< path to sound clips 00164 unsigned int volume; //!< volume in decibels - the value is interpreted as a signed short, where 0 is full volume, 0x8000 is mute 00165 unsigned int sample_rate; //!< sample rate to send to system, currently only 8000 or 16000 supported 00166 unsigned int sample_bits; //!< sample bit depth, either 8 or 16 00167 std::vector<std::string> preload; //!< list of sounds to preload at boot 00168 00169 //!returns an absolute path if @a is relative (to root), otherwise just @a name 00170 std::string makePath(std::string name) { 00171 return (name[0]!='/')?root+"/"+name:name; 00172 } 00173 00174 //!constructor 00175 sound_config() : root(), volume(0xF600), sample_rate(0), sample_bits(0), preload() {} 00176 } sound; 00177 00178 //! call this function when it's time to read the configuration file 00179 void readConfig(const char* filename); 00180 //! returns the section structure corresponding to the section name given 00181 section_t parseSection(const char* key); 00182 //! pass the section, item name string, item value string - sets the value and returns pointer to the item changed 00183 void* setValue(section_t section, const char *key, const char *value, bool updated=false); 00184 00185 00186 protected: 00187 //! returns true if pattern matches model - pattern may have up to 1 '*', case insensitive 00188 bool matchNoCase(const std::string& model, const std::string& pattern); 00189 00190 //! returns bool value corresponding to a @a value of "t", "f", "true", "false", "y", "n", "yes", "no", or zero/nonzero number 00191 static bool extractBool(const char* value); 00192 }; 00193 00194 //!allows global access to current settings 00195 extern Config* config; 00196 00197 /*! @file 00198 * @brief Describes Config, which provides global access to system configuration information 00199 * @author alokl (Creator) 00200 * 00201 * $Author: ejt $ 00202 * $Name: tekkotsu-2_0 $ 00203 * $Revision: 1.27 $ 00204 * $State: Exp $ 00205 * $Date: 2004/01/21 03:31:08 $ 00206 */ 00207 00208 #endif
Tekkotsu v2.0 |
Generated Wed Jan 21 03:20:28 2004 by Doxygen 1.3.4 |