00001 // Copyright (C) 2007 University of Louisiana at Lafayette 00002 // Authors: Suresh Golconda 00003 00004 #ifndef CAJUN_SIMPLE_STATE_MACHINE_H 00005 #define CAJUN_SIMPLE_STATE_MACHINE_H 00006 00007 #include "base_state_machine.H" 00008 #include "state_defs.H" 00009 00010 #include <cfloat> 00011 namespace cajun 00012 { 00014 class safe_state_t : public base_state_machine_t 00015 { 00016 public: 00017 safe_state_t (double tstamp_) 00018 { 00019 m_state_id = SAFE; 00020 m_tstamp_since = tstamp_; 00021 m_name = "SAFE"; 00022 } 00023 state_machine_id_t new_state (state_machine_t *sm_); 00024 }; 00025 00027 class confirm_obstacle_t : public base_state_machine_t 00028 { 00029 public: 00030 confirm_obstacle_t (double tstamp_) 00031 { 00032 m_state_id = CONFIRM_OBSTACLE; 00033 m_tstamp_since = tstamp_; 00034 m_name = "CONFIRM_OBSTACLE"; 00035 m_bot_stopped_in_this_state_since = FLT_MAX; 00036 } 00037 state_machine_id_t new_state (state_machine_t *sm_); 00038 bool update (state_machine_t *sm_); 00039 00040 private: 00041 double m_bot_stopped_in_this_state_since; 00042 00043 bool did_bot_stopped_long_enough (); 00044 00045 }; 00046 00047 // /*!\brief Intermediate state for switching to any of action states after the 00048 // * lane blockage is confirm*/ 00049 class lane_blocked_t : public base_state_machine_t 00050 { 00051 public: 00052 lane_blocked_t (double tstamp_) 00053 { 00054 m_state_id = LANE_BLOCKED; 00055 m_tstamp_since = tstamp_; 00056 m_name = "LANE_BLOCKED"; 00057 } 00058 state_machine_id_t new_state (state_machine_t *sm_); 00059 }; 00060 00061 class pre_stop_lane_blocked_t : public base_state_machine_t 00062 { 00063 public: 00064 pre_stop_lane_blocked_t (double tstamp_) 00065 { 00066 m_state_id = PRE_STOP_LANE_BLOCKED; 00067 m_tstamp_since = tstamp_; 00068 m_name = "PRE_STOP_LANE_BLOCKED"; 00069 } 00070 state_machine_id_t new_state (state_machine_t *sm_); 00071 }; 00072 00073 class intersection_blocked_t : public base_state_machine_t 00074 { 00075 public: 00076 intersection_blocked_t (double tstamp_) 00077 { 00078 m_state_id = INTERSECTION_BLOCKED; 00079 m_tstamp_since = tstamp_; 00080 m_name = "INTERSECTION_BLOCKED"; 00081 } 00082 state_machine_id_t new_state (state_machine_t *sm_); 00083 }; 00084 00085 class post_stop_lane_blocked_t : public base_state_machine_t 00086 { 00087 public: 00088 post_stop_lane_blocked_t (double tstamp_) 00089 { 00090 m_state_id = POST_STOP_LANE_BLOCKED; 00091 m_tstamp_since = tstamp_; 00092 m_name = "POST_STOP_LANE_BLOCKED"; 00093 } 00094 state_machine_id_t new_state (state_machine_t *sm_); 00095 }; 00096 00098 class intersection_queueing_t : public base_state_machine_t 00099 { 00100 public: 00101 intersection_queueing_t (double tstamp_) 00102 { 00103 m_state_id = INTERSECTION_QUEUEING; 00104 m_tstamp_since = tstamp_; 00105 m_name = "INTERSECTION_QUEUEING"; 00106 } 00107 state_machine_id_t new_state (state_machine_t *sm_); 00108 }; 00109 00111 class changing_lane_t : public base_state_machine_t 00112 { 00113 bool m_first_iter; 00114 public: 00115 changing_lane_t (double tstamp_) 00116 { 00117 m_state_id = CHANGING_LANE; 00118 m_tstamp_since = tstamp_; 00119 m_first_iter = true; 00120 m_name = "CHANGING_LANE"; 00121 } 00122 state_machine_id_t new_state (state_machine_t *sm_); 00123 bool update (state_machine_t *sm_); 00124 }; 00125 00127 class passing_lane_t : public base_state_machine_t 00128 { 00129 bool m_first_iter; 00130 public: 00131 passing_lane_t (double tstamp_) 00132 { 00133 m_state_id = PASSING_LANE; 00134 m_tstamp_since = tstamp_; 00135 m_first_iter = true; 00136 m_name = "PASSING_LANE"; 00137 } 00138 state_machine_id_t new_state (state_machine_t *sm_); 00139 bool update (state_machine_t *sm_); 00140 }; 00141 00143 class uturn_state_t : public base_state_machine_t 00144 { 00145 bool m_first_iter; 00146 public: 00147 uturn_state_t (double tstamp_) 00148 { 00149 m_state_id = UTURN; 00150 m_tstamp_since = tstamp_; 00151 m_first_iter = true; 00152 m_name = "UTURN"; 00153 } 00154 state_machine_id_t new_state (state_machine_t *sm_); 00155 bool update (state_machine_t *sm_); 00156 }; 00157 }; 00158 00159 #endif
1.6.1