20#ifndef UPDATER_HELPER_HPP
21#define UPDATER_HELPER_HPP
23#include <opencv2/opencv.hpp>
25#include <boost/math/distributions/chi_squared.hpp>
27#include "types/fptypes.hpp"
28#include "msceqf/state/state.hpp"
29#include "utils/tools.hpp"
33using MatrixXBlockRowRef = Ref<MatrixX::RowsBlockXpr>;
34using VectorXBlockRowRef = Ref<VectorX::RowsBlockXpr>;
36using ColsMap = utils::InsertionOrderedMap<MSCEqFState::MSCEqFKey, size_t>;
46 const Vector3& A_f,
const Vector2& uv,
const Vector2& uvn,
const fp& anchor_timestamp,
const fp& clone_timestamp)
72 [[nodiscard]]
virtual Vector3
pi(
const Vector3& f) = 0;
80 [[nodiscard]]
virtual MatrixX
dpi(
const Vector3& f) = 0;
96 MatrixXBlockRowRef C_block_row,
97 VectorXBlockRowRef delta_block_row,
98 MatrixXBlockRowRef Cf_block_row,
99 const ColsMap& cols_map) = 0;
137 ProjectionHelperS2(
const FeatureRepresentation& feature_representation) :
ProjectionHelper(feature_representation)
148 [[nodiscard]] Vector3
pi(
const Vector3& f)
override;
156 [[nodiscard]] MatrixX
dpi(
const Vector3& f)
override;
172 MatrixXBlockRowRef C_block_row,
173 VectorXBlockRowRef delta_block_row,
174 MatrixXBlockRowRef Cf_block_row,
175 const ColsMap& cols_map)
override;
186 ProjectionHelperZ1(
const FeatureRepresentation& feature_representation) :
ProjectionHelper(feature_representation)
197 [[nodiscard]] Vector3
pi(
const Vector3& f)
override;
205 [[nodiscard]] MatrixX
dpi(
const Vector3& f)
override;
221 MatrixXBlockRowRef C_block_row,
222 VectorXBlockRowRef delta_block_row,
223 MatrixXBlockRowRef Cf_block_row,
224 const ColsMap& cols_map)
override;
227using ProjectionHelperSharedPtr = std::shared_ptr<ProjectionHelper>;
228using ProjectionHelperUniquePtr = std::unique_ptr<ProjectionHelper>;
229using ProjectionHelperZ1SharedPtr = std::shared_ptr<ProjectionHelperZ1>;
230using ProjectionHelperZ1UniquePtr = std::unique_ptr<ProjectionHelperZ1>;
231using ProjectionHelperS2SharedPtr = std::shared_ptr<ProjectionHelperS2>;
232using ProjectionHelperS2UniquePtr = std::unique_ptr<ProjectionHelperS2>;
241[[nodiscard]]
static ProjectionHelperUniquePtr createProjectionHelper(
242 const FeatureRepresentation& feature_representation)
244 if constexpr (std::is_base_of_v<ProjectionHelper, T>)
246 return std::make_unique<T>(feature_representation);
267 [[nodiscard]]
static Matrix<2, 4>
Xi(
const Vector3& f);
303 [[nodiscard]]
static bool chi2Test(
const fp& chi2,
const size_t& dof,
const std::map<uint, fp>& chi2_table);
this class represent the state of the MSCEqF. This includes the state of the lifted system (element o...
Definition state.hpp:38
size_t block_rows_
Number of rows of a C matrix block and a residual block.
Definition updater_helper.hpp:125
size_t dim_loss_
Dimension lost due to nullspace projection.
Definition updater_helper.hpp:126
const size_t & dim_loss() const
Get the dimension lost due to nullspace projection.
Definition updater_helper.hpp:113
ProjectionHelper(const FeatureRepresentation &feature_representation)
Rule of 5.
virtual MatrixX dpi(const Vector3 &f)=0
Projection differential function. This function computes the differential of the projection function.
virtual void residualJacobianBlock(const MSCEqFState &X, const SystemState &xi0, const FeatHelper &feat, MatrixXBlockRowRef C_block_row, VectorXBlockRowRef delta_block_row, MatrixXBlockRowRef Cf_block_row, const ColsMap &cols_map)=0
Computes a block row of the C matrix and a block of the residual, corresponding to the given feature ...
const size_t & block_rows() const
Get the number of rows of a C matrix block and a residual block.
Definition updater_helper.hpp:106
FeatureRepresentation feature_representation_
Feature representation.
Definition updater_helper.hpp:123
virtual Vector3 pi(const Vector3 &f)=0
Projection function. This function projects a 3D point.
MatrixX dpi(const Vector3 &f) override
Projection differential function. This function computes the differential of the projection function.
Vector3 pi(const Vector3 &f) override
Projection function. This function projects a 3D point on the unit sphere.
void residualJacobianBlock(const MSCEqFState &X, const SystemState &xi0, const FeatHelper &feat, MatrixXBlockRowRef C_block_row, VectorXBlockRowRef delta_block_row, MatrixXBlockRowRef Cf_block_row, const ColsMap &cols_map) override
Computes a block row of the C matrix and a block of the residual, corresponding to the given feature ...
MatrixX dpi(const Vector3 &f) override
Projection differential function. This function computes the differential of the projection function.
void residualJacobianBlock(const MSCEqFState &X, const SystemState &xi0, const FeatHelper &feat, MatrixXBlockRowRef C_block_row, VectorXBlockRowRef delta_block_row, MatrixXBlockRowRef Cf_block_row, const ColsMap &cols_map) override
Computes a block row of the C matrix and a block of the residual, corresponding to the given feature ...
Vector3 pi(const Vector3 &f) override
Projection function. This function projects a 3D point on the unit plane.
The SystemState class represent the state of the system posed on the Homogenous space.
Definition system.hpp:37
FeatHelper struct. This struct implements a helper structure holding all the information related to a...
Definition updater_helper.hpp:44
const Vector3 & A_f_
Triangulated feature in anchor frame.
Definition updater_helper.hpp:49
const Vector2 & uv_
(measured) feature coordinates
Definition updater_helper.hpp:50
const fp & anchor_timestamp_
Timestamp of the anchor.
Definition updater_helper.hpp:52
const fp & clone_timestamp_
Timestamp of the feature measurement.
Definition updater_helper.hpp:53
const Vector2 & uvn_
Normalized (measured) feature coordinates.
Definition updater_helper.hpp:51
Updater helper struct. This structs implements common helper methods for MSCEqF update.
Definition updater_helper.hpp:260
static Matrix< 2, 4 > Xi(const Vector3 &f)
Xi operator R^3 -> R^2x4.
static Matrix3 inverseDepthJacobian(const Vector3 &A_f)
Compute the Jacobian for inverse depth parametrization, used in the Cf matrix.
static bool chi2Test(const fp &chi2, const size_t &dof, const std::map< uint, fp > &chi2_table)
Perform chi2 test (based on precomputed table) on the given block of the residual.
static void nullspaceProjection(Ref< MatrixX > Cf, MatrixXBlockRowRef Ct, VectorXBlockRowRef delta)
Perform in-place nullspace projection of the Cf matrix on the Ct matrix and the residual using QR dec...
static void updateQRCompression(MatrixX &C, VectorX &delta)
Perform in-place compression of the C matrix and the residual using QR decomposition.