diff --git a/include/core/ceres_wrapper/solver_ceres.h b/include/core/ceres_wrapper/solver_ceres.h index 210a1aad9b11724188c0d0951551d8bc680d572e..9d473358abdec1c18f2b7239deabaa6399106825 100644 --- a/include/core/ceres_wrapper/solver_ceres.h +++ b/include/core/ceres_wrapper/solver_ceres.h @@ -173,18 +173,22 @@ inline ceres::Solver::Options& SolverCeres::getSolverOptions() inline bool SolverCeres::isFactorRegisteredDerived(const FactorBasePtr& fac_ptr) const { - return fac_2_residual_idx_.find(fac_ptr) != fac_2_residual_idx_.end() and - fac_2_costfunction_.find(fac_ptr) != fac_2_costfunction_.end(); + return fac_2_residual_idx_.count(fac_ptr) == 1 and + fac_2_costfunction_.count(fac_ptr) == 1; } inline bool SolverCeres::isStateBlockRegisteredDerived(const StateBlockPtr& state_ptr) const { + if (state_blocks_.count(state_ptr) == 0) + return false; return ceres_problem_->HasParameterBlock(getAssociatedMemBlockPtr(state_ptr)); } inline bool SolverCeres::isStateBlockFixedDerived(const StateBlockPtr& st) { - return ceres_problem_->IsParameterBlockConstant(SolverManager::getAssociatedMemBlockPtr(st)); + if (state_blocks_.count(st) == 0) + return false; + return ceres_problem_->IsParameterBlockConstant(getAssociatedMemBlockPtr(st)); }; inline bool SolverCeres::hasLocalParametrizationDerived(const StateBlockPtr& st) const