Go to the documentation of this file. 1 #include <ceres/ceres.h>
2 #include <unordered_map>
17 std::vector<int> parameter_idx,
18 std::vector<double *> parameter_blocks)
28 std::vector<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
_jacobians;
48 std::shared_ptr<Frame> &frame1,
49 std::shared_ptr<Marginalization> &marginalization_last);
109 double computeOffDiag(std::shared_ptr<ALandmark> lmk_i, std::shared_ptr<ALandmark> lmk_j);
115 double computeKLD(Eigen::MatrixXd A_p, Eigen::MatrixXd A_q);
129 std::unordered_map<std::shared_ptr<Frame>, Eigen::MatrixXd>
131 std::vector<std::shared_ptr<MarginalizationBlockInfo>>
135 std::unordered_map<std::shared_ptr<ALandmark>, Eigen::Matrix3d>
137 std::unordered_map<std::shared_ptr<ALandmark>, Eigen::Vector3d>
164 this->mutable_parameter_block_sizes()->push_back(6);
165 this->mutable_parameter_block_sizes()->push_back(3);
166 this->mutable_parameter_block_sizes()->push_back(3);
167 this->mutable_parameter_block_sizes()->push_back(3);
172 for (
auto lmk : tlmk.second) {
173 (tlmk.first ==
"pointxd" ? this->mutable_parameter_block_sizes()->push_back(3)
174 : this->mutable_parameter_block_sizes()->push_back(6));
182 virtual bool Evaluate(
double const *
const *parameters,
double *residuals,
double **jacobians)
const {
191 Eigen::Map<
const Eigen::Matrix<double, 6, 1>>(parameters[block_id]);
194 Eigen::Map<const Eigen::Vector3d>(parameters[block_id]);
197 Eigen::Map<const Eigen::Vector3d>(parameters[block_id]);
200 Eigen::Map<const Eigen::Vector3d>(parameters[block_id]);
206 for (
auto lmk : tlmk.second) {
211 Eigen::Map<const Eigen::Vector3d>(parameters[block_id]);
217 Eigen::Map<Eigen::VectorXd>(residuals, n) =
227 if (jacobians[block_id]) {
229 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> jacobian(
230 jacobians[block_id], n, 6);
236 if (jacobians[block_id]) {
238 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> jacobian(
239 jacobians[block_id], n, 3);
245 if (jacobians[block_id]) {
247 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> jacobian(
248 jacobians[block_id], n, 3);
254 if (jacobians[block_id]) {
256 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> jacobian(
257 jacobians[block_id], n, 3);
267 for (
auto lmk : tlmk.second) {
271 if (jacobians[block_id]) {
273 Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> jacobian(
274 jacobians[block_id], n, 3);
bool computeJacobiansAndResiduals()
Compute the jacobian and the residual of the dense prior factor.
Definition: marginalization.cpp:503
void Evaluate()
Definition: marginalization.cpp:8
std::unordered_map< std::shared_ptr< Frame >, int > _map_frame_idx
Map between frames and indices in _Ak.
Definition: marginalization.hpp:127
const double _eps
Threshold to consider a null eigen value.
Definition: marginalization.hpp:120
void preMarginalizeRelative(std::shared_ptr< Frame > &frame0, std::shared_ptr< Frame > &frame1)
Select all the variables to keep and marginalize to derive the relative pose factor between two frame...
Definition: marginalization.cpp:519
Marginalization block struct that stores a factor and the indices of the variables involved.
Definition: marginalization.hpp:14
ceres::CostFunction * _cost_function
Definition: marginalization.hpp:23
MarginalizationFactor(std::shared_ptr< Marginalization > marginalization_info)
Definition: marginalization.hpp:159
bool computeSchurComplement()
Compute the dense prior with the Schur complement on _Ak.
Definition: marginalization.cpp:207
void preMarginalize(std::shared_ptr< Frame > &frame0, std::shared_ptr< Frame > &frame1, std::shared_ptr< Marginalization > &marginalization_last)
Select all the variables to keep and to marginalize in the Markov Blanket for fixed lag smoothing.
Definition: marginalization.cpp:23
Eigen::Matrix3d _info_lmk
Information matrix of the landmark absolute prior.
Definition: marginalization.hpp:140
double computeEntropy(std::shared_ptr< ALandmark > lmk)
Compute the Entropy of a given landmark.
Definition: marginalization.cpp:256
std::shared_ptr< Marginalization > _marginalization_info
Definition: marginalization.hpp:286
Eigen::VectorXd _Lambda
Non null Eigen values.
Definition: marginalization.hpp:148
Eigen::VectorXd _bk
Gradient of the subproblem.
Definition: marginalization.hpp:145
double computeOffDiag(std::shared_ptr< ALandmark > lmk_i, std::shared_ptr< ALandmark > lmk_j)
Approximate the Mutual Information between two landmarks using off diagonal blocks of _Ak.
Definition: marginalization.cpp:293
std::vector< std::shared_ptr< MarginalizationBlockInfo > > _marginalization_blocks
Vector of Marginalization blocks to derive _Ak.
Definition: marginalization.hpp:132
Marginalization class that handles marginalization (and sparsification) for fixed-lag smoothing.
Definition: marginalization.hpp:39
void rankReveallingDecomposition(Eigen::MatrixXd A, Eigen::MatrixXd &U, Eigen::VectorXd &d)
Compute the SVD of a given matrix to reveal its rank.
Definition: marginalization.cpp:305
double ** _raw_jacobians
Definition: marginalization.hpp:27
std::shared_ptr< ALandmark > _lmk_with_prior
Landmark that has an absolute prior factor.
Definition: marginalization.hpp:139
std::unordered_map< std::shared_ptr< ALandmark >, int > _map_lmk_idx
Map between landmarks and indices in _Ak.
Definition: marginalization.hpp:128
std::vector< double * > _parameter_blocks
Definition: marginalization.hpp:25
std::shared_ptr< Frame > _frame_to_marg
Frame to marginalize.
Definition: marginalization.hpp:123
Eigen::Vector3d _prior_lmk
Prior of the landmark absolute prior.
Definition: marginalization.hpp:141
int _n
Parametric size of the variables to keep.
Definition: marginalization.hpp:118
Eigen::VectorXd _marginalization_residual
Residual of the dense prior factor.
Definition: marginalization.hpp:151
Eigen::MatrixXd _U
Eigen vectors that have non null eigen values.
Definition: marginalization.hpp:147
Eigen::VectorXd _Sigma
Inverse of _Lambda.
Definition: marginalization.hpp:149
virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const
Definition: marginalization.hpp:182
Eigen::VectorXd _residuals
Definition: marginalization.hpp:29
double computeMutualInformation(std::shared_ptr< ALandmark > lmk_i, std::shared_ptr< ALandmark > lmk_j)
Compute the Mutual Information between two landmarks.
Definition: marginalization.cpp:265
Eigen::MatrixXd _Sigma_k
Covariance of the dense prior.
Definition: marginalization.hpp:146
Definition: AFeature2D.h:8
std::unordered_map< std::shared_ptr< ALandmark >, Eigen::Matrix3d > _map_lmk_inf
Map between landmarks and info mat of sparse relative prior factors.
Definition: marginalization.hpp:136
std::unordered_map< std::string, std::vector< std::shared_ptr< isae::ALandmark > > > typed_vec_landmarks
A typed vector of landmarks to handle hetereogeneous landmark sets.
Definition: typedefs.h:30
typed_vec_landmarks _lmk_to_keep
Set of landmarks to keep.
Definition: marginalization.hpp:125
std::unordered_map< std::shared_ptr< Frame >, Eigen::MatrixXd > _map_frame_inf
Map between frame and their marginal information matrix.
Definition: marginalization.hpp:130
int _n_full
Parametric size of the variables to keep after rank reveilling.
Definition: marginalization.hpp:119
void computeInformationAndGradient(std::vector< std::shared_ptr< MarginalizationBlockInfo >> blocks, Eigen::MatrixXd &A, Eigen::VectorXd &b)
Compute the information matrix and the gradient for a set of factors.
Definition: marginalization.cpp:145
Eigen::MatrixXd _Ak
Information matrix of the subproblem.
Definition: marginalization.hpp:144
MarginalizationBlockInfo(ceres::CostFunction *cost_function, std::vector< int > parameter_idx, std::vector< double * > parameter_blocks)
Definition: marginalization.hpp:16
std::vector< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > _jacobians
Definition: marginalization.hpp:28
std::unordered_map< std::shared_ptr< ALandmark >, Eigen::Vector3d > _map_lmk_prior
Map between landmarks and priors of sparse prior relative factors.
Definition: marginalization.hpp:138
bool sparsifyVIO()
Sparsify the dense prior factor in the VIO case.
Definition: marginalization.cpp:349
Eigen::MatrixXd _marginalization_jacobian
Jacobian of the dense prior factor.
Definition: marginalization.hpp:150
double computeKLD(Eigen::MatrixXd A_p, Eigen::MatrixXd A_q)
Compute the KLD between the multivariate Gaussian with their Information Matrix assuming their mean i...
Definition: marginalization.cpp:331
Ceres cost function of the dense prior factor.
Definition: marginalization.hpp:157
std::vector< int > _parameter_idx
Definition: marginalization.hpp:24
std::shared_ptr< Frame > _frame_to_keep
Frame to keep.
Definition: marginalization.hpp:124
int _m
Parametric size of the variables to marginalize.
Definition: marginalization.hpp:117
typed_vec_landmarks _lmk_to_marg
Set of landmarks to marginalize.
Definition: marginalization.hpp:126
bool sparsifyVO()
Sparsify the dense prior factor in the VO case.
Definition: marginalization.cpp:397