planners/prm/PL_PRM.h

Go to the documentation of this file.
00001 //=========================================================================
00002 //
00003 //  File:  PL_PRM.h
00004 //
00005 //  Created by Ian Gipson, Modified by Shane Schneider.
00006 //
00007 //              Full and Lazy PRM planner.  Uses PL_GraphBase as parent class
00008 //              the basic graph structure and access functions.  This planner
00009 //              will modify the graph and implement the PRM planners.
00010 
00011 #ifndef PL_PRM_h
00012 #define PL_PRM_h 1
00013 
00014 #pragma warning( disable : 4250 )
00015 
00016 // Parent Classes
00017 #include "Planners\PL_GraphBase.h"
00018 
00019 // Additional LEDA Classes
00020 #include <LEDA/node_map.h>
00021 #include <LEDA/edge_map.h> 
00022 #include <LEDA/node_list.h>
00023 #include <LEDA/node_pq.h>
00024 #include <LEDA/list.h>
00025 
00026 
00027 
00028 
00029 //-------------- Forward Declarations -----------
00030 enum PRM_StateMachineType;
00031 
00032 //## Class: PL_PRM%3921BC600296
00033 //## Category: Planners%36FB140B003C
00034 //## Persistence: Transient
00035 //## Cardinality/Multiplicity: n
00036 
00037 class PL_PRM : 
00038         public PL_GraphBase  //## Inherits: Basic graph planner
00039 {
00040 
00041   public:
00042     //## Destructor (generated)
00043       virtual ~PL_PRM();
00044 
00045           // Default Constructor
00046           PL_PRM();                     
00047 
00048           virtual bool DrawExplicit () const;
00049 
00050       virtual bool Plan ();
00051 
00052           virtual void SetStartConfig( const Configuration& config );
00053           virtual void SetGoalConfig ( const Configuration& config );
00054 
00055           // Set the Collision Detector for the graph.
00056           virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector);
00057 
00058           virtual void *GetParameters();
00059           virtual bool SetParameters(const void *param);
00060           virtual bool ValidateParameters();
00061 
00062     // Additional Public Declarations
00063           void SetRadiusTol ( double tol );
00064           double GetRadiusTol ();
00065           
00066           void SetPRMMode ( BOOL& isLazy, BOOL& validNodes, BOOL& validEdges );
00067           void GetPRMMode ( BOOL& isLazy, BOOL& validNodes, BOOL& validEdges ) const;
00068 
00069           void SetUseMidPts ( BOOL use_them ) { useMidPts = use_them; };
00070           BOOL GetUseMidPts () const { return useMidPts; };
00071 
00072           PRM_StateMachineType GetLastPlanningState () const { return lastPlanningState; }; 
00073 
00074           void SetInitQuant ( int quant ) { initQuant = quant; };
00075           int  GetInitQuant () const { return initQuant; };
00076 
00077           void SetEnhanceQuant ( int quant ) { enhanceQuant = quant; };
00078           int  GetEnhanceQuant () const { return enhanceQuant; };
00079 
00080           void SetSeedRatio ( double ratio ) { seedRatio = ratio; };
00081           double GetSeedRatio () const { return seedRatio; };
00082 
00083           // Add Node Routine.
00084           BOOL AddNode();
00085 
00086           //copies the settings from a different planner
00087           void CopySettings( PlannerBase* original );
00088 
00089   protected:
00090         // Additional Implementation Declarations
00091           virtual void ConnectNode( const node& newnode );  // Connects the given node with edges.
00092           virtual void ConnectEdgesFull( const node& n1, const double& radius_squared );  // Connects the given node with edges, Full PRM style.
00093           virtual void ConnectEdgesLazy( const node& n1, const double& radius_squared );  // Connects the given node with edges, Lazy PRM style.
00094 
00095           // State Machine Functions
00096           SuccessResultType BuildInitRoadMap();
00097           SuccessResultType FindPath();
00098           SuccessResultType VerifyPath();
00099           SuccessResultType EnhanceRoadMap();
00100 
00101           // SaveContents
00102           //    Saves the graph and other relevent PRM parameters to the given ostream pointer
00103           virtual bool SaveContents( std::ofstream& outfile ) const;
00104 
00105           // LoadContents
00106           //    Load the graph and other relevent PRM parameters to the given ostream pointer
00107           virtual bool LoadContents( std::ifstream& infile );
00108 
00109           // Tree Graph Functions
00110           void SetGraphMode ( const bool& treeGraph );  // Sets the graph mode for either connect tree or fully connected graph
00111           bool NodeInConnectionList( const node& n1, const list<int>& connectIDs); // checks if node has a connectionID that is in the given list.
00112 
00113 
00114 
00115 
00116     // Additional Protected Declarations
00117           double diagonal_squared;      // records the current squared weighted diagonal.
00118           double radiusTol;                     // used for calculating the radius of neighbours to connect to.
00119 
00120           BOOL lazyMode;                        // Indicates if planner is currently in LazyPRM mode.
00121           BOOL validNodesOnly;          // Indicates if only valid nodes are to be added
00122           BOOL validEdgesOnly;          // Indicates if only valid edges are to be added
00123           BOOL useMidPts;                       // Indicates if midpoints of deleted (or proposed invalid) edges are to be used as seeds.
00124 
00125           PRM_StateMachineType lastPlanningState;       // Records what was the last state of the planning state machine.
00126 
00127           int initQuant;        // initial number of nodes to add when building roadmap.
00128           int enhanceQuant;     // number of nodes to add to roadmap when enhancing.
00129           double seedRatio; // Ratio of normally distributed nodes about seeds to uniformly distributed nodes.
00130 
00131           list<Configuration> config_seeds;   // List of configurations to be used as seeds during enhancement.
00132 
00133      
00134   protected:
00135     // Additional Private Declarations
00136         
00137           // Additional Graph statitics:
00138           node_map<BOOL> nodeChecked;   // Indicates if node has been checked for collisions
00139           edge_map<BOOL> edgeChecked;   // Indicates if edge has been checked for collisions
00140 
00141           node_map<BOOL> uniformlyAdded;// Indicates if the node was added uniformly added or based on a seed.
00142 
00143           // Tree Connected Graphs
00144           node_map<int>* connectIDp;    // Records the connection ID for tree connected nodes.
00145           int baseConnectID;                    // Records the next available connect graph component ID.
00146 
00147 
00148           // Find Path Variables.
00149           //    These are saved as part of the class because we want to resume from an interupted
00150           //    search.  These variables will then have to be available outside the scope of the FindPath
00151           //    Function so they can be access on subsequent iterations.  NOTE:  These variables
00152           //    should only be modified by FindPath only!
00153           node_map<node>   pred;   // stores the edge pointers to the prev node for any given path of nodes
00154           node_map<double> dist;   // records the distance of the current calculated path
00155           node_pq<double>* openp;       // pointer to the open list used to store possible nodes for the path
00156                                                                 // This needs to be a properly maintained pointer to the priority queue as
00157                                                                 // a priority queue can only be established for a properly defined graph.
00158           
00159   private: //## implementation
00160     // Additional Implementation Declarations
00161           
00162           // A* Cost Function
00163           inline double Astar_f( const node& n, const double& currcost ) const;
00164           
00165 
00166 };
00167 
00168 
00169 // Class PL_PRM 
00170 
00171 
00172 // PRM Specific ENUM Types
00173 enum PRM_StateMachineType
00174 {
00175         PRM_DONE = 0,
00176         PRM_START = 1,
00177         PRM_BUILD_INIT_ROADMAP,
00178         PRM_FIND_PATH,
00179         PRM_VERIFY_PATH,
00180         PRM_TRANSLATE_PATH,
00181         PRM_ENHANCE_ROADMAP,
00182         PRM_TIMER_EXPIRED = -1,
00183         PRM_FAILURE = -2
00184 };
00185 
00186 
00187 #endif

Generated on Sat Apr 1 21:30:45 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO