00001 #ifndef CAJUN_INTERSECTION_TRACKER_H 00002 #define CAJUN_INTERSECTION_TRACKER_H 00003 00004 #include "rndf.H" 00005 #include "data_type.H" 00006 00007 namespace cajun 00008 { 00009 class intersection_tracker_t 00010 { 00011 public: 00012 struct stop_status_t 00013 { 00014 rndf_t::waypoint_id_t m_wp_id; //wp id 00015 bool m_is_blocked; // true if blocked, else not blocked 00016 double m_blk_since; // tstamp since its blocked 00017 double m_last_noticed;//tstamp when last update 00018 unsigned m_blk_lane_id;// id of object blocking 00019 }; 00020 00021 struct intersection_status_t 00022 { 00023 intersection_status_t () { } 00024 std::vector <stop_status_t> m_stop_status; 00025 unsigned m_inter_id; //index to rndf_t's intersection 00026 }; 00027 00028 intersection_tracker_t (const rndf_t *rndf_) : m_rndf (rndf_) 00029 { init (); } 00030 void update (std::vector <blocked_lane_data_t> const &blk_lanes_); 00031 //returns the intersection status for given it_id) 00032 const intersection_status_t *get_inter_status ( 00033 rndf_t::waypoint_id_t wp_id_); 00034 private: 00035 const rndf_t *m_rndf; 00036 double m_blk_status_timeout; 00037 double m_max_dis_before_stop; 00038 double m_max_dis_after_stop; 00039 00040 std::vector<intersection_status_t *> m_inter_status; 00041 00042 void init (); 00043 void add_intersection_contents ( 00044 unsigned it_id_, intersection_status_t* &int_st_); 00045 bool at_near_stop (const blocked_lane_data_t &blk_lane_, 00046 unsigned &int_id_, unsigned &stop_wp_id_); 00047 void update_stop_point (const blocked_lane_data_t &blk_lanes_, 00048 unsigned int_id_, unsigned stop_wp_id_); 00049 void flush_old_blockage (intersection_status_t *it_st_); 00050 void print_stop (stop_status_t const stop_); 00051 }; 00052 00053 00054 }; 00055 00056 #endif