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 #ifndef PLANNING_GRAPH_H_
00026 #define PLANNING_GRAPH_H_
00027
00028 #include <boost/graph/adjacency_list.hpp>
00029 #include "descartes_core/trajectory_pt.h"
00030 #include "descartes_trajectory/cart_trajectory_pt.h"
00031 #include "descartes_trajectory/joint_trajectory_pt.h"
00032
00033 #include <map>
00034 #include <vector>
00035
00036 namespace descartes_planner
00037 {
00038
00039 struct JointVertex
00040 {
00041 descartes_core::TrajectoryPt::ID id;
00042 };
00043 struct JointEdge
00044 {
00045 descartes_core::TrajectoryPt::ID joint_start;
00046 descartes_core::TrajectoryPt::ID joint_end;
00047 double transition_cost;
00048 };
00049
00050 struct CartesianPointRelationship
00051 {
00052 descartes_core::TrajectoryPt::ID id;
00053 descartes_core::TrajectoryPt::ID id_previous;
00054 descartes_core::TrajectoryPt::ID id_next;
00055 };
00056
00057 typedef boost::adjacency_list<boost::listS,
00058 boost::vecS,
00059 boost::bidirectionalS,
00060 JointVertex,
00061 JointEdge
00062 > JointGraph;
00063
00064 typedef boost::graph_traits<JointGraph>::vertex_iterator VertexIterator;
00065 typedef boost::graph_traits<JointGraph>::edge_iterator EdgeIterator;
00066 typedef boost::graph_traits<JointGraph>::out_edge_iterator OutEdgeIterator;
00067 typedef boost::graph_traits<JointGraph>::in_edge_iterator InEdgeIterator;
00068
00069 struct CartesianPointInformation
00070 {
00071 CartesianPointRelationship links_;
00072 descartes_core::TrajectoryPtPtr source_trajectory_;
00073 std::list<descartes_core::TrajectoryPt::ID> joints_;
00074 };
00075
00076 typedef std::map<descartes_core::TrajectoryPt::ID, CartesianPointInformation> CartesianMap;
00077
00078 class PlanningGraph
00079 {
00080 public:
00081
00082 PlanningGraph(descartes_core::RobotModelConstPtr model);
00083
00084 virtual ~PlanningGraph();
00085
00090 bool insertGraph(const std::vector<descartes_core::TrajectoryPtPtr> *points);
00091
00096 bool addTrajectory(descartes_core::TrajectoryPtPtr point, descartes_core::TrajectoryPt::ID previous_id, descartes_core::TrajectoryPt::ID next_id);
00097
00098 bool modifyTrajectory(descartes_core::TrajectoryPtPtr point);
00099
00100 bool removeTrajectory(descartes_core::TrajectoryPtPtr point);
00101
00102 CartesianMap getCartesianMap();
00103
00104 bool getCartesianTrajectory(std::vector<descartes_core::TrajectoryPtPtr>& traj);
00105
00113 bool getShortestPath(double &cost, std::list<descartes_trajectory::JointTrajectoryPt> &path);
00114
00115
00116
00117
00121 void printGraph();
00122 void printMaps();
00123
00124 descartes_core::RobotModelConstPtr getRobotModel();
00125
00126 protected:
00127 descartes_core::RobotModelConstPtr robot_model_;
00128
00129 JointGraph dg_;
00130
00131 int recalculateJointSolutionsVertexMap(std::map<descartes_core::TrajectoryPt::ID, JointGraph::vertex_descriptor> &joint_vertex_map);
00132
00137 typedef std::pair<bool, double> LinearWeightResult;
00138
00140 LinearWeightResult linearWeight(const descartes_trajectory::JointTrajectoryPt& start,
00141 const descartes_trajectory::JointTrajectoryPt& end) const;
00142
00143
00144
00145
00146
00147 std::map<descartes_core::TrajectoryPt::ID, CartesianPointInformation> *cartesian_point_link_;
00148
00149
00150
00151 std::map<descartes_core::TrajectoryPt::ID, descartes_trajectory::JointTrajectoryPt> joint_solutions_map_;
00152
00154 bool findStartVertices(std::list<JointGraph::vertex_descriptor> &start_points);
00155
00157 bool findEndVertices(std::list<JointGraph::vertex_descriptor> &end_points);
00158
00160 bool calculateJointSolutions();
00161
00163 bool populateGraphVertices();
00164
00166 bool calculateEdgeWeights(const std::list<descartes_core::TrajectoryPt::ID> &start_joints,
00167 const std::list<descartes_core::TrajectoryPt::ID> &end_joints, std::list<JointEdge> &edge_results);
00168
00170 bool calculateAllEdgeWeights(std::list<JointEdge> &edges);
00171
00173 bool populateGraphEdges(const std::list<JointEdge> &edges);
00174 };
00175
00176 }
00177
00178 #endif