12#ifndef UPDATER_HELPER_HPP
13#define UPDATER_HELPER_HPP
15#include <opencv2/opencv.hpp>
17#include <boost/math/distributions/chi_squared.hpp>
19#include "types/fptypes.hpp"
20#include "msceqf/state/state.hpp"
21#include "utils/tools.hpp"
25using MatrixXBlockRowRef = Ref<MatrixX::RowsBlockXpr>;
26using VectorXBlockRowRef = Ref<VectorX::RowsBlockXpr>;
38 const Vector3& A_f,
const Vector2& uv,
const Vector2& uvn,
const fp& anchor_timestamp,
const fp& clone_timestamp)
64 [[nodiscard]]
virtual Vector3
pi(
const Vector3& f) = 0;
72 [[nodiscard]]
virtual MatrixX
dpi(
const Vector3& f) = 0;
88 MatrixXBlockRowRef C_block_row,
89 VectorXBlockRowRef delta_block_row,
90 MatrixXBlockRowRef Cf_block_row,
140 [[nodiscard]] Vector3
pi(
const Vector3& f)
override;
148 [[nodiscard]] MatrixX
dpi(
const Vector3& f)
override;
164 MatrixXBlockRowRef C_block_row,
165 VectorXBlockRowRef delta_block_row,
166 MatrixXBlockRowRef Cf_block_row,
167 const ColsMap& cols_map)
override;
189 [[nodiscard]] Vector3
pi(
const Vector3& f)
override;
197 [[nodiscard]] MatrixX
dpi(
const Vector3& f)
override;
213 MatrixXBlockRowRef C_block_row,
214 VectorXBlockRowRef delta_block_row,
215 MatrixXBlockRowRef Cf_block_row,
216 const ColsMap& cols_map)
override;
219using ProjectionHelperSharedPtr = std::shared_ptr<ProjectionHelper>;
220using ProjectionHelperUniquePtr = std::unique_ptr<ProjectionHelper>;
221using ProjectionHelperZ1SharedPtr = std::shared_ptr<ProjectionHelperZ1>;
222using ProjectionHelperZ1UniquePtr = std::unique_ptr<ProjectionHelperZ1>;
223using ProjectionHelperS2SharedPtr = std::shared_ptr<ProjectionHelperS2>;
224using ProjectionHelperS2UniquePtr = std::unique_ptr<ProjectionHelperS2>;
233[[nodiscard]]
static ProjectionHelperUniquePtr createProjectionHelper(
234 const FeatureRepresentation& feature_representation)
236 if constexpr (std::is_base_of_v<ProjectionHelper, T>)
238 return std::make_unique<T>(feature_representation);
259 [[nodiscard]]
static Matrix<2, 4>
Xi(
const Vector3& f);
295 [[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:30
ProjectionHelper interface. This class provides an interface to the implementation of the projection ...
Definition updater_helper.hpp:54
size_t block_rows_
Number of rows of a C matrix block and a residual block.
Definition updater_helper.hpp:117
size_t dim_loss_
Dimension lost due to nullspace projection.
Definition updater_helper.hpp:118
const size_t & dim_loss() const
Get the dimension lost due to nullspace projection.
Definition updater_helper.hpp:105
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:98
FeatureRepresentation feature_representation_
Feature representation.
Definition updater_helper.hpp:115
virtual Vector3 pi(const Vector3 &f)=0
Projection function. This function projects a 3D point.
ProjectionHelperS2 class. This class provides an implementation of the projection on the unit sphere ...
Definition updater_helper.hpp:127
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 ...
ProjectionHelperZ1 class. This class provides an implementation of the projection on the unit plane a...
Definition updater_helper.hpp:176
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:29
This calss define a map that keeps the insertion order.
Definition tools.hpp:34
FeatHelper struct. This struct implements a helper structure holding all the information related to a...
Definition updater_helper.hpp:36
const Vector3 & A_f_
Triangulated feature in anchor frame.
Definition updater_helper.hpp:41
const Vector2 & uv_
(measured) feature coordinates
Definition updater_helper.hpp:42
const fp & anchor_timestamp_
Timestamp of the anchor.
Definition updater_helper.hpp:44
const fp & clone_timestamp_
Timestamp of the feature measurement.
Definition updater_helper.hpp:45
const Vector2 & uvn_
Normalized (measured) feature coordinates.
Definition updater_helper.hpp:43
Updater helper struct. This structs implements common helper methods for MSCEqF update.
Definition updater_helper.hpp:252
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.