2 #ifndef _TUW_VORONOI_SERIALIZER 3 #define _TUW_VORONOI_SERIALIZER 5 #include <nav_msgs/OccupancyGrid.h> 11 #include <boost/archive/xml_oarchive.hpp> 12 #include <boost/archive/xml_iarchive.hpp> 14 #define DEFAULT_MAP_NAME "voronoi_map" 15 #include <eigen3/Eigen/Dense> 16 #include <opencv/cv.hpp> 17 #include <boost/filesystem.hpp> 18 #include <boost/functional/hash.hpp> 42 template<
class archive>
void serialize(archive & ar,
const unsigned int version)
44 using boost::serialization::make_nvp;
45 ar & boost::serialization::make_nvp(
"x", x);
46 ar & boost::serialization::make_nvp(
"y", y);
55 GraphInfo(Eigen::Vector2d _pt,
float _resolution,
int _nrSegments_) : Origin(_pt)
57 Resolution = _resolution;
58 SegmentLength = _nrSegments_;
65 friend class boost::serialization::access;
66 template<
class archive>
void serialize(archive & ar,
const unsigned int version)
68 using boost::serialization::make_nvp;
69 ar & boost::serialization::make_nvp(
"Origin", Origin);
70 ar & boost::serialization::make_nvp(
"Resolution", Resolution);
71 ar & boost::serialization::make_nvp(
"SegmentLength", SegmentLength);
80 for(uint32_t i = 0; i < _segs.size(); i++)
82 int * pred = Predecessors.get();
83 int * succ = Successors.get();
84 int * point = Points.get();
85 pred[i] = _segs[i].getPredecessors().size();
86 succ[i] = _segs[i].getSuccessors().size();
87 point[i] = _segs[i].getPath().size();
92 Predecessors.reset(
new int[_length]);
93 Successors.reset(
new int[_length]);
94 Points.reset(
new int[_length]);
108 friend class boost::serialization::access;
109 template<
class archive>
void serialize(archive & ar,
const unsigned int version)
111 using boost::serialization::make_nvp;
112 ar & boost::serialization::make_nvp(
"Length", Length);
113 ar & boost::serialization::make_array<int>(Predecessors.get(), Length);
114 ar & boost::serialization::make_array<int>(Successors.get(), Length);
115 ar & boost::serialization::make_array<int>(Points.get(), Length);
130 predecessorLength = _predLength;
131 successorLength = _succLength;
132 pointLength = _pointLength;
133 predecessors.reset(
new int[predecessorLength]);
134 successors.reset(
new int[successorLength]);
144 SegmentSerializer(
const uint32_t _id, std::vector<uint32_t> _predecessors, std::vector<uint32_t> _successors,
float _minDistance, std::vector<Eigen::Vector2d> _points):
148 minDistance = _minDistance;
150 int *pred = predecessors.get();
151 int *succ = successors.get();
155 for(
int i = 0; i < predecessorLength; i++)
157 pred[i] = _predecessors[i];
160 for(
int i = 0; i < successorLength; i++)
162 succ[i] = _successors[i];
165 for(uint32_t i = 0; i < _points.size(); i++)
182 friend class boost::serialization::access;
183 template<
class archive>
void serialize(archive & ar,
const unsigned int version)
185 using boost::serialization::make_nvp;
186 ar & boost::serialization::make_nvp(
"id",
id);
187 ar & boost::serialization::make_nvp(
"predecessorLength", predecessorLength);
188 ar & boost::serialization::make_nvp(
"successorLength", successorLength);
189 ar & boost::serialization::make_nvp(
"minDistance", minDistance);
190 ar & boost::serialization::make_nvp(
"pointLength", pointLength);
191 ar & boost::serialization::make_array<int>(predecessors.get(), predecessorLength);
192 ar & boost::serialization::make_array<int>(successors.get(), successorLength);
193 ar & boost::serialization::make_array<PointSerializer>(points.get(), pointLength);
203 segments_ = &_segments[0];
204 Length = _segments.size();
209 friend class boost::serialization::access;
210 template<
class archive>
void serialize(archive & ar,
const unsigned int version)
212 using boost::serialization::make_nvp;
213 ar & boost::serialization::make_nvp(
"pointLength", Length);
214 ar & boost::serialization::make_array<SegmentSerializer>(segments_, Length);
229 void save(
const std::string &_mapPath,
const std::vector<Segment> &_segs,
const Eigen::Vector2d &_origin,
const float &_resolution);
237 bool load(
const std::string &_mapPath, std::vector<Segment> &_segs, Eigen::Vector2d &_origin,
float &_resolution);
244 size_t getHash(
const std::vector<signed char> &_map, Eigen::Vector2d _origin,
float _resolution);
void serialize(archive &ar, const unsigned int version)
friend class boost::serialization::access
GraphInfo(Eigen::Vector2d _pt, float _resolution, int _nrSegments_)
GraphSerializer(std::vector< SegmentSerializer > &_segments)
TreeInfo(std::vector< Segment > _segs)
PointSerializer(Eigen::Vector2d p)
std::unique_ptr< int > Predecessors
void serialize(archive &ar, const unsigned int version)
SegmentSerializer(const uint32_t _id, std::vector< uint32_t > _predecessors, std::vector< uint32_t > _successors, float _minDistance, std::vector< Eigen::Vector2d > _points)
std::unique_ptr< int > predecessors
void serialize(archive &ar, const unsigned int version)
SegmentSerializer(const Segment &_s)
std::unique_ptr< PointSerializer > points
SegmentSerializer(int _predLength, int _succLength, int _pointLength)
std::unique_ptr< int > successors
ROSLIB_DECL std::string getPath(const std::string &package_name)
void serialize(archive &ar, const unsigned int version)
PointSerializer(float _x, float _y)
void serialize(archive &ar, const unsigned int version)
std::unique_ptr< int > Successors
std::unique_ptr< int > Points
SegmentSerializer * segments_