src/smp/planners/rrtstar.h

Go to the documentation of this file.
00001 
00008 #ifndef _SMP_PLANNER_RRTSTAR_H_
00009 #define _SMP_PLANNER_RRTSTAR_H_
00010 
00011 #include <smp/planners/base_incremental.h>
00012 #include <smp/planners/planner_parameters.h>
00013 
00014 #include <smp/components/cost_evaluators/base.h>
00015 
00016 
00017 namespace smp {
00018 
00020 
00028     class rrtstar_vertex_data {
00029         
00030     public:
00032         double total_cost;
00033     };
00034 
00035 
00037 
00045     class rrtstar_edge_data {
00046         
00047     public:
00049         double edge_cost;
00050     };
00051     
00052     
00054 
00060     template< class typeparams >
00061     class rrtstar : public planner_incremental<typeparams> {
00062 
00063 
00064         typedef typename typeparams::state state_t;
00065         typedef typename typeparams::input input_t;
00066         typedef typename typeparams::vertex_data vertex_data_t;
00067         typedef typename typeparams::edge_data edge_data_t;
00068 
00069         typedef trajectory<typeparams> trajectory_t;
00070 
00071         typedef vertex<typeparams> vertex_t;
00072         typedef smp::edge<typeparams> edge_t;
00073 
00074         typedef planner_incremental<typeparams> planner_incremental_t;
00075 
00076         typedef cost_evaluator_base<typeparams> cost_evaluator_t;
00077     
00078         typedef planner_parameters parameters_t;
00079 
00080         typedef sampler_base<typeparams> sampler_t;
00081         typedef distance_evaluator_base<typeparams> distance_evaluator_t;
00082         typedef extender_base<typeparams> extender_t;
00083         typedef collision_checker_base<typeparams> collision_checker_t;
00084         typedef model_checker_base<typeparams> model_checker_t;
00085 
00086 
00087     private:
00088 
00089 
00090         // This function adds the given state to the beginning of the tracjetory and calls the collision checker.
00091         int check_extended_trajectory_for_collision (state_t *state, trajectory_t *trajectory) {
00092 
00093             trajectory->list_states.push_front (state);
00094             int collision_check = this->collision_checker.check_collision_trajectory (trajectory);
00095             trajectory->list_states.pop_front ();
00096 
00097             return collision_check;
00098         }
00099 
00100         // The radius that was used in the previous iteration
00101         double radius_last; 
00102 
00103     
00104     protected:
00105 
00106 
00107     
00112     
00114 
00117         cost_evaluator_t &cost_evaluator;
00118 
00120 
00121 
00122 
00135         int propagate_cost (vertex_t *vertex_in, double total_cost_new);
00136     
00137     
00138     public:
00139 
00140 
00142 
00147         parameters_t parameters;
00148 
00149 
00150         rrtstar ();
00151         ~rrtstar ();
00152 
00153 
00171         rrtstar (sampler_t &sampler_in, distance_evaluator_t &distance_evaluator_in, 
00172                  extender_t &extender_in, collision_checker_t &collision_checker_in, 
00173                  model_checker_t &model_checker_in, cost_evaluator_t &cost_evaluator_in);
00174 
00175 
00190         int initialize (state_t *initial_state_in = 0);
00191 
00192 
00197     
00205         int init_cost_evaluator (cost_evaluator_t &cost_evaluator_in);
00206 
00208 
00209     
00215         double get_ball_radius_last () {return radius_last;}
00216 
00217 
00258         int iteration ();
00259 
00260     };
00261 
00262 
00263 }
00264 
00265 #endif