28 #ifndef BATCHING_POMP_UTIL_ROADMAPFROMFILE_HPP_ 29 #define BATCHING_POMP_UTIL_ROADMAPFROMFILE_HPP_ 34 #include <type_traits> 35 #include <boost/property_map/dynamic_property_map.hpp> 36 #include <boost/graph/graphml.hpp> 37 #include <boost/graph/adjacency_list.hpp> 38 #include <ompl/base/State.h> 39 #include <ompl/base/ScopedState.h> 40 #include <ompl/base/StateSpace.h> 41 #include <ompl/base/spaces/RealVectorStateSpace.h> 42 #include "rv_state_map_string_adaptor.hpp" 51 template <
class PropMap,
class StateCon>
55 typedef boost::writable_property_map_tag category;
56 typedef typename boost::property_traits<PropMap>::key_type key_type;
57 typedef std::string value_type;
58 typedef std::string reference;
60 const PropMap mPropMap;
61 ompl::base::StateSpacePtr mSpace;
62 const unsigned int mDim;
73 template <
class PropMap,
class StateCon>
76 const typename RoadmapFromFilePutStateMap<PropMap,StateCon>::key_type & k)
82 template <
class PropMap,
class StateCon>
85 const typename RoadmapFromFilePutStateMap<PropMap,StateCon>::key_type & k,
86 const std::string representation)
88 get(map.mPropMap, k).reset(
new StateCon(map.mSpace));
89 ompl::base::State* ver_state{
get(map.mPropMap, k)->state};
90 double * values{ver_state->as<ompl::base::RealVectorStateSpace::StateType>()->values};
91 std::stringstream ss(representation);
92 for (
unsigned int ui=0; ui<map.mDim; ui++){
106 template <
class Graph,
class VStateMap,
class StateCon,
class EDistance>
109 typedef boost::graph_traits<Graph> GraphTypes;
110 typedef typename GraphTypes::vertex_descriptor Vertex;
111 typedef typename GraphTypes::vertex_iterator VertexIter;
112 typedef typename GraphTypes::edge_descriptor Edge;
113 typedef typename GraphTypes::edge_iterator EdgeIter;
117 const std::string mFilename;
120 const ompl::base::StateSpacePtr _space,
121 std::string _filename)
123 , mFilename(_filename)
126 if (mSpace->getType() != ompl::base::STATE_SPACE_REAL_VECTOR) {
127 throw std::runtime_error(
"This only supports real vector state spaces!");
130 mDim = mSpace->getDimension();
131 mBounds = mSpace->as<ompl::base::RealVectorStateSpace>()->getBounds();
136 void generateVertices(Graph& _roadmap,
140 fp.open(mFilename.c_str());
142 boost::dynamic_properties props;
143 props.property(
"state",
146 boost::read_graphml(fp, _roadmap, props);
149 void generateEdges(Graph& _roadmap,
151 EDistance _distanceMap)
154 for (boost::tie(ei,ei_end)=edges(_roadmap); ei!=ei_end; ++ei)
156 ompl::base::State * state1 =
get(_stateMap, source(*ei,_roadmap))->state;
157 ompl::base::State * state2 =
get(_stateMap, target(*ei,_roadmap))->state;
158 put(_distanceMap, *ei, mSpace->distance(state1,state2));
165 ompl::base::RealVectorBounds mBounds;
166 const ompl::base::StateSpacePtr mSpace;
175 #endif //BATCHING_POMP_UTIL_ROADMAPFROMFILE_HPP_ Reads a roadmap encoded as a .graphml file and creates the corresponding Boost Graph.
Definition: RoadmapFromFile.hpp:107
Definition: BatchingManager.hpp:36
The map used to decode the .graphml file and populate vertex states.
Definition: RoadmapFromFile.hpp:52
Composite struct to associate the state space with each state.
Definition: BatchingPOMP.hpp:55