testNavExpressions.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #include <gtsam/geometry/Rot3.h>
23 #include <gtsam/nonlinear/Values.h>
24 #include <gtsam/slam/expressions.h>
25 
27 
28 using namespace gtsam;
29 
30 // A NavState unknown expression wXb with key 42
32 
33 /* ************************************************************************* */
34 // Example: absolute position measurement
35 TEST(Expressions, Position) {
36  auto absolutePosition_ = position(wXb_);
37 
38  // Test with some values
39  Values values;
40  values.insert(42, NavState(Rot3(), Point3(1, 2, 3), Velocity3(4, 5, 6)));
41  EXPECT(assert_equal(Point3(1, 2, 3), absolutePosition_.value(values)));
42 }
43 
44 /* ************************************************************************* */
45 // Example: velocity measurement in body frame
46 TEST(Expressions, Velocity) {
47  // We want to predict h(wXb) = velocity in body frame
48  // h(wXb) = bRw(wXb) * wV(wXb)
49  auto bodyVelocity_ = unrotate(attitude(wXb_), velocity(wXb_));
50 
51  // Test with some values
52  Values values;
53  values.insert(42, NavState(Rot3(), Point3(1, 2, 3), Velocity3(4, 5, 6)));
54  EXPECT(assert_equal(Velocity3(4, 5, 6), bodyVelocity_.value(values)));
55 }
56 
57 /* ************************************************************************* */
58 int main() {
59  TestResult tr;
60  return TestRegistry::runAllTests(tr);
61 }
62 /* ************************************************************************* */
Point3_ unrotate(const Rot3_ &x, const Point3_ &p)
int main()
static int runAllTests(TestResult &result)
A non-templated config holding any types of Manifold-group elements.
void insert(Key j, const Value &val)
Definition: Values.cpp:140
Vector3 Velocity3
Velocity is currently typedef&#39;d to Vector3.
Definition: NavState.h:28
leaf::MyValues values
Expression< NavState > wXb_(42)
#define EXPECT(condition)
Definition: Test.h:151
Velocity3_ velocity(const NavState_ &X)
traits
Definition: chartTesting.h:28
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:42
Rot3_ attitude(const NavState_ &X)
Point3_ position(const NavState_ &X)
TEST(LPInitSolver, InfiniteLoopSingleVar)
Vector3 Point3
Definition: Point3.h:35
3D rotation represented as a rotation matrix or quaternion


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:48:08