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);
58 OMPL_ERROR(
"Failed to store PlannerData: output stream is invalid");
63 OMPL_ERROR(
"Failed to store PlannerData: SpaceInformation is invalid");
68 boost::archive::binary_oarchive oa(out);
72 h.marker = OMPL_PLANNER_DATA_ARCHIVE_MARKER;
75 si->getStateSpace()->computeSignature(h.signature);
78 storeVertices(pd, oa);
81 catch (boost::archive::archive_exception &ae)
83 OMPL_ERROR(
"Failed to store PlannerData: %s", ae.what());
89 std::ifstream in(filename, std::ios::binary);
101 OMPL_ERROR(
"Failed to load PlannerData: input stream is invalid");
106 OMPL_ERROR(
"Failed to load PlannerData: SpaceInformation is invalid");
112 boost::archive::binary_iarchive ia(in);
119 if (h.marker != OMPL_PLANNER_DATA_ARCHIVE_MARKER)
121 OMPL_ERROR(
"Failed to load PlannerData: PlannerData archive marker not found");
126 std::vector<int> sig;
127 si->getStateSpace()->computeSignature(sig);
128 if (h.signature != sig)
130 OMPL_ERROR(
"Failed to load PlannerData: StateSpace signature mismatch");
135 loadVertices(pd, h.vertex_count, ia);
136 loadEdges(pd, h.edge_count, ia);
138 catch (boost::archive::archive_exception &ae)
140 OMPL_ERROR(
"Failed to load PlannerData: %s", ae.what());
const SpaceInformationPtr & getSpaceInformation() const
Return the instance of SpaceInformation used in this PlannerData.
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,...
virtual void store(const PlannerData &pd, const char *filename)
Store (serialize) the PlannerData structure to the given filename.
unsigned int numVertices() const
Retrieve the number of vertices in this structure.
PlannerDataStorage()
Default constructor.
virtual void load(const char *filename, PlannerData &pd)
Load the PlannerData structure from the given stream. The StateSpace that was used to store the data ...
virtual void clear()
Clears the entire data structure.
#define OMPL_ERROR(fmt,...)
Log a formatted error string.