00001 // Author: Firas Bouz 00002 00003 #include "data_queue.H" 00004 #include "data_type.H" 00005 00006 #include "queue_generator.H" 00007 00008 namespace cajun 00009 { 00010 class local_dtm_t 00011 { 00012 public: 00013 local_dtm_t (); 00014 ~local_dtm_t (); 00015 00016 bool update(); 00017 int get_local_max_x ()// the right most boundary of the local_dtm 00018 { 00019 return local_dtm.MAX_X; 00020 } 00021 int get_local_max_y ()// the top most boundary 00022 { 00023 return local_dtm.MAX_Y; 00024 } 00025 00026 void get_global_position (double &x, double &y); 00027 double get_heading (); 00028 00029 // The local_cell_t of the cell at relative x and y. (x, y) are relative coords 00030 local_cell_t get_local_cell (int x, int y) 00031 { 00032 // make sure about the row major thing 00033 return local_dtm.local_dtm[x][y]; 00034 } 00035 // local_cell_t is defined in data_type.H, contains only 00036 // min_z and max_z, and whether or not it is an obstacle 00037 00038 void get_global_origin (double &x, double &y); 00039 // the corresponding global (x, y) for a local (x`, y`) 00040 void get_global_xy (int local_x, int local_y, 00041 double &global_x, double &global_y) 00042 { 00043 global_x = (local_x * local_dtm.cell_size) / 100.0 + local_dtm.min_x; 00044 global_y = (local_y * local_dtm.cell_size) / 100.0 + local_dtm.min_y; 00045 } 00046 00047 double get_global_x (int local_x); 00048 double get_global_y (int local_y); 00049 00050 void get_local_xy ( double global_x, double global_y, 00051 int &local_x, int &local_y); 00052 00053 int get_local_x (double global_x); 00054 int get_local_y (double global_y); 00055 00056 int get_cell_size (); 00057 void print_obstacles(); 00058 void log_obstacles(FILE * fp); 00059 00060 private: 00061 00062 local_cell_t local_cell; // min_z and max_z 00063 local_dtm_data_t local_dtm; // to read from shared_mem 00064 data_queue_reader_t<local_dtm_data_t> *local_dtm_dq; 00065 00066 scan_gp_data_t::coord_t global_position; // vehicle gps position 00067 00068 heading_data_t heading; 00069 data_queue_reader_t<heading_data_t>* heading_dq; 00070 00071 nav_data_t nav; 00072 data_queue_reader_t<nav_data_t>* nav_dq; 00073 }; 00074 };