00001
00002
00003
00004
00005
00006
00007 #ifndef CAJUN_RNDF_POINT_H
00008 #define CAJUN_RNDF_POINT_H
00009
00010 #include "rndf.H"
00011 #include "util.H"
00012
00013 namespace cajun
00014 {
00015 class rndf_point_t
00016 {
00017 friend class mission_handler_t;
00018 friend class mission_planner_t;
00019 friend class task_plan_handler_t;
00020
00021 rndf_t const *m_rndf;
00022 rndf_t::waypoint_id_t m_id;
00023
00024 double m_x;
00025 double m_y;
00026
00027 bool m_is_rndf_wp;
00028 unsigned m_inter_rp_id;
00029
00030
00031
00032 bool m_is_exit;
00033 bool m_is_entry;
00034
00035 rndf_point_t (rndf_t const *rndf_,
00036 rndf_t::waypoint_id_t const &wp_id_,
00037 double x_ = 0, double y_ = 0,
00038 bool is_rndf_wp = true):
00039 m_rndf (rndf_), m_id (wp_id_), m_x (x_), m_y (y_),
00040 m_is_rndf_wp (is_rndf_wp), m_inter_rp_id (0),
00041 m_is_exit (false), m_is_entry (false)
00042 {}
00043
00044 rndf_point_t (rndf_t const *rndf_, unsigned sid_,
00045 unsigned lid_, unsigned wid_,
00046 double x_ = 0, double y_ = 0,
00047 bool is_rndf_wp = true):
00048 m_rndf (rndf_), m_id (sid_, lid_, wid_), m_x (x_),
00049 m_y (y_), m_is_rndf_wp (is_rndf_wp),
00050 m_inter_rp_id (0),
00051 m_is_exit (false), m_is_entry (false)
00052 {}
00053
00054
00055 rndf_point_t ()
00056 {}
00057 public:
00058 rndf_t::waypoint_id_t const id () const
00059 { return m_id; }
00060
00061 double x () const { return m_x; }
00062
00063 double y () const { return m_y; }
00064
00065 unsigned operator [] (unsigned i_) const
00066 { return m_id[i_]; }
00067
00068
00069
00070 bool operator < (rndf_point_t const &rp_) const
00071 { return m_id < rp_.id (); }
00072
00073 bool operator != (rndf_point_t const &rp_) const
00074 {
00075 double max_dis = 0.1;
00076
00077 return m_id != rp_.id () ||
00078 !are_too_close_points (m_x, m_y,
00079 rp_.x (), rp_.y (),
00080 max_dis);
00081 }
00082
00083 bool operator == (rndf_point_t const &rp_) const
00084 {
00085 double max_dis = 0.1;
00086
00087 return m_id == rp_.id () &&
00088 are_too_close_points (m_x, m_y,
00089 rp_.x (), rp_.y (),
00090 max_dis);
00091 }
00092 void print () const
00093 {
00094 printf (" (%u %u %u), wp=%d (%.2f %.2f)\n",
00095 m_id[0], m_id[1], m_id[2], m_is_rndf_wp,
00096 m_x, m_y);
00097 }
00098
00099
00100 bool is_rndf_wp () const
00101 { return m_is_rndf_wp; }
00102 bool is_entry () const;
00103 bool is_exit () const;
00104 bool in_segment () const;
00105 bool is_stop () const;
00106 bool in_zone () const;
00107 bool is_perimeter () const;
00108 bool is_spot () const;
00109 bool is_checkpoint () const;
00110
00111 unsigned checkpoint_id () const;
00112
00113
00114
00115 void set_exit ();
00116 void set_entry ();
00117 void set_xy (double x_, double y_);
00118 void set_id (rndf_t::waypoint_id_t wp_id_);
00119
00120
00121
00122
00123
00124 };
00125
00133 class rp_containter_t
00134 {
00135 rndf_point_t *m_rp;
00136 public:
00137 rp_containter_t (rndf_point_t *rp_) : m_rp (rp_)
00138 {}
00139
00140 rndf_point_t* rp () const
00141 {return m_rp; }
00142
00143 rndf_t::waypoint_id_t const id () const
00144 { return m_rp->id (); }
00145
00146 unsigned operator [] (unsigned i_) const
00147 { return (*m_rp)[i_]; }
00148
00149 bool operator < (rp_containter_t const &rpc_) const
00150 {
00151
00152 return (*m_rp) < *(rpc_.rp ());
00153 }
00154
00155
00156 bool operator != (rp_containter_t const &rpc_) const
00157 {
00158
00159 return (*m_rp) != *(rpc_.rp ());
00160 }
00161
00162 bool operator == (rp_containter_t const &rpc_) const
00163 {
00164
00165 return (*m_rp) == *(rpc_.rp ());
00166
00167 }
00168
00169 void print () const
00170 {
00171 m_rp->print ();
00172 }
00173 };
00174 };
00175
00176 #endif