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

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

parent 1325ddfb
......@@ -24,37 +24,21 @@
namespace boost {
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>
inline void save(Archive & ar,
const hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>& lg,
inline void serialize(Archive & ar,
hpp::pinocchio::liegroup::VectorSpaceOperation<Size,rot>& lg,
const unsigned int version)
{
(void) version;
if (Size == Eigen::Dynamic) {
int size = static_cast<int>(lg.nq());
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>
......
......@@ -58,7 +58,7 @@ namespace hpp {
/// Constructor
/// \param size size of the vector space: should be the equal to
/// 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_)
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 (R6xSO3); e.setNeutral ();
LiegroupElement e (space); e.setNeutral ();
std::stringstream ss;
{
......@@ -311,3 +310,19 @@ BOOST_AUTO_TEST_CASE (serialization)
BOOST_CHECK_EQUAL(*e.space(), *e2.space());
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());
}
Markdown is supported
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