25 #include <boost/assign/list_of.hpp> 32 using namespace gtsam;
60 TEST (Serialization, noiseModels) {
62 EXPECT(equalsDereferenced<noiseModel::Diagonal::shared_ptr>(
diag3));
63 EXPECT(equalsDereferencedXML<noiseModel::Diagonal::shared_ptr>(
diag3));
64 EXPECT(equalsDereferencedBinary<noiseModel::Diagonal::shared_ptr>(
diag3));
66 EXPECT(equalsDereferenced<noiseModel::Gaussian::shared_ptr>(gaussian3));
67 EXPECT(equalsDereferencedXML<noiseModel::Gaussian::shared_ptr>(gaussian3));
68 EXPECT(equalsDereferencedBinary<noiseModel::Gaussian::shared_ptr>(gaussian3));
70 EXPECT(equalsDereferenced<noiseModel::Isotropic::shared_ptr>(iso3));
71 EXPECT(equalsDereferencedXML<noiseModel::Isotropic::shared_ptr>(iso3));
72 EXPECT(equalsDereferencedBinary<noiseModel::Isotropic::shared_ptr>(iso3));
74 EXPECT(equalsDereferenced<noiseModel::Unit::shared_ptr>(unit3));
75 EXPECT(equalsDereferencedXML<noiseModel::Unit::shared_ptr>(unit3));
76 EXPECT(equalsDereferencedBinary<noiseModel::Unit::shared_ptr>(unit3));
78 EXPECT(equalsDereferencedBinary<noiseModel::Constrained::shared_ptr>(constrained3));
79 EXPECT(equalsDereferenced<noiseModel::Constrained::shared_ptr>(constrained3));
80 EXPECT(equalsDereferencedXML<noiseModel::Constrained::shared_ptr>(constrained3));
84 TEST (Serialization, SharedNoiseModel_noiseModels) {
86 EXPECT(equalsDereferenced<SharedNoiseModel>(diag3_sg));
87 EXPECT(equalsDereferencedXML<SharedNoiseModel>(diag3_sg));
88 EXPECT(equalsDereferencedBinary<SharedNoiseModel>(diag3_sg));
90 EXPECT(equalsDereferenced<SharedNoiseModel>(
diag3));
91 EXPECT(equalsDereferencedXML<SharedNoiseModel>(
diag3));
92 EXPECT(equalsDereferencedBinary<SharedNoiseModel>(
diag3));
94 EXPECT(equalsDereferenced<SharedNoiseModel>(iso3));
95 EXPECT(equalsDereferencedXML<SharedNoiseModel>(iso3));
96 EXPECT(equalsDereferencedBinary<SharedNoiseModel>(iso3));
98 EXPECT(equalsDereferenced<SharedNoiseModel>(gaussian3));
99 EXPECT(equalsDereferencedXML<SharedNoiseModel>(gaussian3));
100 EXPECT(equalsDereferencedBinary<SharedNoiseModel>(gaussian3));
102 EXPECT(equalsDereferenced<SharedNoiseModel>(unit3));
103 EXPECT(equalsDereferencedXML<SharedNoiseModel>(unit3));
104 EXPECT(equalsDereferencedBinary<SharedNoiseModel>(unit3));
106 EXPECT(equalsDereferencedBinary<SharedNoiseModel>(constrained3));
107 EXPECT(equalsDereferenced<SharedNoiseModel>(constrained3));
108 EXPECT(equalsDereferencedXML<SharedNoiseModel>(constrained3));
112 TEST (Serialization, SharedDiagonal_noiseModels) {
114 EXPECT(equalsDereferencedXML<SharedDiagonal>(
diag3));
115 EXPECT(equalsDereferencedBinary<SharedDiagonal>(
diag3));
117 EXPECT(equalsDereferenced<SharedDiagonal>(iso3));
118 EXPECT(equalsDereferencedXML<SharedDiagonal>(iso3));
119 EXPECT(equalsDereferencedBinary<SharedDiagonal>(iso3));
121 EXPECT(equalsDereferenced<SharedDiagonal>(unit3));
122 EXPECT(equalsDereferencedXML<SharedDiagonal>(unit3));
123 EXPECT(equalsDereferencedBinary<SharedDiagonal>(unit3));
125 EXPECT(equalsDereferencedBinary<SharedDiagonal>(constrained3));
126 EXPECT(equalsDereferenced<SharedDiagonal>(constrained3));
127 EXPECT(equalsDereferencedXML<SharedDiagonal>(constrained3));
137 TEST (Serialization, linear_factors) {
142 EXPECT(equalsObj<VectorValues>(values));
143 EXPECT(equalsXML<VectorValues>(values));
144 EXPECT(equalsBinary<VectorValues>(values));
147 Matrix A1 = I_3x3, A2 = -1.0 * I_3x3;
162 TEST (Serialization, gaussian_conditional) {
163 Matrix A1 = (
Matrix(2, 2) << 1., 2., 3., 4.).finished();
164 Matrix A2 = (
Matrix(2, 2) << 6., 0.2, 8., 0.4).finished();
175 TEST (Serialization, gaussian_factor_graph) {
178 Matrix A1 = (
Matrix(2, 2) << 1., 2., 3., 4.).finished();
179 Matrix A2 = (
Matrix(2, 2) << 6., 0.2, 8., 0.4).finished();
188 Matrix A1 = I_3x3, A2 = -1.0 * I_3x3;
202 TEST (Serialization, gaussian_bayes_tree) {
205 const SharedDiagonal chainNoise = noiseModel::Isotropic::Sigma(1, 0.5);
216 std::string serialized =
serialize(init);
boost::shared_ptr< Unit > shared_ptr
static noiseModel::Unit::shared_ptr unit3
static noiseModel::Diagonal::shared_ptr diag3
void serialize(Archive &ar, Eigen::Matrix< Scalar_, Rows_, Cols_, Ops_, MaxRows_, MaxCols_ > &m, const unsigned int version)
static int runAllTests(TestResult &result)
noiseModel::Diagonal::shared_ptr model
boost::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
bool equalsObj(const T &input=T())
static noiseModel::Isotropic::shared_ptr iso3
Rot2 R(Rot2::fromAngle(0.1))
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
IsDerived< DERIVEDFACTOR > push_back(boost::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
NonlinearFactorGraph graph
bool equalsXML(const T &input=T())
bool equalsBinary(const T &input=T())
#define EXPECT(condition)
Contains the HessianFactor class, a general quadratic factor.
boost::shared_ptr< Diagonal > shared_ptr
boost::shared_ptr< Constrained > shared_ptr
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
noiseModel::Diagonal::shared_ptr SharedDiagonal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
void deserialize(const std::string &serialized, T &output)
deserializes from a string
BOOST_CLASS_EXPORT_GUID(gtsam::noiseModel::Constrained,"gtsam_noiseModel_Constrained")
A Gaussian factor using the canonical parameters (information form)
static noiseModel::Gaussian::shared_ptr gaussian3
boost::shared_ptr< Isotropic > shared_ptr
boost::shared_ptr< Gaussian > shared_ptr
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
iterator insert(const std::pair< Key, Vector > &key_value)
TEST(Serialization, noiseModels)
std::uint64_t Key
Integer nonlinear key type.
static noiseModel::Constrained::shared_ptr constrained3
noiseModel::Base::shared_ptr SharedNoiseModel