MROB
factor2Poses2d.hpp
1 /* Copyright (c) 2022, Gonzalo Ferrer
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  *
16  * Created on: Jan 14, 2019
17  * Author: Gonzalo Ferrer
18  * g.ferrer@skoltech.ru
19  * konstantin.pakulev@skoltech.ru
20  * Konstantin Pakulev
21  * Mobile Robotics Lab, Skoltech
22  */
23 #ifndef MROB_FACTOR2POSES2D_H
24 #define MROB_FACTOR2POSES2D_H
25 
26 #include "mrob/matrix_base.hpp"
27 #include "mrob/factor.hpp"
28 
29 
30 namespace mrob{
31 
52  class Factor2Poses2d : public Factor
53  {
54  public:
55  Factor2Poses2d(const Mat31 &observation, std::shared_ptr<Node> &nodeOrigin,
56  std::shared_ptr<Node> &nodeTarget, const Mat3 &obsInf, bool updateNodeTarget=false,
57  Factor::robustFactorType robust_type = Factor::robustFactorType::QUADRATIC);
58  ~Factor2Poses2d() override = default;
59 
60  void evaluate_residuals() override;
61  void evaluate_jacobians() override;
62  void evaluate_chi2() override;
63 
64  MatRefConst get_obs() const override {return obs_;};
65  VectRefConst get_residual() const override {return r_;};
66  MatRefConst get_information_matrix() const override {return W_;};
67  MatRefConst get_jacobian([[maybe_unused]]mrob::factor_id_t id = 0) const override {return J_;};
68  void print() const override;
69 
70  protected:
71  // The Jacobian's correspondent nodes are ordered on the vector<Node>
72  // being [0]->J1 and [1]->J2
73  // declared here but initialized on child classes
74  Mat31 obs_, r_; //and residuals
75  Mat3 W_;//inverse of observation covariance (information matrix)
76  Mat<3,6> J_;//Joint Jacobian
77 
78  public:
79  EIGEN_MAKE_ALIGNED_OPERATOR_NEW // as proposed by Eigen
80  };
81 
94  {
95  public:
101  Factor2Poses2dOdom(const Mat31 &observation, std::shared_ptr<Node> &nodeOrigin,
102  std::shared_ptr<Node> &nodeTarget, const Mat3 &obsInf, bool updateNodeTarget=true,
103  Factor::robustFactorType robust_type = Factor::robustFactorType::QUADRATIC);
104  ~Factor2Poses2dOdom() override = default;
105 
106  void evaluate_residuals() override;
107  void evaluate_jacobians() override;
108 
109  private:
110  Mat31 get_odometry_prediction(Mat31 state, Mat31 motion);
111 
112  };
113 
114 }
115 
116 #endif //MROB_FACTOR2POSES2D_H
robustFactorType
Definition: factor.hpp:87
VectRefConst get_residual() const override
Definition: factor2Poses2d.hpp:65
void evaluate_chi2() override
Definition: factor2Poses2d.cpp:92
void print() const override
Definition: factor2Poses2d.cpp:97
void evaluate_jacobians() override
Definition: factor2Poses2d.cpp:75
Definition: factor2Poses2d.hpp:52
MatRefConst get_obs() const override
Definition: factor2Poses2d.hpp:64
Special Euclidean (group) in 3d Is the group representing rotations and translations, that is, rigid body transformations. SE3 = {T = [R t] | R SO3 , t Re^3 } [0 1] Associated to the groups of RBT, there is the Lie algebra se3 representing the same transformation in the tangent space around the identity. Particularly, xi =[w , v] Re^6, where w Re^3 represents the rotation and v the translation. We will preserve this order in this class.
Definition: matrix_base.hpp:36
Definition: factor2Poses2d.hpp:93
Definition: factor.hpp:81
void evaluate_residuals() override
Definition: factor2Poses2d.cpp:58