123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #ifndef OPTIMIZER_H
- #define OPTIMIZER_H
- #include "Map.h"
- #include "MapPoint.h"
- #include "KeyFrame.h"
- #include "LoopClosing.h"
- #include "Frame.h"
- #include <math.h>
- #include "Thirdparty/g2o/g2o/types/types_seven_dof_expmap.h"
- #include "Thirdparty/g2o/g2o/core/sparse_block_matrix.h"
- #include "Thirdparty/g2o/g2o/core/block_solver.h"
- #include "Thirdparty/g2o/g2o/core/optimization_algorithm_levenberg.h"
- #include "Thirdparty/g2o/g2o/core/optimization_algorithm_gauss_newton.h"
- #include "Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h"
- #include "Thirdparty/g2o/g2o/types/types_six_dof_expmap.h"
- #include "Thirdparty/g2o/g2o/core/robust_kernel_impl.h"
- #include "Thirdparty/g2o/g2o/solvers/linear_solver_dense.h"
- namespace ORB_SLAM3
- {
- class LoopClosing;
- class Optimizer
- {
- public:
- void static BundleAdjustment(const std::vector<KeyFrame*> &vpKF, const std::vector<MapPoint*> &vpMP,
- int nIterations = 5, bool *pbStopFlag=NULL, const unsigned long nLoopKF=0,
- const bool bRobust = true);
- void static GlobalBundleAdjustemnt(Map* pMap, int nIterations=5, bool *pbStopFlag=NULL,
- const unsigned long nLoopKF=0, const bool bRobust = true);
- void static FullInertialBA(Map *pMap, int its, const bool bFixLocal=false, const unsigned long nLoopKF=0, bool *pbStopFlag=NULL, bool bInit=false, float priorG = 1e2, float priorA=1e6, Eigen::VectorXd *vSingVal = NULL, bool *bHess=NULL);
- void static LocalBundleAdjustment(KeyFrame* pKF, bool *pbStopFlag, Map *pMap, int& num_fixedKF, int& num_OptKF, int& num_MPs, int& num_edges);
- int static PoseOptimization(Frame* pFrame);
- int static PoseInertialOptimizationLastKeyFrame(Frame* pFrame, bool bRecInit = false);
- int static PoseInertialOptimizationLastFrame(Frame *pFrame, bool bRecInit = false);
-
- void static OptimizeEssentialGraph(Map* pMap, KeyFrame* pLoopKF, KeyFrame* pCurKF,
- const LoopClosing::KeyFrameAndPose &NonCorrectedSim3,
- const LoopClosing::KeyFrameAndPose &CorrectedSim3,
- const map<KeyFrame *, set<KeyFrame *> > &LoopConnections,
- const bool &bFixScale);
- void static OptimizeEssentialGraph(KeyFrame* pCurKF, vector<KeyFrame*> &vpFixedKFs, vector<KeyFrame*> &vpFixedCorrectedKFs,
- vector<KeyFrame*> &vpNonFixedKFs, vector<MapPoint*> &vpNonCorrectedMPs);
-
- void static OptimizeEssentialGraph4DoF(Map* pMap, KeyFrame* pLoopKF, KeyFrame* pCurKF,
- const LoopClosing::KeyFrameAndPose &NonCorrectedSim3,
- const LoopClosing::KeyFrameAndPose &CorrectedSim3,
- const map<KeyFrame *, set<KeyFrame *> > &LoopConnections);
-
- static int OptimizeSim3(KeyFrame* pKF1, KeyFrame* pKF2, std::vector<MapPoint *> &vpMatches1,
- g2o::Sim3 &g2oS12, const float th2, const bool bFixScale,
- Eigen::Matrix<double,7,7> &mAcumHessian, const bool bAllPoints=false);
-
- void static LocalInertialBA(KeyFrame* pKF, bool *pbStopFlag, Map *pMap, int& num_fixedKF, int& num_OptKF, int& num_MPs, int& num_edges, bool bLarge = false, bool bRecInit = false);
- void static MergeInertialBA(KeyFrame* pCurrKF, KeyFrame* pMergeKF, bool *pbStopFlag, Map *pMap, LoopClosing::KeyFrameAndPose &corrPoses);
-
- void static LocalBundleAdjustment(KeyFrame* pMainKF,vector<KeyFrame*> vpAdjustKF, vector<KeyFrame*> vpFixedKF, bool *pbStopFlag);
-
-
- static Eigen::MatrixXd Marginalize(const Eigen::MatrixXd &H, const int &start, const int &end);
-
- void static InertialOptimization(Map *pMap, Eigen::Matrix3d &Rwg, double &scale, Eigen::Vector3d &bg, Eigen::Vector3d &ba, bool bMono, Eigen::MatrixXd &covInertial, bool bFixedVel=false, bool bGauss=false, float priorG = 1e2, float priorA = 1e6);
- void static InertialOptimization(Map *pMap, Eigen::Vector3d &bg, Eigen::Vector3d &ba, float priorG = 1e2, float priorA = 1e6);
- void static InertialOptimization(Map *pMap, Eigen::Matrix3d &Rwg, double &scale);
- EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
- };
- }
- #endif
|