diff --git a/include/core/problem/problem.h b/include/core/problem/problem.h index 0ba4badcdba1e22b15d5ab228673aaf363b7954d..fa64604575e47511e913ea8a2c800c29bd11c133 100644 --- a/include/core/problem/problem.h +++ b/include/core/problem/problem.h @@ -38,11 +38,8 @@ enum Notification struct PriorOptions { std::string mode = ""; - Eigen::VectorXd state; // todo remove all - Eigen::MatrixXd cov; // todo remove all - StateStructure structure; - VectorComposite state__; // todo remove __ - MatrixComposite cov__; // todo remove __ + VectorComposite state; + MatrixComposite cov; double time_tolerance; }; WOLF_STRUCT_PTR_TYPEDEFS(PriorOptions); diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 8b7bf52b5f66836bf9e280f152a51fba212a033f..786b8816bf2fbd3823b9cd728649d7b48968f46d 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -934,37 +934,6 @@ FrameBasePtr Problem::closestKeyOrAuxFrameToTimeStamp(const TimeStamp& _ts) cons return trajectory_ptr_->closestKeyOrAuxFrameToTimeStamp(_ts); } -// void Problem::setPriorOptions(const std::string& _mode, -// const double _time_tolerance, -// const Eigen::VectorXd& _state, -// const Eigen::MatrixXd& _cov) -// { -// assert(prior_options_ != nullptr && "prior options have already been applied"); -// assert(prior_options_->mode == "" && "prior options have already been set"); -// assert((_mode == "nothing" || _mode == "initial_guess" || _mode == "fix" || _mode == "factor") && "wrong _mode value, it should be: 'nothing', 'initial_guess', 'fix' or 'factor'"); - -// // Store options (optionals depending on the mode) -// WOLF_TRACE("prior mode: ", _mode); -// prior_options_->mode = _mode; - -// if (prior_options_->mode != "nothing") -// { -// assert(_time_tolerance > 0 && "time tolerance should be bigger than 0"); - -// WOLF_TRACE("prior state: ", _state.transpose()); -// WOLF_TRACE("prior time tolerance: ", _time_tolerance); -// prior_options_->state = _state; -// prior_options_->time_tolerance = _time_tolerance; - -// if (prior_options_->mode == "factor") -// { -// assert(isCovariance(_cov) && "cov is not a covariance matrix (symmetric and Pos Def)"); -// WOLF_TRACE("prior covariance:\n" , _cov); -// prior_options_->cov = _cov; -// } -// } -// } - void Problem::setPriorOptions(const std::string& _mode, const double _time_tolerance , const VectorComposite& _state , @@ -977,7 +946,6 @@ void Problem::setPriorOptions(const std::string& _mode, // Store options (optionals depending on the mode) WOLF_TRACE("prior mode: ", _mode); prior_options_->mode = _mode; - prior_options_->structure = getFrameStructure(); if (prior_options_->mode != "nothing") { @@ -985,7 +953,7 @@ void Problem::setPriorOptions(const std::string& _mode, WOLF_TRACE("prior state: ", _state); WOLF_TRACE("prior time tolerance: ", _time_tolerance); - prior_options_->state__ = _state; + prior_options_->state = _state; prior_options_->time_tolerance = _time_tolerance; if (prior_options_->mode == "factor") @@ -997,14 +965,16 @@ void Problem::setPriorOptions(const std::string& _mode, assert(isPositive && "sigma is not positive"); MatrixComposite Q; - for (const auto& ckey : prior_options_->structure) + for (const auto& pair_key_sig : _sigma) { - const auto& key = string(1,ckey); // ckey is char - auto cov_blk = (_sigma.at(key).array() * _sigma.at(key).array()).matrix().asDiagonal(); + const auto& key = pair_key_sig.first; + const auto& sig_blk = pair_key_sig.second; + + const auto& cov_blk = (sig_blk.array() * sig_blk.array()).matrix().asDiagonal(); Q.emplace(key,key,cov_blk); } WOLF_TRACE("prior covariance:" , Q); - prior_options_->cov__ = Q; + prior_options_->cov = Q; } } } @@ -1019,7 +989,7 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts) { prior_keyframe = emplaceFrame(KEY, _ts, - prior_options_->state__); + prior_options_->state); if (prior_options_->mode == "fix") prior_keyframe->fix(); @@ -1036,8 +1006,8 @@ FrameBasePtr Problem::applyPriorOptions(const TimeStamp& _ts) const auto& key = pair_key_sb.first; const auto& sb = pair_key_sb.second; - const auto& state_blk = prior_options_->state__.at(key); - const auto& covar_blk = prior_options_->cov__.at(key,key); + const auto& state_blk = prior_options_->state.at(key); + const auto& covar_blk = prior_options_->cov.at(key,key); assert(sb->getSize() == state_blk.size() && "prior_options state wrong size"); assert(sb->getLocalSize() == covar_blk.rows() && "prior_options cov. wrong size");