00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef MODULE_MAP
00018 #define MODULE_MAP
00019
00020 #include <vector>
00021 #include <string>
00022 #include <map>
00023
00024 #include <time.h>
00025 #include <sys/time.h>
00026
00027 #include "module.h"
00028 #include "module_conf.h"
00029 #include "protocol.h"
00030
00037 const double PI= 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
00038
00041 const double DIFF_VOLTAGE_WARN = 0.4;
00042
00043 using namespace std;
00044
00046 enum terrain_types
00047 {
00048 TERRAIN_UNKNOWN = 0,
00049 TERRAIN_BLOCKED_UNKNOWN,
00050
00051 TERRAIN_VISITED
00052 };
00053
00057 struct robot_data
00058 {
00059 string name;
00060 double x, y, z;
00061 double angle;
00062
00063
00064 double sigma_angle;
00065 double sigma_x, sigma_y, sigma_z;
00066 };
00067
00074 class robot_path
00075 {
00076 public:
00077 robot_path( double x1, double y1, double z1, double x2, double y2, double z2, bool permanent = false );
00078
00079 timeval get_creation_time( void );
00080
00081 void set_status( bool active );
00082 bool get_status( void );
00083
00084 void set_permanent( bool permanent );
00085 bool get_permanent( void );
00086
00087 double get_source_x( void );
00088 double get_source_y( void );
00089 double get_source_z( void );
00090
00091 double get_target_x( void );
00092 double get_target_y( void );
00093 double get_target_z( void );
00094
00095 private:
00096 timeval creation_time;
00097 double source_x, source_y, source_z;
00098 double target_x, target_y, target_z;
00099
00100 bool active;
00101 bool permanent;
00102
00103 friend class module_map;
00104 };
00105
00108 struct map_info
00109 {
00110 double x,y,z;
00111 double sigma_x, sigma_y, sigma_z;
00112
00113 unsigned int type;
00114 double width;
00115 double angle;
00116 double sigma_angle;
00117 timeval discovery_time;
00118 };
00119
00124 class module_map : public module
00125 {
00126 public:
00127
00128 module_map( void );
00129
00130
00131
00132 virtual int mod_load( void );
00133 virtual int mod_unload( void );
00134 virtual int handle_msg( const char* msg );
00135
00139 virtual char* get_name( void )
00140 {
00141 return( "module_map" );
00142 }
00143
00144 virtual int get_status( void );
00145
00146
00147
00148 int setup( double width, double height );
00149 int setup( double width, double height, const char* map_file );
00150
00151 void execute_command( string command, double param );
00152 void execute_command( unsigned char code, const saved_net_msg& message );
00153
00154 void update( void );
00155 void dump_paths( const char* filename );
00156 void parse_datalog( vector<saved_net_msg> saved_messages, string datalog );
00157
00158 double estimate_execution_time( vector<saved_net_msg> messages );
00159
00160
00161
00162 double get_width( void );
00163 double get_height( void );
00164
00165 void set_battery_voltage( double voltage, bool compile_voltage = false );
00166 double get_battery_voltage( bool compile_voltage = false );
00167
00168 robot_data get_robot_data( void );
00169
00170 vector<map_info> get_map_data( void );
00171 void add_map_element( map_info element );
00172
00173 vector <robot_path> get_paths( void );
00174
00175 size_t add_path( robot_path path );
00176
00177 void add_command( string name, unsigned char code );
00178 string get_command( unsigned char code );
00179
00180 private:
00181 double EPM;
00182
00183 unsigned int BATTERIESPANNUNG;
00184 unsigned int UNGUELTIGER_BEFEHL;
00185 unsigned int BEFEHL_VERWEIGERT;
00186 unsigned int FATALER_FEHLER;
00187 unsigned int AUSFUEHRUNGSPROTOKOLL_ANFANG;
00188 unsigned int AUSFUEHRUNGSPROTOKOLL_ENDE;
00189 unsigned int METERZEIT;
00190 unsigned int PERIODENDAUER;
00191 unsigned int GENAUIGKEIT;
00192 unsigned int SENSOR_1_AN;
00193 unsigned int SENSOR_2_AN;
00194 unsigned int SENSOR_3_AN;
00195 unsigned int SENSOR_1_AUS;
00196 unsigned int SENSOR_2_AUS;
00197 unsigned int SENSOR_3_AUS;
00198
00199 double SENSOR_1_X;
00200 double SENSOR_1_Y;
00201 double SENSOR_1_RTG_X;
00202 double SENSOR_1_RTG_Y;
00203 double SENSOR_1_BREITE;
00204
00205 double SENSOR_2_X;
00206 double SENSOR_2_Y;
00207 double SENSOR_2_RTG_X;
00208 double SENSOR_2_RTG_Y;
00209 double SENSOR_2_BREITE;
00210
00211 double SENSOR_3_X;
00212 double SENSOR_3_Y;
00213 double SENSOR_3_RTG_X;
00214 double SENSOR_3_RTG_Y;
00215 double SENSOR_3_BREITE;
00216
00217 module_conf* mod_conf;
00218
00219
00220 double width;
00221 double height;
00222
00223 double compile_battery_voltage;
00224 double battery_voltage;
00225 double path_ttl;
00226
00227
00228 vector<map_info> map_data;
00229
00230
00231 robot_data robot;
00232
00233 map<unsigned char, string> command_library;
00234 vector <robot_path> paths;
00235
00236 double current_voltage;
00237 };
00238
00239 #endif