testSlamExpressions.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 
18 #include <gtsam/slam/expressions.h>
21 
23 
24 #include <iostream>
25 
26 using namespace std;
27 using namespace gtsam;
28 
29 /* ************************************************************************* */
30 TEST(SlamExpressions, project2) {
31  typedef Expression<CalibratedCamera> CalibratedCamera_;
32 
33  Rot3_ rot3_expr('r', 0); // unknown rotation !
34  Point3_ t_expr(Point3(1, 2, 3)); // known translation
35  Pose3_ pose_expr(&Pose3::Create, rot3_expr, t_expr);
36  CalibratedCamera_ camera_expr(&CalibratedCamera::Create, pose_expr);
37  Point3_ point3_expr('p', 12); // unknown 3D point with index 12, for funsies
38  Point2_ point2_expr = project2<CalibratedCamera>(camera_expr, point3_expr);
39 
40  // Set the linearization point
41  Values values;
42  values.insert(Symbol('r', 0), Rot3());
43  values.insert(Symbol('p', 12), Point3(4, 5, 6));
44 
45  EXPECT_CORRECT_EXPRESSION_JACOBIANS(point2_expr, values, 1e-7, 1e-5);
46 }
47 
48 /* ************************************************************************* */
49 TEST(SlamExpressions, rotation) {
50  Pose3_ T_(0);
51  const Rot3_ R_ = rotation(T_);
52 }
53 
54 /* ************************************************************************* */
55 TEST(SlamExpressions, unrotate) {
56  Rot3_ R_(0);
57  Point3_ p_(1);
58  const Point3_ q_ = unrotate(R_, p_);
59 }
60 
61 /* ************************************************************************* */
62 int main() {
63  TestResult tr;
64  return TestRegistry::runAllTests(tr);
65 }
66 /* ************************************************************************* */
static Point2 project2(const CalibratedCamera &camera, const Point3 &point)
static int runAllTests(TestResult &result)
void insert(Key j, const Value &val)
Definition: Values.cpp:140
leaf::MyValues values
Definition: Half.h:150
int main()
#define EXPECT_CORRECT_EXPRESSION_JACOBIANS(expression, values, numerical_derivative_step, tolerance)
Check the Jacobians produced by an expression against finite differences.
P unrotate(const T &r, const P &pt)
Definition: lieProxies.h:50
Test harness methods for expressions.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Calibrated camera for which only pose is unknown.
traits
Definition: chartTesting.h:28
Vector3 Point3
Definition: Point3.h:35
Rot3 rotation(const Pose3 &pose, OptionalJacobian< 3, 6 > H)
TEST(SlamExpressions, project2)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:49:32