timeAdaptAutoDiff.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 "timeLinearize.h"
26 #include <gtsam/geometry/Point3.h>
27 
28 using namespace std;
29 using namespace gtsam;
30 
31 #define time timeMultiThreaded
32 
33 int main() {
34 
35  // The DefaultChart of Camera below is laid out like Snavely's 9-dim vector
38  typedef Expression<Camera> Camera_;
40 
41  // Create leaves
42  Camera_ camera(1);
43  Point3_ point(2);
44 
45  // Some parameters needed
46  Point2 z(-17, 30);
47  SharedNoiseModel model = noiseModel::Unit::Create(2);
48 
49  // Create values
50  Values values;
51  values.insert(1, Camera());
52  values.insert(2, Point3(0, 0, 1));
53 
55 
56  // Dedicated factor
57  f1 = std::make_shared<GeneralSFMFactor<Camera, Point3> >(z, model, 1, 2);
58  time("GeneralSFMFactor<Camera> : ", f1, values);
59 
60  // ExpressionFactor
61  Point2_ expression2(camera, &Camera::project2, point);
62  f3 = std::make_shared<ExpressionFactor<Point2> >(model, z, expression2);
63  time("Point2_(camera, &Camera::project, point): ", f3, values);
64 
65  // AdaptAutoDiff
66  values.clear();
67  values.insert(1,Vector9(Vector9::Zero()));
68  values.insert(2,Vector3(0,0,1));
69  typedef AdaptAutoDiff<SnavelyProjection, 2, 9, 3> AdaptedSnavely;
70  Expression<Vector2> expression(AdaptedSnavely(), Expression<Vector9>(1), Expression<Vector3>(2));
71  f2 = std::make_shared<ExpressionFactor<Vector2> >(model, z, expression);
72  time("Point2_(AdaptedSnavely(), camera, point): ", f2, values);
73 
74  return 0;
75 }
gtsam::NonlinearFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: NonlinearFactor.h:78
Point3_
Expression< Point3 > Point3_
Definition: testExpression.cpp:31
test_constructor::f1
auto f1
Definition: testHybridNonlinearFactor.cpp:56
project2
static Point2 project2(const CalibratedCamera &camera, const Point3 &point)
Definition: testCalibratedCamera.cpp:127
gtsam::Point2_
Expression< Point2 > Point2_
Definition: slam/expressions.h:22
f2
double f2(const Vector2 &x)
Definition: testNumericalDerivative.cpp:56
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
GeneralSFMFactor.h
a general SFM factor with an unknown calibration
Point3.h
3D Point
main
int main()
Definition: timeAdaptAutoDiff.cpp:33
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:43
gtsam::Expression
Definition: Expression.h:47
gtsam_unstable.tests.test_ProjectionFactorRollingShutter.point
point
Definition: test_ProjectionFactorRollingShutter.py:25
gtsam::AdaptAutoDiff
Definition: AdaptAutoDiff.h:35
gtsam::PinholeCamera< Cal3Bundler >
PinholeCamera.h
Base class for all pinhole cameras.
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
gtsam::HybridValues::insert
void insert(Key j, const Vector &value)
Definition: HybridValues.cpp:85
gtsam::Point2
Vector2 Point2
Definition: Point2.h:32
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
time
#define time
Definition: timeAdaptAutoDiff.cpp:31
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
gtsam
traits
Definition: SFMdata.h:40
timeLinearize.h
time linearize
f3
double f3(double x1, double x2)
Definition: testNumericalDerivative.cpp:76
gtsam::Values
Definition: Values.h:65
std
Definition: BFloat16.h:88
AdaptAutoDiff.h
Adaptor for Ceres style auto-differentiated functions.
Camera
PinholePose< Cal3_S2 > Camera
Definition: SFMExample_SmartFactor.cpp:38
example.h
ExpressionFactor.h
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
camera
static const CalibratedCamera camera(kDefaultPose)
Cal3Bundler.h
Calibration used by Bundler.


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:08:57