00001 #ifndef CAJUN_CURVED_PATH_EXTRACTOR_H
00002 #define CAJUN_CURVED_PATH_EXTRACTOR_H
00003
00004 #include "path_extractor.H"
00005 #include "obstacle_free.H"
00006
00007 #include "uc_planner_param.H"
00008 #include <queue>
00009
00010 namespace cajun
00011 {
00012
00013 class curved_path_extractor_t : public path_extractor_t
00014 {
00015
00016 public:
00017 curved_path_extractor_t (double cell_size_, obstacle_free_t *of_);
00018
00019 private:
00020 static const unsigned MAX_CHILDREN = 3;
00021
00022 struct ep_node_t
00023 {
00024 double x;
00025 double y;
00026 double orient;
00027 unsigned id;
00028 unsigned depth;
00029
00030 double cost_to_goal;
00031 double cost_from_start;
00032 double total_cost;
00033
00034 ep_node_t *parent_node;
00035 ep_node_t* child_node[MAX_CHILDREN];
00036
00037 };
00038
00039 struct cmp_node_t
00040 {
00041 bool operator () (ep_node_t const *n1_, ep_node_t const *n2_)
00042 { return n1_->total_cost > n2_->total_cost; }
00043 };
00044 std::priority_queue<ep_node_t *, std::vector<ep_node_t *>, cmp_node_t> m_work_list;
00045
00046 obstacle_free_t *m_obstacle_free;
00047
00048 double m_start_x;
00049 double m_start_y;
00050
00051
00052 std::vector <double> m_orient_step;
00053
00054
00055 double m_dis_step_size;
00056
00057 const uc_planner_param_t *m_uc_param;
00058
00059 bool extract (double tstamp_, path_t &path_, path_t &detail_path_,
00060 double orient_);
00061
00062 void clear_work_list ();
00063
00064 ep_node_t* bsd_search (path_t &path_);
00065
00066 void create_start_node (ep_node_t *start_node_,
00067 path_t const &detail_path_, double orient_);
00068
00069 void create_ith_child (ep_node_t *parent_node, unsigned child_id, ep_node_t* &child_node);
00070
00071
00072 bool stop_exploring (ep_node_t *node_);
00073
00074
00075 bool through_bad_part (ep_node_t const *node_);
00076
00077 bool point_over_bad_part (double x_, double y_);
00078
00079 bool outside_zone (ep_node_t const *node_);
00080
00081 bool reached_goal (ep_node_t const *node);
00082
00083 void form_new_node (ep_node_t *start_node_,
00084 ep_node_t *new_node_,
00085 unsigned child_id_);
00086
00087 void extract_path (ep_node_t *start_node, path_t &path_);
00088
00089 double get_cost_at_xy (double x_, double y_);
00090
00091 double orientation_to_goal (ep_node_t const *node_);
00092
00093 bool approaching_wrong (ep_node_t const *start_node_);
00094 void write_to_file (FILE *fp, ep_node_t *node1, ep_node_t *node2);
00095
00096 unsigned m_depth;
00097 unsigned m_count;
00098
00099 };
00100
00101 };
00102
00103 #endif