19 #ifndef SNARK_SENSORS_VELODYNE_IMPL_SERIALIZABLEDB_H_
20 #define SNARK_SENSORS_VELODYNE_IMPL_SERIALIZABLEDB_H_
25 #include <boost/array.hpp>
26 #include <boost/serialization/nvp.hpp>
27 #include <boost/serialization/utility.hpp>
29 #include <boost/serialization/version.hpp>
30 #include <boost/static_assert.hpp>
31 #include <boost/type_traits/is_class.hpp>
33 namespace snark {
namespace velodyne {
namespace impl {
38 template <
bool AddDummyversion = false >
41 template<
class Archive >
42 static void add_item_version( Archive& ) {}
51 template<
class Archive >
52 static void add_item_version( Archive& ar )
55 ar & boost::serialization::make_nvp(
"item_version", itemversion );
62 template <
typename T, std::
size_t Size,
bool HasUnexpectedItemversion = false >
66 BOOST_STATIC_ASSERT( Size > 0 );
68 typedef boost::array< T, Size > Type;
69 const Type& operator()()
const {
return m_value; }
70 Type& operator()() {
return m_value; }
76 friend class boost::serialization::access;
77 template <
typename U, std::
size_t S >
78 friend std::ostream& operator<<( std::ostream &os, const serializable_array< U, S >& gp );
80 template<
class Archive >
81 void serialize( Archive & ar,
const unsigned int )
83 ar & boost::serialization::make_nvp(
"count", m_count );
85 for( std::size_t i = 0; i < Size; ++i )
87 ar & boost::serialization::make_nvp(
"item", m_value[i] );
96 template<
class Archive >
97 void serialize( Archive & ar,
const unsigned int ) { ar & BOOST_SERIALIZATION_NVP( xyz ); }
100 struct orientation_type
102 impl::serializable_array< float, 3 > rpy;
104 template<
class Archive >
105 void serialize( Archive & ar,
const unsigned int ) { ar & BOOST_SERIALIZATION_NVP( rpy ); }
110 color_type() { rgb()[0] = rgb()[1] = rgb()[2] = 0; }
111 impl::serializable_array< float, 3 > rgb;
113 template<
class Archive >
114 void serialize( Archive & ar,
const unsigned int ) { ar & BOOST_SERIALIZATION_NVP( rgb ); }
121 , rotCorrection_( 0 )
122 , vertCorrection_( 0 )
123 , distCorrection_( 0 )
124 , vertOffsetCorrection_( 0 )
125 , horizOffsetCorrection_( 0 )
130 double rotCorrection_;
131 double vertCorrection_;
132 float distCorrection_;
133 float vertOffsetCorrection_;
134 float horizOffsetCorrection_;
136 template<
class Archive >
137 void serialize( Archive & ar,
const unsigned int )
139 ar & BOOST_SERIALIZATION_NVP( id_ )
140 & BOOST_SERIALIZATION_NVP( rotCorrection_ )
141 & BOOST_SERIALIZATION_NVP( vertCorrection_ )
142 & BOOST_SERIALIZATION_NVP( distCorrection_ )
143 & BOOST_SERIALIZATION_NVP( vertOffsetCorrection_ )
144 & BOOST_SERIALIZATION_NVP( horizOffsetCorrection_ );
152 template<
class Archive >
153 void serialize( Archive & ar,
const unsigned int ) { ar & BOOST_SERIALIZATION_NVP( px ); }
156 struct serializable_db
159 impl::position_type position_;
160 impl::orientation_type orientation_;
161 impl::serializable_array< impl::color_type, 64 > colors_;
162 impl::serializable_array< unsigned int, 64 > enabled_;
163 impl::serializable_array< unsigned char, 64 > intensity_;
164 impl::serializable_array< unsigned char, 64, true > minIntensity_;
165 impl::serializable_array< unsigned char, 64, true > maxIntensity_;
166 impl::serializable_array< impl::point_type, 64 > points_;
168 friend class boost::serialization::access;
169 friend std::ostream & operator<<( std::ostream &os,
const serializable_db &gp );
171 template<
class Archive >
172 void serialize( Archive & ar,
const unsigned int )
174 ar & BOOST_SERIALIZATION_NVP( distLSB_ )
175 & BOOST_SERIALIZATION_NVP( position_ )
176 & BOOST_SERIALIZATION_NVP( orientation_ )
177 & BOOST_SERIALIZATION_NVP( colors_ )
178 & BOOST_SERIALIZATION_NVP( enabled_ )
179 & BOOST_SERIALIZATION_NVP( intensity_ )
180 & BOOST_SERIALIZATION_NVP( minIntensity_ )
181 & BOOST_SERIALIZATION_NVP( maxIntensity_ )
182 & BOOST_SERIALIZATION_NVP( points_ );
188 #endif // SNARK_SENSORS_VELODYNE_IMPL_SERIALIZABLEDB_H_