| Directory: | ./ |
|---|---|
| File: | include/hpp/pinocchio/liegroup/serialization.hh |
| Date: | 2025-05-04 12:09:19 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 9 | 9 | 100.0% |
| Branches: | 5 | 10 | 50.0% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright (c) 2020, Joseph Mirabel | ||
| 2 | // Authors: Joseph Mirabel (joseph.mirabel@laas.fr) | ||
| 3 | // | ||
| 4 | |||
| 5 | // Redistribution and use in source and binary forms, with or without | ||
| 6 | // modification, are permitted provided that the following conditions are | ||
| 7 | // met: | ||
| 8 | // | ||
| 9 | // 1. Redistributions of source code must retain the above copyright | ||
| 10 | // notice, this list of conditions and the following disclaimer. | ||
| 11 | // | ||
| 12 | // 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | // notice, this list of conditions and the following disclaimer in the | ||
| 14 | // documentation and/or other materials provided with the distribution. | ||
| 15 | // | ||
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 20 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
| 27 | // DAMAGE. | ||
| 28 | |||
| 29 | #ifndef HPP_PINOCCHIO_LIEGROUP_SERIALIZATION_HH | ||
| 30 | #define HPP_PINOCCHIO_LIEGROUP_SERIALIZATION_HH | ||
| 31 | |||
| 32 | #include <boost/serialization/serialization.hpp> | ||
| 33 | #include <boost/serialization/split_free.hpp> | ||
| 34 | #include <hpp/pinocchio/liegroup.hh> | ||
| 35 | |||
| 36 | namespace boost { | ||
| 37 | namespace serialization { | ||
| 38 | |||
| 39 | template <class Archive, int Size, bool rot> | ||
| 40 | 40 | inline void serialize( | |
| 41 | Archive& ar, hpp::pinocchio::liegroup::VectorSpaceOperation<Size, rot>& lg, | ||
| 42 | const unsigned int version) { | ||
| 43 | (void)version; | ||
| 44 | if (Size == Eigen::Dynamic) { | ||
| 45 | 4 | int size = static_cast<int>(lg.nq()); | |
| 46 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | ar& make_nvp("size", size); |
| 47 | if (!Archive::is_saving::value) { | ||
| 48 | // TODO VectorSpaceOperation should provide a resize operation. | ||
| 49 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | lg = hpp::pinocchio::liegroup::VectorSpaceOperation<Size, rot>(size); |
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | template <class Archive, typename LieGroup1, typename LieGroup2> | ||
| 55 | 16 | inline void serialize( | |
| 56 | Archive& ar, | ||
| 57 | hpp::pinocchio::liegroup::CartesianProductOperation<LieGroup1, LieGroup2>& | ||
| 58 | lg, | ||
| 59 | const unsigned int version) { | ||
| 60 | (void)version; | ||
| 61 | #if PINOCCHIO_VERSION_AT_LEAST(2, 4, 5) | ||
| 62 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
16 | ar& make_nvp("lg1", lg.lg1); |
| 63 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
16 | ar& make_nvp("lg2", lg.lg2); |
| 64 | #else | ||
| 65 | (void)ar; | ||
| 66 | (void)lg; | ||
| 67 | throw std::logic_error( | ||
| 68 | "Pinocchio version is too low for serializing " | ||
| 69 | "hpp::pinocchio::liegroup::CartesianProductOperation"); | ||
| 70 | #endif | ||
| 71 | } | ||
| 72 | |||
| 73 | template <class Archive, int N> | ||
| 74 | 24 | inline void serialize( | |
| 75 | Archive& ar, hpp::pinocchio::liegroup::SpecialOrthogonalOperation<N>& lg, | ||
| 76 | const unsigned int version) { | ||
| 77 | (void)ar; | ||
| 78 | (void)lg; | ||
| 79 | (void)version; | ||
| 80 | } | ||
| 81 | |||
| 82 | template <class Archive, int N> | ||
| 83 | 8 | inline void serialize( | |
| 84 | Archive& ar, hpp::pinocchio::liegroup::SpecialEuclideanOperation<N>& lg, | ||
| 85 | const unsigned int version) { | ||
| 86 | (void)ar; | ||
| 87 | (void)lg; | ||
| 88 | (void)version; | ||
| 89 | } | ||
| 90 | } // namespace serialization | ||
| 91 | } // namespace boost | ||
| 92 | |||
| 93 | #endif // HPP_PINOCCHIO_LIEGROUP_SERIALIZATION_HH | ||
| 94 |