00001 #ifndef _SMGraph_Header_ 00002 #define _SMGraph_Header_ 00003 00004 #include <LEDA/graph.h> 00005 #include "kinematics\Configuration.h" 00006 00007 class SMGraph 00008 { 00009 public: 00010 SMGraph(Configuration &entry); 00011 ~SMGraph(); 00012 00013 //The following two method, use to set the initial and goal 00014 // in the self-motin graph 00015 bool SetEntryConfig(Configuration &entry); 00016 bool SetExitConfig(Configuration &exit); 00017 00018 //The following function used to traverse the graph 00019 void* FirstNode(); 00020 void* NextNode(); 00021 Configuration* GetConfiguration(void *v); 00022 00023 //According to the initial and goal find a feasible path 00024 // in the self-motion grpah. 00025 bool GetPath(); 00026 Configuration* FirstConfigInPath(); 00027 Configuration* NextConfigInPath(); 00028 00029 //Add and edge in the self-motion graph 00030 void* AddConnection(void* parent, Configuration &son); 00031 void* AddConnection(Configuration &parent, Configuration &son); 00032 void Clear(); 00033 00034 //Optimize the connections in the self-motion graph, 00035 virtual bool OptimizeConnection(); 00036 00037 //Return the number of Node in this Graph 00038 int Node_Num(); 00039 00040 //The following functions are used for plotting. 00041 //Return the Graph data structure. 00042 GRAPH<Configuration *, double> *GetSMGraph(); 00043 //Return the number of edges in this graph 00044 int Node_Edge(); 00045 void GetConfig(const node& n, Configuration **conf); 00046 void GetConfig(const edge& e, Configuration **conf1, Configuration **conf2); 00047 private: 00048 node NewNode(Configuration &config); 00049 node Lookup(Configuration &config); 00050 double Distance (const Configuration& a, const Configuration& b); 00051 00052 00053 private: 00054 //Private member to save the entry and exit configurations. 00055 node entryNode; 00056 node exitNode; 00057 00058 //The current pointer for traversing all node 00059 node currentNode; 00060 00061 //The current pointer for retrieving path 00062 list_item current; 00063 list<Configuration *> path; 00064 00065 //Self motion Graph, using Graph data structure in Leda 00066 //The NODE is about the configuration 00067 // while, the EDGE is about the weight, distance. 00068 GRAPH<Configuration *, double> G; 00069 }; 00070 00071 #endif