GPSPose2XYFactor.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <gtsam/nonlinear/NonlinearFactor.h>
16 #include <gtsam/base/Matrix.h>
17 #include <gtsam/base/Vector.h>
18 #include <gtsam/geometry/Pose2.h>
19 
20 
21 namespace rtabmap {
22 
23 class GPSPose2XYFactor: public gtsam::NoiseModelFactor1<gtsam::Pose2> {
24 
25 private:
26  // measurement information
27  double mx_, my_;
28 
29 public:
30 
37  GPSPose2XYFactor(gtsam::Key poseKey, const gtsam::Point2 m, gtsam::SharedNoiseModel model) :
38  gtsam::NoiseModelFactor1<gtsam::Pose2>(model, poseKey), mx_(m.x()), my_(m.y()) {}
39 
40  // error function
41  // @param p the pose in Pose2
42  // @param H the optional Jacobian matrix, which use boost optional and has default null pointer
43  gtsam::Vector evaluateError(const gtsam::Pose2& p, boost::optional<gtsam::Matrix&> H = boost::none) const {
44 
45  // note that use boost optional like a pointer
46  // only calculate jacobian matrix when non-null pointer exists
47  if (H) *H = (gtsam::Matrix23() << 1.0, 0.0, 0.0,
48  0.0, 1.0, 0.0).finished();
49 
50  // return error vector
51  return (gtsam::Vector2() << p.x() - mx_, p.y() - my_).finished();
52  }
53 
54 };
55 
56 } // namespace gtsamexamples
57 
GPSPose2XYFactor(gtsam::Key poseKey, const gtsam::Point2 m, gtsam::SharedNoiseModel model)
gtsam::Vector evaluateError(const gtsam::Pose2 &p, boost::optional< gtsam::Matrix & > H=boost::none) const


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:58