-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Header discipline in base #1108
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e4cbd9c
Move Vector serialization to separate file
dellaert a97eae6
Move Matrix serialization to separate file and remove spurious headers
dellaert c78af4d
Add headers in the place they are needed
dellaert d6ebc21
Base wrapper needs Matrix serialization
dellaert c4ebc71
Add missing header
dellaert ba8da3c
Added missing header in header
dellaert 5905110
Remove duplicate header
dellaert b65c89c
Use at least 2 cores
dellaert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* ---------------------------------------------------------------------------- | ||
|
||
* GTSAM Copyright 2010, Georgia Tech Research Corporation, | ||
* Atlanta, Georgia 30332-0415 | ||
* All Rights Reserved | ||
* Authors: Frank Dellaert, et al. (see THANKS for the full author list) | ||
|
||
* See LICENSE for the license information | ||
|
||
* -------------------------------------------------------------------------- */ | ||
|
||
/** | ||
* @file MatrixSerialization.h | ||
* @brief Serialization for matrices | ||
* @author Frank Dellaert | ||
* @date February 2022 | ||
*/ | ||
|
||
// \callgraph | ||
|
||
#pragma once | ||
|
||
#include <gtsam/base/Matrix.h> | ||
|
||
#include <boost/serialization/array.hpp> | ||
#include <boost/serialization/nvp.hpp> | ||
#include <boost/serialization/split_free.hpp> | ||
|
||
namespace boost { | ||
namespace serialization { | ||
|
||
/** | ||
* Ref. | ||
* https://stackoverflow.com/questions/18382457/eigen-and-boostserialize/22903063#22903063 | ||
* | ||
* Eigen supports calling resize() on both static and dynamic matrices. | ||
* This allows for a uniform API, with resize having no effect if the static | ||
* matrix is already the correct size. | ||
* https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html#TutorialMatrixSizesResizing | ||
* | ||
* We use all the Matrix template parameters to ensure wide compatibility. | ||
* | ||
* eigen_typekit in ROS uses the same code | ||
* http://docs.ros.org/lunar/api/eigen_typekit/html/eigen__mqueue_8cpp_source.html | ||
*/ | ||
|
||
// split version - sends sizes ahead | ||
template <class Archive, typename Scalar_, int Rows_, int Cols_, int Ops_, | ||
int MaxRows_, int MaxCols_> | ||
void save( | ||
Archive& ar, | ||
const Eigen::Matrix<Scalar_, Rows_, Cols_, Ops_, MaxRows_, MaxCols_>& m, | ||
const unsigned int /*version*/) { | ||
const size_t rows = m.rows(), cols = m.cols(); | ||
ar << BOOST_SERIALIZATION_NVP(rows); | ||
ar << BOOST_SERIALIZATION_NVP(cols); | ||
ar << make_nvp("data", make_array(m.data(), m.size())); | ||
} | ||
|
||
template <class Archive, typename Scalar_, int Rows_, int Cols_, int Ops_, | ||
int MaxRows_, int MaxCols_> | ||
void load(Archive& ar, | ||
Eigen::Matrix<Scalar_, Rows_, Cols_, Ops_, MaxRows_, MaxCols_>& m, | ||
const unsigned int /*version*/) { | ||
size_t rows, cols; | ||
ar >> BOOST_SERIALIZATION_NVP(rows); | ||
ar >> BOOST_SERIALIZATION_NVP(cols); | ||
m.resize(rows, cols); | ||
ar >> make_nvp("data", make_array(m.data(), m.size())); | ||
} | ||
|
||
// templated version of BOOST_SERIALIZATION_SPLIT_FREE(Eigen::Matrix); | ||
template <class Archive, typename Scalar_, int Rows_, int Cols_, int Ops_, | ||
int MaxRows_, int MaxCols_> | ||
void serialize( | ||
Archive& ar, | ||
Eigen::Matrix<Scalar_, Rows_, Cols_, Ops_, MaxRows_, MaxCols_>& m, | ||
const unsigned int version) { | ||
split_free(ar, m, version); | ||
} | ||
|
||
// specialized to Matrix for MATLAB wrapper | ||
template <class Archive> | ||
void serialize(Archive& ar, gtsam::Matrix& m, const unsigned int version) { | ||
split_free(ar, m, version); | ||
} | ||
|
||
} // namespace serialization | ||
} // namespace boost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* ---------------------------------------------------------------------------- | ||
|
||
* GTSAM Copyright 2010, Georgia Tech Research Corporation, | ||
* Atlanta, Georgia 30332-0415 | ||
* All Rights Reserved | ||
* Authors: Frank Dellaert, et al. (see THANKS for the full author list) | ||
|
||
* See LICENSE for the license information | ||
|
||
* -------------------------------------------------------------------------- */ | ||
|
||
/** | ||
* @file VectorSerialization.h | ||
* @brief serialization for Vectors | ||
* @author Frank Dellaert | ||
* @date February 2022 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <gtsam/base/Vector.h> | ||
|
||
#include <boost/serialization/array.hpp> | ||
#include <boost/serialization/nvp.hpp> | ||
#include <boost/serialization/split_free.hpp> | ||
|
||
namespace boost { | ||
namespace serialization { | ||
|
||
// split version - copies into an STL vector for serialization | ||
template <class Archive> | ||
void save(Archive& ar, const gtsam::Vector& v, unsigned int /*version*/) { | ||
const size_t size = v.size(); | ||
ar << BOOST_SERIALIZATION_NVP(size); | ||
ar << make_nvp("data", make_array(v.data(), v.size())); | ||
} | ||
|
||
template <class Archive> | ||
void load(Archive& ar, gtsam::Vector& v, unsigned int /*version*/) { | ||
size_t size; | ||
ar >> BOOST_SERIALIZATION_NVP(size); | ||
v.resize(size); | ||
ar >> make_nvp("data", make_array(v.data(), v.size())); | ||
} | ||
|
||
// split version - copies into an STL vector for serialization | ||
template <class Archive, int D> | ||
void save(Archive& ar, const Eigen::Matrix<double, D, 1>& v, | ||
unsigned int /*version*/) { | ||
ar << make_nvp("data", make_array(v.data(), v.RowsAtCompileTime)); | ||
} | ||
|
||
template <class Archive, int D> | ||
void load(Archive& ar, Eigen::Matrix<double, D, 1>& v, | ||
unsigned int /*version*/) { | ||
ar >> make_nvp("data", make_array(v.data(), v.RowsAtCompileTime)); | ||
} | ||
|
||
} // namespace serialization | ||
} // namespace boost | ||
|
||
BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector) | ||
BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector2) | ||
BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector3) | ||
BOOST_SERIALIZATION_SPLIT_FREE(gtsam::Vector6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you reviewed everything and you trust me to fix the above, approve??