Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _OBSTACLE_HH_
00012 #define _OBSTACLE_HH_
00013
00014 #include <vector>
00015 #include "ntimer.h"
00016
00017 #include <art_msgs/ObservationArray.h>
00018
00024 class Obstacle
00025 {
00026 public:
00027
00029 Obstacle(Navigator *_nav, int _verbose);
00030
00032 ~Obstacle()
00033 {
00034 delete blockage_timer;
00035 };
00036
00041 bool blockage_timeout(void)
00042 {
00043 return blockage_timer->Check();
00044 }
00045
00047 void blocked(void)
00048 {
00049 if (verbose >= 5)
00050 ART_MSG(3, "Starting blockage timer");
00051 blockage_timer->Start(config_->blockage_timeout_secs);
00052 }
00053
00055 bool car_approaching();
00056
00058 void closest_in_lane(const poly_list_t &lane, float &ahead, float &behind);
00059
00061 bool initialized(void)
00062 {
00063
00064 return true;
00065 };
00066
00068 float maximum_range(void) {return max_range;}
00069
00071 art_msgs::Observation observation(art_msgs::Observation::_oid_type oid)
00072 {
00073 return obstate.obs[oid];
00074 }
00075
00077 bool observer_clear(art_msgs::Observation::_oid_type oid)
00078 {
00079 bool clear = obstate.obs[oid].clear && obstate.obs[oid].applicable;
00080
00081
00082 if (!clear)
00083 blocked();
00084 return clear;
00085 }
00086
00087 void observers_message(const art_msgs::ObservationArrayConstPtr obs_msg);
00088
00090 bool passing_lane_clear(void);
00091
00093 void reset(void);
00094
00096 void unblocked(void)
00097 {
00098 if (verbose >= 5)
00099 ART_MSG(3, "Canceling blockage timer");
00100 blockage_timer->Cancel();
00101 }
00102
00104 void update_blockage_state(void)
00105 {
00106 if (navdata->stopped != was_stopped ||
00107 !navdata->stopped)
00108 {
00109 if (navdata->stopped)
00110 blocked();
00111 else
00112 unblocked();
00113 if (verbose >= 4 &&
00114 navdata->stopped != was_stopped)
00115 ART_MSG(8, "vehicle %s moving",
00116 (navdata->stopped? "stopped": "started"));
00117 was_stopped = navdata->stopped;
00118 }
00119 }
00120
00121 private:
00122
00123
00124 float max_range;
00125
00126 ros::Subscriber obs_sub_;
00127
00128
00129 art_msgs::ObservationArray obstate;
00130
00131
00132 NavTimer *blockage_timer;
00133 bool was_stopped;
00134
00135
00136 int verbose;
00137 Navigator *nav;
00138
00139
00140 PolyOps* pops;
00141 Course* course;
00142 art_msgs::Order *order;
00143 art_msgs::NavigatorState *navdata;
00144 nav_msgs::Odometry *odom;
00145 nav_msgs::Odometry *estimate;
00146 const Config *config_;
00147
00148
00149 bool in_lane(MapXY location, const poly_list_t &lane, int start_index);
00150
00151 #if 0 // ignoring obstacles at the moment
00152
00153 float laser_scan_bearing(unsigned index, const player_laser_data_t &scan)
00154 {
00155 return scan.min_angle + index * scan.resolution;
00156 }
00157 unsigned laser_scan_index(float bearing, const player_laser_data_t &scan)
00158 {
00159 unsigned index =
00160 (unsigned) rintf((bearing - scan.min_angle) / scan.resolution);
00161 if (index < 0)
00162 index = 0;
00163 else if (index > scan.ranges_count)
00164 index = scan.ranges_count;
00165 return index;
00166 }
00167 #endif // ignoring obstacles at the moment
00168 };
00169
00170 #endif // _OBSTACLE_HH_