00001 //========================================================================= 00002 // 00003 // File: PL_Astar.h 00004 // 00005 // Created by Shane Schneider 00006 // 00007 // Base A* Planner. 00008 // 00009 00010 #ifndef PL_ASTAR_h 00011 #define PL_ASTAR_h 1 00012 00013 #pragma warning( disable : 4250 ) 00014 00015 // Parent Classes 00016 #include "Planners\PL_GraphBase.h" 00017 00018 // Additional LEDA Classes 00019 #include <LEDA/node_map.h> 00020 #include <LEDA/node_pq.h> 00021 00022 //## Class: PL_Astar%3921BC600296 00023 //## Category: Planners%36FB140B003C 00024 //## Persistence: Transient 00025 //## Cardinality/Multiplicity: n 00026 00027 class PL_Astar : 00028 public PL_GraphBase //## Inherits: Basic graph planner 00029 { 00030 00031 public: 00032 //## Destructor (generated) 00033 virtual ~PL_Astar(); 00034 00035 // Default Constructor 00036 PL_Astar(); 00037 00038 //virtual bool DrawExplicit () const; 00039 //virtual bool DrawSpecific () const; 00040 00041 virtual bool Plan (); 00042 00043 virtual void SetStartConfig( const Configuration& config ); 00044 virtual void SetGoalConfig ( const Configuration& config ); 00045 00046 virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector); 00047 00048 virtual void ClearGraph(); 00049 00050 // Additional Public Declarations 00051 00052 // Assign the StepSize 00053 void SetDefaultStepSize(); // Assigns a default step size for each of the joints based on the joint limits. 00054 void SetStepSize( const VectorN& newstepsize ); 00055 VectorN GetStepSize() const { return stepsize; } ; 00056 00057 void SetCostWeight( const double& cost ) { weight = cost; }; 00058 double GetCostWeight() const { return weight; }; 00059 00060 void CopySettings( PlannerBase* original ); 00061 00062 protected: 00063 // Additional Implementation Declarations 00064 //Cost Function 00065 virtual double Astar_f( const node& n, const double& currcost ) const; 00066 00067 // Aligns a given joint value to the grid specificed by the stepsize and start config. 00068 double AlignJoint ( const int& jointNum, const double& jointValue ) const; 00069 00070 // Returns the aligned configuration closest to given config. 00071 Configuration AlignConfig( const Configuration& config ) const; 00072 00073 // Expands the node by connecting all configurations within stepsize 00074 void ExpandNode( const node& n ); 00075 00076 // Initialize a new search 00077 void InitNewSearch(); 00078 00079 // SaveContents 00080 // Saves the graph and other relevent PRM parameters to the given ostream pointer 00081 virtual bool SaveContents( std::ofstream& outfile ) const; 00082 00083 // LoadContents 00084 // Load the graph and other relevent PRM parameters to the given ostream pointer 00085 virtual bool LoadContents( std::ifstream& infile ); 00086 00087 00088 // Additional Protected Declarations 00089 node_map<bool> nodeExpanded; // records if node has been previously expanded 00090 00091 node_map<node> pred; // stores the prev node for any given path of nodes 00092 node_map<double> dist; // records the distance of the current calculated path upto specified node 00093 00094 node_pq<double>* openp; // pointer to open priority queue. 00095 00096 VectorN stepsize; // Records the stepsize Astar should step for each joint 00097 VectorN invStepSize; // Stores the inverse of each of the step sizes. Needs to be recalculated each time stepsize is changed. 00098 00099 bool goalOnGrid; // Indicates if the goal node is on the grid formed by stepsize and the start config. 00100 SuccessResultType plan_success; // Indicates if the planner has been successful in finding a path 00101 00102 double weight; // weight used in Astar Cost function. 00103 00104 private: 00105 // Additional Private Declarations 00106 // Calculate the inverse of each of the steps sizes and assign it. 00107 void InvertStepSize(); 00108 00109 00110 private: //## implementation 00111 // Additional Implementation Declarations 00112 00113 00114 00115 }; 00116 00117 00118 // Class PL_Astar 00119 00120 00121 #endif