00001
00003
00004
00005
00006
00007
00009
00010 #ifndef _PL_MPEP_HEADER_
00011 #define _PL_MPEP_HEADER_
00012
00013 #define DEFAULT_SAMPLE_RATE 10
00014 #define DEFAULT_TOLERANCE 0.1
00015 #define DEFAULT_RANDOM_RETRY 150
00016 #define DEFAULT_EXTEND_RETRY 50 //times the number of sample
00017 #define DEFAULT_EXPLORE_RETRY 20
00018 #define DEFAULT_ITERATION 10
00019 #define DEFAULT_SMGNODE_NUM 10
00020
00021
00022
00023
00024 #define ALG_GREEDY_PLANNER 0x00
00025 #define ALG_RRT_LIKE 0x01
00026 #define ALG_RRT_CONNECT_LIKE 0x02
00027 #define ALG_RRT_GREEDY_LIKE 0x03
00028 #define ALG_RRT_GREED_CONNECT 0x04
00029 #define ALG_IMP_GREEDY_PLANNER 0x05
00030 #define ALG_SMG_GREEDY_PLANNER 0x06
00031 #define ALG_SMG_RRT_PLANNER 0x07
00032 #define ALG_SMG_CONNECT_PLANNER 0x08
00033
00034 #define ERROR_OK 0x00
00035 #define ERROR_GET_RANDOM_CONF_FAILURE 0x01
00036 #define ERROR_GET_COLLISION_FREE_FAILURE 0x02
00037 #define ERROR_RRT_EXTEND_FAILURE 0x03
00038 #define ERROR_START_CONFIG_INVALID 0x04
00039 #define ERROR_GOAL_CONFIG_INVALID 0x05
00040 #define ERROR_SMGRAPH_FULL 0x06
00041 #define ERROR_PLANNING_TIMEOUT 0x0FE
00042
00043 #define ERROR_UNKNOW_PLANNER 0x0FF
00044
00045 #define TRAJ_LINE 0x00
00046 #define TRAJ_SEMICIRCLE 0x01
00047 #define TRAJ_CIRCLE 0x02
00048
00049 #pragma warning( disable : 4250 )
00050
00051 #include "Kinematics/Jacobian.h"
00052 #include "Robots/R_OpenChain.h"
00053 #include "geometry/Frame.h"
00054 #include "kinematics/Configuration.h"
00055 #include "CollisionDetectors/CD_BasicStyle.h"
00056 #include "kinematics/FrameManager.h"
00057 #include "Robots\RobotBase.h"
00058 #include "../inversekin/Redundant.h"
00059
00060 #include "Planners/PL_Boolean_Output.h"
00061 #include "Planners/PL_OpenGL.h"
00062
00063 #include "Planners/PL_GraphBase.h"
00064
00065 #include <LEDA/dynamic_trees.h>
00066
00067
00068
00069
00070 #undef array
00071 #undef vector
00072 #undef map
00073 #undef string
00074 #undef set
00075
00076
00077
00078 class SMGraph;
00079 class CRedundant;
00080
00081 typedef struct
00082 {
00083 int poses;
00084 SMGraph *graph;
00085 Configuration conf;
00086 }
00087 Pose_Node;
00088
00089 class PL_MPEP: public PL_Boolean_Output, public PL_OpenGL
00090 {
00091 public:
00092 PL_MPEP();
00093 virtual ~PL_MPEP();
00094
00095
00096 virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector);
00097 virtual bool DrawExplicit () const;
00098 virtual bool Plan ();
00099
00100 Frame GetToolFrame( const Configuration& config ) const;
00101
00102
00103 void SetTrajectory(std::vector<Frame> &traj);
00104 void SetPassiveNum(unsigned int num);
00105 void SetAlgorithm(unsigned int alg);
00106 void SetTolerance(double dist);
00107 void SetUsingStartConfig(bool use);
00108 void SetUsingGoalConfig(bool use);
00109 void SetRandomRetry(unsigned int retry);
00110 void SetExtendNum(unsigned int num);
00111 void SetExploreNum(unsigned int num);
00112 void SetIterationNum(unsigned int num);
00113
00114 void SetSMGNodeNum(unsigned int num);
00115 void SetUsingJacobianExt(bool use);
00116
00117 protected:
00118
00119
00120 bool GetConfigurationByDirection(Configuration &conf, Configuration &base, Configuration &direct);
00121
00122 bool GetRandomConfiguration(Configuration &conf);
00123
00124 bool GetRandomConfiguration(Configuration &conf, Frame &frame);
00125
00126 bool GetRandomConfiguration(Configuration &conf, Frame &frame, Configuration &bias);
00127
00128
00129
00130 int Greedy_Step(int &begin, int end, vertex &base);
00131
00132 int RRT_Extend_Like(dynamic_trees &tr, std::vector<vertex> &vert, int &extPose, vertex &extended, int dir=1);
00133 int Step(dynamic_trees &tr, std::vector<vertex> &vert, int begin, int end, vertex &base, int dir=1);
00134
00135 bool IsJointWithinLimits(Configuration& config);
00136 bool AdjustConfiguration(Configuration &config, int nPose);
00137 int Extend_Node_Self_Motion_Graph_Jacobian(vertex g_vertex, Configuration **nextConf);
00138
00139
00140 int Establish_Self_Motion_Graph(dynamic_trees &tr, vertex extended);
00141
00142 int Extend_Node_Self_Motion_Graph(vertex g_vertex, Configuration **);
00143
00144 int CheckConnectivity(dynamic_trees &tr, std::vector<vertex> &vert, vertex extendedVert, vertex &connectedVert, int dir);
00145
00146
00147 int Planner_Greedy();
00148 int Planner_RRT_Like();
00149 int Planner_RRT_Connect_Like();
00150 int Planner_RRT_Greedy_Like();
00151 int Planner_RRT_Greedy_Connect();
00152
00153
00154 int Planner_IMP_Greedy();
00155
00156 int Planner_SMG_Greedy();
00157
00158 int Planner_SMG_RRT_Connect_Like();
00159
00160 int Planner_SMG_RRT_Greedy_Like();
00161
00162 protected:
00163
00164 void ClearTree();
00165 int InitializeTree();
00166 void RetrievePathFromTree();
00167 vertex ConnectNode(dynamic_trees &tr, std::vector<vertex> &vert, vertex &parent, Pose_Node &child);
00168
00169 vertex GetNearestNodeInTree(dynamic_trees &tr, std::vector<vertex> &vert, Configuration &conf);
00170
00171 vertex GetClosestPoseVert(dynamic_trees &tr, std::vector<vertex> &vert);
00172
00173
00174 void *GetNearestNodeInGraph(SMGraph *graph, Configuration *conf);
00175
00176
00177 double Distance(Configuration &conf1, Configuration &conf2);
00178 double DistanceInActiveJoints(Configuration &conf1, Configuration &conf2);
00179
00180
00181 void Display_Error_Message(int result);
00182
00183 protected:
00184 R_OpenChain * m_pRobot;
00185 int m_nDof;
00186 int m_nToolFrame;
00187 Frame m_frEndEffector;
00188 CJacobian *m_pJacobian;
00189
00190 protected:
00191
00192 CRedundant redundant;
00193
00194
00195 vertex goalPoseVertex;
00196 vertex goalPoseVertex2;
00197
00198
00199
00200
00201 vertex startPoseVertex;
00202
00203
00204
00205
00206 dynamic_trees tree;
00207 std::vector<vertex> vertices;
00208
00209
00210
00211 dynamic_trees goal_tree;
00212 std::vector<vertex> goal_vertices;
00213
00214
00215 std::vector<vertex> itinerary;
00216
00217
00218
00219 std::vector<Frame> poses;
00220
00221
00222 unsigned int algorithm;
00223 unsigned int passiveNum;
00224 unsigned int randomRetry;
00225 unsigned int extendNum;
00226 unsigned int exploreNum;
00227 unsigned int iterationNum;
00228 unsigned int smgNodeNum;
00229 double distTolerance;
00230 bool usingStartConfig;
00231 bool usingGoalConfig;
00232 bool usingGoalTree;
00233 bool usingJacobianExt;
00234
00235 private:
00236 };
00237
00238 #endif