38 #include <boost/version.hpp>
39 #if BOOST_VERSION < 104400
40 #warning Boost version >= 1.44 is required for PlannerDataStorage classes
43 #include "ompl/control/PlannerDataStorage.h"
44 #include <boost/archive/archive_exception.hpp>
47 static const boost::uint32_t OMPL_PLANNER_DATA_CONTROL_ARCHIVE_MARKER = 0x5044434D;
67 OMPL_WARN(
"PlannerData does not have controls. Invoking base::PlannerDataStorage::load");
78 OMPL_ERROR(
"Failed to load PlannerData: input stream is invalid");
83 OMPL_ERROR(
"Failed to load PlannerData: SpaceInformation is invalid");
89 boost::archive::binary_iarchive ia(in);
96 if (h.marker != OMPL_PLANNER_DATA_CONTROL_ARCHIVE_MARKER)
98 OMPL_ERROR(
"Failed to load PlannerData: PlannerData control archive marker not found");
103 std::vector<int> sig;
104 si->getStateSpace()->computeSignature(sig);
105 if (h.signature != sig)
107 OMPL_ERROR(
"Failed to load PlannerData: StateSpace signature mismatch");
113 si->getControlSpace()->computeSignature(sig);
114 if (h.control_signature != sig)
116 OMPL_ERROR(
"Failed to load PlannerData: ControlSpace signature mismatch");
121 loadVertices(pd, h.vertex_count, ia);
122 loadEdges(pd, h.edge_count, ia);
124 catch (boost::archive::archive_exception &ae)
126 OMPL_ERROR(
"Failed to load PlannerData: %s", ae.what());
140 OMPL_WARN(
"Failed to cast PlannerData to control::PlannerData. Invoking base::PlannerDataStorage::store");
148 OMPL_ERROR(
"Failed to store PlannerData: output stream is invalid");
153 OMPL_ERROR(
"Failed to store PlannerData: SpaceInformation is invalid");
158 boost::archive::binary_oarchive oa(out);
162 h.
marker = OMPL_PLANNER_DATA_CONTROL_ARCHIVE_MARKER;
165 si->getStateSpace()->computeSignature(h.
signature);
166 si->getControlSpace()->computeSignature(h.control_signature);
169 storeVertices(pd, oa);
172 catch (boost::archive::archive_exception &ae)
174 OMPL_ERROR(
"Failed to store PlannerData: %s", ae.what());
unsigned int numVertices(void) const
Retrieve the number of vertices in this structure.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Object that handles loading/storing a PlannerData object to/from a binary stream. Serialization of ve...
PlannerDataStorage(void)
Default constructor.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
virtual void store(const base::PlannerData &pd, const char *filename)
Store (serialize) the structure to the given filename. The StateSpace and ControlSpace that was used ...
virtual ~PlannerDataStorage(void)
Destructor.
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 ...
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
const SpaceInformationPtr & getSpaceInformation(void) const
Return the instance of SpaceInformation used in this PlannerData.
#define OMPL_WARN(fmt,...)
Log a formatted warning string.
virtual bool hasControls(void) const
Indicate whether any information about controls (ompl::control::Control) is stored in this instance...
unsigned int numEdges(void) const
Retrieve the number of edges in this structure.
virtual void clear(void)
Clears the entire data structure.
virtual void store(const PlannerData &pd, const char *filename)
Store (serialize) the PlannerData structure to the given filename.
virtual void load(const char *filename, base::PlannerData &pd)
Load the PlannerData structure from the given filename.