Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _EXPANDER_H
00039 #define _EXPANDER_H
00040 #include <global_planner/potential_calculator.h>
00041 #include <global_planner/planner_core.h>
00042
00043 namespace global_planner {
00044
00045 class Expander {
00046 public:
00047 Expander(PotentialCalculator* p_calc, int nx, int ny) :
00048 unknown_(true), lethal_cost_(253), neutral_cost_(50), factor_(3.0), p_calc_(p_calc) {
00049 setSize(nx, ny);
00050 }
00051 virtual bool calculatePotentials(unsigned char* costs, double start_x, double start_y, double end_x, double end_y,
00052 int cycles, float* potential) = 0;
00053
00059 virtual void setSize(int nx, int ny) {
00060 nx_ = nx;
00061 ny_ = ny;
00062 ns_ = nx * ny;
00063 }
00064 void setLethalCost(unsigned char lethal_cost) {
00065 lethal_cost_ = lethal_cost;
00066 }
00067 void setNeutralCost(unsigned char neutral_cost) {
00068 neutral_cost_ = neutral_cost;
00069 }
00070 void setFactor(float factor) {
00071 factor_ = factor;
00072 }
00073 void setHasUnknown(bool unknown) {
00074 unknown_ = unknown;
00075 }
00076
00077 void clearEndpoint(unsigned char* costs, float* potential, int gx, int gy, int s){
00078 int startCell = toIndex(gx, gy);
00079 for(int i=-s;i<=s;i++){
00080 for(int j=-s;j<=s;j++){
00081 int n = startCell+i+nx_*j;
00082 if(potential[n]<POT_HIGH)
00083 continue;
00084 float c = costs[n]+neutral_cost_;
00085 float pot = p_calc_->calculatePotential(potential, c, n);
00086 potential[n] = pot;
00087 }
00088 }
00089 }
00090
00091 protected:
00092 inline int toIndex(int x, int y) {
00093 return x + nx_ * y;
00094 }
00095
00096 int nx_, ny_, ns_;
00097 bool unknown_;
00098 unsigned char lethal_cost_, neutral_cost_;
00099 int cells_visited_;
00100 float factor_;
00101 PotentialCalculator* p_calc_;
00102
00103 };
00104
00105 }
00106 #endif