37 #include "ompl/base/PlannerDataStorage.h"
38 #include <boost/archive/archive_exception.hpp>
40 static const std::uint_fast32_t OMPL_PLANNER_DATA_ARCHIVE_MARKER = 0x5044414D;
48 std::ofstream out(filename, std::ios::binary);
49 bool r =
store(pd, out);
60 OMPL_ERROR(
"Failed to store PlannerData: output stream is invalid");
65 OMPL_ERROR(
"Failed to store PlannerData: SpaceInformation is invalid");
70 boost::archive::binary_oarchive oa(out);
74 h.marker = OMPL_PLANNER_DATA_ARCHIVE_MARKER;
77 si->getStateSpace()->computeSignature(h.signature);
80 storeVertices(pd, oa);
83 catch (boost::archive::archive_exception &ae)
85 OMPL_ERROR(
"Failed to store PlannerData: %s", ae.what());
94 std::ifstream in(filename, std::ios::binary);
95 bool r = load(in, pd);
108 OMPL_ERROR(
"Failed to load PlannerData: input stream is invalid");
113 OMPL_ERROR(
"Failed to load PlannerData: SpaceInformation is invalid");
119 boost::archive::binary_iarchive ia(in);
126 if (h.marker != OMPL_PLANNER_DATA_ARCHIVE_MARKER)
128 OMPL_ERROR(
"Failed to load PlannerData: PlannerData archive marker not found");
133 std::vector<int> sig;
134 si->getStateSpace()->computeSignature(sig);
135 if (h.signature != sig)
137 OMPL_ERROR(
"Failed to load PlannerData: StateSpace signature mismatch");
142 loadVertices(pd, h.vertex_count, ia);
143 loadEdges(pd, h.edge_count, ia);
145 catch (boost::archive::archive_exception &ae)
147 OMPL_ERROR(
"Failed to load PlannerData: %s", ae.what());
const SpaceInformationPtr & getSpaceInformation() const
Return the instance of SpaceInformation used in this PlannerData.
virtual bool store(const PlannerData &pd, const char *filename)
Store (serialize) the PlannerData structure to the given filename.
virtual bool load(const char *filename, PlannerData &pd)
Load the PlannerData structure from the given stream. The StateSpace that was used to store the data ...
virtual ~PlannerDataStorage()
Destructor.
unsigned int numEdges() const
Retrieve the number of edges in this structure.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique,...
unsigned int numVertices() const
Retrieve the number of vertices in this structure.
PlannerDataStorage()
Default constructor.
virtual void clear()
Clears the entire data structure.
#define OMPL_ERROR(fmt,...)
Log a formatted error string.