MROB
factorCameraProj3dPoint.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  * factorCameraProj3dPoint.hpp
17  *
18  * Created on: March 13, 2023
19  * Author: Gonzalo Ferrer
20  * g.ferrer@skoltech.ru
21  * Mobile Robotics Lab, Skoltech
22  */
23 
24 #ifndef FACTORCAMERAPROJ3DPOINT_HPP_
25 #define FACTORCAMERAPROJ3DPOINT_HPP_
26 
27 
28 #include "mrob/matrix_base.hpp"
29 #include "mrob/SE3.hpp" //requires including and linking SE3 library
30 #include "mrob/factor.hpp"
31 
32 namespace mrob{
33 
63 {
64  public:
65  FactorCameraProj3dPoint(const Mat21 &observation, std::shared_ptr<Node> &nodePose,
66  std::shared_ptr<Node> &nodeLandmark,
67  const Mat41 &camera_k,
68  const Mat2 &obsInf = Mat2::Identity(),
69  Factor::robustFactorType robust_type = Factor::robustFactorType::QUADRATIC);
70  ~FactorCameraProj3dPoint() override = default;
74  void evaluate_residuals() override;
78  void evaluate_jacobians() override;
79  void evaluate_chi2() override;
80 
81  void print() const;
82 
83  MatRefConst get_obs() const {return obs_;};
84  VectRefConst get_residual() const {return r_;};
85  MatRefConst get_information_matrix() const {return W_;};
86  MatRefConst get_jacobian([[maybe_unused]] mrob::factor_id_t id = 0) const {return J_;};
87 
88  protected:
89  Mat21 obs_, r_; // Assumes this observations has been undistorted
90  Mat31 landmark_, local_point_;
91  Mat41 camera_k_; // This encodes [fx, fy, cx, cy]
92  SE3 Tinv_;
93  Mat2 W_;//inverse of observation covariance (information matrix)
94  Mat<2,9> J_;//Joint Jacobian: 6 (pose) + 3(pint) || + 4 (K)
95  bool reversedNodeOrder_;//flag to keep order when building the adjacency matrix. This should be transparent for the user
96 
97  //project_point in 3D to 2D by the camera parameters in this class
98  //TODO, maybe move projective methods all together? this can be used in many other places in visual
99  Mat21 project_point(const Mat31 point);
100 
101  public:
102  EIGEN_MAKE_ALIGNED_OPERATOR_NEW // as proposed by Eigen
103 
104 };
105 
106 
107 }
108 
109 
110 
111 
112 #endif /* FACTORCAMERAPROJ3DPOINT_HPP_ */
MatRefConst get_jacobian([[maybe_unused]] mrob::factor_id_t id=0) const
Definition: factorCameraProj3dPoint.hpp:86
void evaluate_jacobians() override
Definition: factorCameraProj3dPoint.cpp:83
robustFactorType
Definition: factor.hpp:87
Definition: SE3.hpp:50
void evaluate_residuals() override
Definition: factorCameraProj3dPoint.cpp:67
VectRefConst get_residual() const
Definition: factorCameraProj3dPoint.hpp:84
void print() const
Definition: factorCameraProj3dPoint.cpp:129
MatRefConst get_obs() const
Definition: factorCameraProj3dPoint.hpp:83
void evaluate_chi2() override
Definition: factorCameraProj3dPoint.cpp:125
Definition: factorCameraProj3dPoint.hpp:62
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: factor.hpp:81