Commit 12d667be authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

Fix serialization of liegroup::VectorSpaceOperation<-1,...>

parent 1325ddfb
...@@ -24,39 +24,23 @@ ...@@ -24,39 +24,23 @@
namespace boost { namespace boost {
namespace serialization { namespace serialization {
template<class Archive, int Size, bool rot>
inline void load(Archive & ar,
hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>& lg,
const unsigned int version)
{
(void) version;
if (Size == Eigen::Dynamic) {
int size;
ar & make_nvp("size", size);
lg = hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot> (size);
}
}
template<class Archive, int Size, bool rot> template<class Archive, int Size, bool rot>
inline void save(Archive & ar, inline void serialize(Archive & ar,
const hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>& lg, hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>& lg,
const unsigned int version) const unsigned int version)
{ {
(void) version; (void) version;
if (Size == Eigen::Dynamic) { if (Size == Eigen::Dynamic) {
int size = static_cast<int>(lg.nq()); int size = static_cast<int>(lg.nq());
ar & make_nvp("size", size); ar & make_nvp("size", size);
if (!Archive::is_saving::value) {
// TODO VectorSpaceOperation should provide a resize operation.
lg = hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>(size);
}
} }
} }
template<class Archive, int Size, bool rot>
inline void serialize(Archive & ar,
hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>& lg,
const unsigned int version)
{
split_free(ar, lg, version);
}
template<class Archive, typename LieGroup1, typename LieGroup2> template<class Archive, typename LieGroup1, typename LieGroup2>
inline void serialize(Archive & ar, inline void serialize(Archive & ar,
hpp::pinocchio::liegroup::CartesianProductOperation<LieGroup1, LieGroup2>& lg, hpp::pinocchio::liegroup::CartesianProductOperation<LieGroup1, LieGroup2>& lg,
......
...@@ -58,7 +58,7 @@ namespace hpp { ...@@ -58,7 +58,7 @@ namespace hpp {
/// Constructor /// Constructor
/// \param size size of the vector space: should be the equal to /// \param size size of the vector space: should be the equal to
/// template argument for static sized vector-spaces. /// template argument for static sized vector-spaces.
VectorSpaceOperation (int size = Size) : Base (size) VectorSpaceOperation (int size = boost::static_signed_max<0,Size>::value) : Base (size)
{ {
} }
......
...@@ -291,10 +291,9 @@ BOOST_AUTO_TEST_CASE (log_) ...@@ -291,10 +291,9 @@ BOOST_AUTO_TEST_CASE (log_)
BOOST_CHECK ((hpp::pinocchio::log(e).isZero(1e-10))); BOOST_CHECK ((hpp::pinocchio::log(e).isZero(1e-10)));
} }
BOOST_AUTO_TEST_CASE (serialization) void test_serialization(LiegroupSpacePtr_t space)
{ {
LiegroupSpacePtr_t R6xSO3 (LiegroupSpace::R3 () * LiegroupSpace::R3xSO3 ()); LiegroupElement e (space); e.setNeutral ();
LiegroupElement e (R6xSO3); e.setNeutral ();
std::stringstream ss; std::stringstream ss;
{ {
...@@ -311,3 +310,19 @@ BOOST_AUTO_TEST_CASE (serialization) ...@@ -311,3 +310,19 @@ BOOST_AUTO_TEST_CASE (serialization)
BOOST_CHECK_EQUAL(*e.space(), *e2.space()); BOOST_CHECK_EQUAL(*e.space(), *e2.space());
BOOST_CHECK(e.vector() == e2.vector()); BOOST_CHECK(e.vector() == e2.vector());
} }
BOOST_AUTO_TEST_CASE (serialization)
{
test_serialization(LiegroupSpace::R1());
test_serialization(LiegroupSpace::R2());
test_serialization(LiegroupSpace::R3());
test_serialization(LiegroupSpace::Rn(4));
test_serialization(LiegroupSpace::SO2());
test_serialization(LiegroupSpace::SO3());
test_serialization(LiegroupSpace::SE2());
test_serialization(LiegroupSpace::SE3());
test_serialization(LiegroupSpace::R2xSO2());
test_serialization(LiegroupSpace::R3xSO3());
test_serialization(LiegroupSpace::R3() * LiegroupSpace::R3xSO3());
test_serialization(LiegroupSpace::R3() * LiegroupSpace::R3xSO3());
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment