26 #define GTSAM_MAGIC_GAUSSIAN 2 37 using namespace gtsam;
61 CHECK(!f0.equals(f1));
62 CHECK(!f1.equals(f0));
72 NonlinearFactorGraph::sharedFactor f0 = fg[0],
f1 = fg[1];
74 CHECK(f0->equals(*f0));
75 CHECK(!f0->equals(*f1));
76 CHECK(!f1->equals(*f0));
89 NonlinearFactorGraph::sharedFactor factor = fg[0];
100 double actual = factor->error(cfg);
111 NonlinearFactorGraph::sharedFactor nlf = nfg[0];
133 NonlinearFactorGraph::sharedFactor nlf = nfg[1];
149 NonlinearFactorGraph::sharedFactor nlf = nfg[2];
166 NonlinearFactorGraph::sharedFactor nlf = nfg[3];
188 NonlinearFactorGraph::sharedFactor
factor1 = fg[0],
factor2 = fg[1],
191 CHECK(factor1->size() == 1);
192 CHECK(factor2->size() == 2);
193 CHECK(factor3->size() == 2);
211 noiseModel::Constrained::MixedSigmas(
Vector2(1,0)));
229 Matrix2
A; A << 5.0, 0.0, 0.0, 1.0;
232 noiseModel::Constrained::MixedSigmas(
Vector2(1,0)));
250 actual.
push_back( boost::dynamic_pointer_cast<NoiseModelFactor>(nfg[0])->cloneWithNewNoiseModel(noise2) );
264 boost::optional<Matrix&> H1 = boost::none,
265 boost::optional<Matrix&> H2 = boost::none,
266 boost::optional<Matrix&> H3 = boost::none,
267 boost::optional<Matrix&> H4 = boost::none)
const override {
269 *H1 = (
Matrix(1, 1) << 1.0).finished();
270 *H2 = (
Matrix(1, 1) << 2.0).finished();
271 *H3 = (
Matrix(1, 1) << 3.0).finished();
272 *H4 = (
Matrix(1, 1) << 4.0).finished();
274 return (
Vector(1) << x1 + x2 + x3 + x4).finished();
286 tv.
insert(
X(1),
double((1.0)));
287 tv.
insert(
X(2),
double((2.0)));
288 tv.
insert(
X(3),
double((3.0)));
289 tv.
insert(
X(4),
double((4.0)));
312 boost::optional<Matrix&> H1 = boost::none,
313 boost::optional<Matrix&> H2 = boost::none,
314 boost::optional<Matrix&> H3 = boost::none,
315 boost::optional<Matrix&> H4 = boost::none,
316 boost::optional<Matrix&> H5 = boost::none)
const override {
318 *H1 = (
Matrix(1, 1) << 1.0).finished();
319 *H2 = (
Matrix(1, 1) << 2.0).finished();
320 *H3 = (
Matrix(1, 1) << 3.0).finished();
321 *H4 = (
Matrix(1, 1) << 4.0).finished();
322 *H5 = (
Matrix(1, 1) << 5.0).finished();
324 return (
Vector(1) << x1 + x2 + x3 + x4 + x5).finished();
332 tv.
insert(
X(1),
double((1.0)));
333 tv.
insert(
X(2),
double((2.0)));
334 tv.
insert(
X(3),
double((3.0)));
335 tv.
insert(
X(4),
double((4.0)));
336 tv.
insert(
X(5),
double((5.0)));
361 boost::optional<Matrix&> H1 = boost::none,
362 boost::optional<Matrix&> H2 = boost::none,
363 boost::optional<Matrix&> H3 = boost::none,
364 boost::optional<Matrix&> H4 = boost::none,
365 boost::optional<Matrix&> H5 = boost::none,
366 boost::optional<Matrix&> H6 = boost::none)
const override {
368 *H1 = (
Matrix(1, 1) << 1.0).finished();
369 *H2 = (
Matrix(1, 1) << 2.0).finished();
370 *H3 = (
Matrix(1, 1) << 3.0).finished();
371 *H4 = (
Matrix(1, 1) << 4.0).finished();
372 *H5 = (
Matrix(1, 1) << 5.0).finished();
373 *H6 = (
Matrix(1, 1) << 6.0).finished();
375 return (
Vector(1) << x1 + x2 + x3 + x4 + x5 + x6).finished();
384 tv.
insert(
X(1),
double((1.0)));
385 tv.
insert(
X(2),
double((2.0)));
386 tv.
insert(
X(3),
double((3.0)));
387 tv.
insert(
X(4),
double((4.0)));
388 tv.
insert(
X(5),
double((5.0)));
389 tv.
insert(
X(6),
double((6.0)));
420 EXPECT(actClone.get() != init.get());
426 EXPECT(actRekey.get() != init.get());
boost::shared_ptr< GaussianFactor > linearize(const Values &x) const override
double error(const Values &c) const override
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
Values createNoisyValues()
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
This is the base class for all measurement types.
Factor Graph consisting of non-linear factors.
GaussianFactorGraph createGaussianFactorGraph()
void insert(Key j, const Value &val)
TEST(NonlinearFactor, equals)
NoiseModelFactor5< double, double, double, double, double > Base
Vector evaluateError(const double &x1, const double &x2, const double &x3, const double &x4, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none, boost::optional< Matrix & > H4=boost::none) const override
#define DOUBLES_EQUAL(expected, actual, threshold)
static const double sigma
A factor with a quadratic error function - a Gaussian.
NonlinearFactorGraph nonlinearFactorGraphWithGivenSigma(const double sigma)
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.
JacobianFactor factor3(keyY, A32, keyZ, A33, b3, noiseModel::Isotropic::Sigma(2, sigma3))
NoiseModelFactor6< double, double, double, double, double, double > Base
boost::shared_ptr< NonlinearFactor > shared_nlf
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
NoiseModelFactor4< double, double, double, double > Base
#define EXPECT(condition)
boost::shared_ptr< This > shared_ptr
Array< double, 1, 3 > e(1./3., 0.5, 2.)
NonlinearFactorGraph createNonlinearFactorGraph(const SharedNoiseModel &noiseModel1=impl::kSigma0_1, const SharedNoiseModel &noiseModel2=impl::kSigma0_2)
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
#define LONGS_EQUAL(expected, actual)
noiseModel::Diagonal::shared_ptr SharedDiagonal
Vector evaluateError(const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none, boost::optional< Matrix & > H4=boost::none, boost::optional< Matrix & > H5=boost::none) const override
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
measurement functions and derivatives for simulated 2D robot
#define EXPECT_LONGS_EQUAL(expected, actual)
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Create small example with two poses and one landmark.
JacobianFactor factor2(keyX, A21, keyY, A22, b2, noiseModel::Isotropic::Sigma(2, sigma2))
static noiseModel::Diagonal::shared_ptr Diagonal(const Matrix &covariance)
gtsam::NonlinearFactor::shared_ptr clone() const override
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
boost::shared_ptr< GaussianFactorGraph > linearize(const Values &linearizationPoint) const
Linearize a nonlinear factor graph.
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Vector evaluateError(const X1 &x1, const X2 &x2, const X3 &x3, const X4 &x4, const X5 &x5, const X6 &x6, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none, boost::optional< Matrix & > H4=boost::none, boost::optional< Matrix & > H5=boost::none, boost::optional< Matrix & > H6=boost::none) const override
noiseModel::Base::shared_ptr SharedNoiseModel
JacobianFactor factor1(keyX, A11, b1, noiseModel::Isotropic::Sigma(2, sigma1))