testDummyFactor.cpp
Go to the documentation of this file.
1 
12 
14 
15 #include <gtsam/geometry/Point3.h>
17 
18 using namespace gtsam;
19 
20 const double tol = 1e-9;
21 
22 /* ************************************************************************* */
23 TEST( testDummyFactor, basics ) {
24 
25  gtsam::Key key1 = 7, key2 = 9;
26  size_t dim1 = 3, dim2 = 3;
27  DummyFactor dummyfactor(key1, dim1, key2, dim2);
28 
29  // verify contents
30  LONGS_EQUAL(2, dummyfactor.size());
31  EXPECT_LONGS_EQUAL(key1, dummyfactor.keys()[0]);
32  EXPECT_LONGS_EQUAL(key2, dummyfactor.keys()[1]);
33 
34  LONGS_EQUAL(2, dummyfactor.dims().size());
35  EXPECT_LONGS_EQUAL(dim1, dummyfactor.dims()[0]);
36  EXPECT_LONGS_EQUAL(dim2, dummyfactor.dims()[1]);
37 
38  Values c;
39  c.insert(key1, Point3(1.0, 2.0, 3.0));
40  c.insert(key2, Point3(4.0, 5.0, 6.0));
41 
42  // errors - all zeros
43  DOUBLES_EQUAL(0.0, dummyfactor.error(c), tol);
44 
45  // linearization: all zeros
46  GaussianFactor::shared_ptr actLinearization = dummyfactor.linearize(c);
47  CHECK(actLinearization);
49  GaussianFactor::shared_ptr expLinearization(new JacobianFactor(
50  key1, Matrix::Zero(3,3), key2, Matrix::Zero(3,3), Z_3x1, model3));
51  EXPECT(assert_equal(*expLinearization, *actLinearization, tol));
52 }
53 
54 /* ************************************************************************* */
55 int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
56 /* ************************************************************************* */
key1
const Symbol key1('v', 1)
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
main
int main()
Definition: testDummyFactor.cpp:55
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EXPECT_LONGS_EQUAL
#define EXPECT_LONGS_EQUAL(expected, actual)
Definition: Test.h:154
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
gtsam::Z_3x1
static const Eigen::MatrixBase< Vector3 >::ConstantReturnType Z_3x1
Definition: Vector.h:47
TestHarness.h
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
gtsam::JacobianFactor
Definition: JacobianFactor.h:91
Point3.h
3D Point
gtsam::DummyFactor
Definition: gtsam_unstable/slam/DummyFactor.h:17
TestableAssertions.h
Provides additional testing facilities for common data structures.
DummyFactor.h
A simple factor that can be used to trick gtsam solvers into believing a graph is connected.
key2
const Symbol key2('v', 2)
DOUBLES_EQUAL
#define DOUBLES_EQUAL(expected, actual, threshold)
Definition: Test.h:141
gtsam::GaussianFactor::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42
gtsam::noiseModel::Unit::Create
static shared_ptr Create(size_t dim)
Definition: NoiseModel.h:631
TestResult
Definition: TestResult.h:26
gtsam
traits
Definition: SFMdata.h:40
gtsam::TEST
TEST(SmartFactorBase, Pinhole)
Definition: testSmartFactorBase.cpp:38
gtsam::Values
Definition: Values.h:65
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:143
CHECK
#define CHECK(condition)
Definition: Test.h:108
gtsam::noiseModel::Diagonal::shared_ptr
std::shared_ptr< Diagonal > shared_ptr
Definition: NoiseModel.h:321
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:41
gtsam::DummyFactor::dims
const std::vector< size_t > & dims() const
Definition: gtsam_unstable/slam/DummyFactor.h:44
gtsam::DummyFactor::linearize
std::shared_ptr< GaussianFactor > linearize(const Values &c) const override
Definition: DummyFactor.cpp:39
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
model3
const SharedNoiseModel model3
Definition: testPoseRotationPrior.cpp:22
gtsam::Factor::size
size_t size() const
Definition: Factor.h:160
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::DummyFactor::error
double error(const Values &c) const override
Definition: gtsam_unstable/slam/DummyFactor.h:51
LONGS_EQUAL
#define LONGS_EQUAL(expected, actual)
Definition: Test.h:134


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:16:14