MROB
factorCameraProj3dLine.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  * factorCameraProj3dLine.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 FACTORCAMERAPROJ3DLINE_HPP_
25 #define FACTORCAMERAPROJ3DLINE_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 
58 {
59  public:
60  FactorCameraProj3dLine(const Mat21 &obsPoint1, const Mat21 &obsPoint2,
61  std::shared_ptr<Node> &nodePose,
62  std::shared_ptr<Node> &nodePoint1,
63  std::shared_ptr<Node> &nodePoint2,
64  const Mat41 &camera_k,
65  const Mat2 &obsInf = Mat2::Identity(),
66  Factor::robustFactorType robust_type = Factor::robustFactorType::QUADRATIC);
67  ~FactorCameraProj3dLine() override = default;
71  void evaluate_residuals() override;
75  void evaluate_jacobians() override;
76  void evaluate_chi2() override;
77 
78  void print() const;
79 
80  MatRefConst get_obs() const {return line_obs_;};
81  VectRefConst get_residual() const {return r_;};
82  MatRefConst get_information_matrix() const {return W_;};
83  MatRefConst get_jacobian([[maybe_unused]] mrob::factor_id_t id = 0) const {return J_;};
84 
85  protected:
86  Mat31 line_obs_;
87  Mat21 r_;
88  Mat31 point1_, point2_, local_point1_, local_point2_;
89  Mat41 camera_k_; // This encodes [fx, fy, cx, cy]
90  SE3 Tinv_;
91  Mat2 W_;//inverse of observation covariance (information matrix)
92  Mat<2,12> J_;//Joint Jacobian: 6 (pose) + 3(point) + 3 (point) + 4 (K)
93 
97  Mat31 project_point_homog(const Mat31 &point);
102  Mat31 calculate_image_line(const Mat21 &p1, const Mat21 &p2);
103 
104  public:
105  EIGEN_MAKE_ALIGNED_OPERATOR_NEW // as proposed by Eigen
106 
107 };
108 
109 
110 }
111 
112 
113 
114 
115 #endif /* FACTORCAMERAPROJ3DLINE_HPP_ */
Mat31 project_point_homog(const Mat31 &point)
Definition: factorCameraProj3dLine.cpp:53
void evaluate_residuals() override
Definition: factorCameraProj3dLine.cpp:80
robustFactorType
Definition: factor.hpp:87
Definition: SE3.hpp:50
Definition: factorCameraProj3dLine.hpp:57
Mat31 calculate_image_line(const Mat21 &p1, const Mat21 &p2)
Definition: factorCameraProj3dLine.cpp:68
MatRefConst get_jacobian([[maybe_unused]] mrob::factor_id_t id=0) const
Definition: factorCameraProj3dLine.hpp:83
void print() const
Definition: factorCameraProj3dLine.cpp:147
void evaluate_jacobians() override
Definition: factorCameraProj3dLine.cpp:92
void evaluate_chi2() override
Definition: factorCameraProj3dLine.cpp:143
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
MatRefConst get_obs() const
Definition: factorCameraProj3dLine.hpp:80
VectRefConst get_residual() const
Definition: factorCameraProj3dLine.hpp:81
Definition: factor.hpp:81