00001
00002 #ifndef INCLUDED_Config_h
00003 #define INCLUDED_Config_h
00004
00005 #include <vector>
00006 #include <string>
00007 #include "RobotInfo.h"
00008
00009
00010 class Config {
00011 public:
00012
00013 Config(const char* filename)
00014 : wireless(), vision(), main(), behaviors(), controller(), motion(),
00015 worldmodel2(), sound()
00016 { readConfig(filename); }
00017
00018 ~Config() {}
00019
00020
00021 enum section_t {
00022 sec_wireless=0,
00023 sec_vision,
00024 sec_main,
00025 sec_behaviors,
00026 sec_controller,
00027 sec_motion,
00028 sec_worldmodel2,
00029 sec_sound,
00030 sec_invalid
00031 };
00032
00033
00034 struct wireless_config {
00035 int id;
00036
00037 wireless_config () : id(1) {}
00038 } wireless;
00039
00040
00041 struct vision_config {
00042 int white_balance;
00043 int gain;
00044 int shutter_speed;
00045 int resolution;
00046 char thresh[50];
00047 char colors[50];
00048 int raw_port;
00049 int rle_port;
00050 int obj_port;
00051 int raw_encoding;
00052
00053
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
00058 struct main_config {
00059 int console_port;
00060 int stderr_port;
00061 int error_level;
00062 int debug_level;
00063 int verbose_level;
00064 int wsjoints_port;
00065 int wspids_port;
00066 int headControl_port;
00067 int walkControl_port;
00068 int estopControl_port;
00069 int aibo3d_port;
00070 int wmmonitor_port;
00071 bool use_VT100;
00072
00073
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
00083 struct behaviors_config {
00084 } behaviors;
00085
00086
00087 struct controller_config {
00088 int gui_port;
00089 char select_snd[50];
00090 char next_snd[50];
00091 char prev_snd[50];
00092 char read_snd[50];
00093 char cancel_snd[50];
00094
00095
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
00102 struct motion_config {
00103 std::string root;
00104 char estop_on_snd[50];
00105 char estop_off_snd[50];
00106 float max_head_tilt_speed;
00107 float max_head_pan_speed;
00108 float max_head_roll_speed;
00109
00110
00111 std::string makePath(std::string name) {
00112 return (name[0]!='/')?root+"/"+name:name;
00113 }
00114
00115
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
00125 struct worldmodel2_config {
00126
00127
00128 int dm_port, hm_port, gm_port, fs_port;
00129
00130
00131 worldmodel2_config() : dm_port(0), hm_port(0), gm_port(0), fs_port(0) {}
00132 } worldmodel2;
00133
00134
00135 struct sound_config {
00136 std::string root;
00137 unsigned int sample_rate;
00138 unsigned int sample_bits;
00139 std::vector<std::string> preload;
00140
00141
00142 std::string makePath(std::string name) {
00143 return (name[0]!='/')?root+"/"+name:name;
00144 }
00145
00146
00147 sound_config() : root(), sample_rate(0), sample_bits(0), preload() {}
00148 } sound;
00149
00150
00151 void readConfig(const char* filename);
00152
00153 section_t parseSection(const char* key);
00154
00155 void* setValue(section_t section, const char *key, const char *value, bool updated=false);
00156
00157
00158 protected:
00159
00160
00161 static bool extractBool(const char* value);
00162 };
00163
00164
00165 extern Config* config;
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 #endif