Skip to content

Commit

Permalink
Add Options for GlobalOptimizer (#621)
Browse files Browse the repository at this point in the history
* Add Options for GlobalOptimizer

- num_iter
- use_huber_kernel

* Update clang-format-lint-action
  • Loading branch information
ymd-stella authored Oct 4, 2024
1 parent 4be17ea commit 7b78cc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.12
- uses: DoozyX/clang-format-lint-action@v0.18.1
with:
source: "."
exclude: "./3rd"
Expand Down
5 changes: 4 additions & 1 deletion src/stella_vslam/global_optimization_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ global_optimization_module::global_optimization_module(data::map_database* map_d
data::bow_vocabulary* bow_vocab, const YAML::Node& yaml_node,
const bool fix_scale)
: loop_detector_(new module::loop_detector(bow_db, bow_vocab, util::yaml_optional_ref(yaml_node, "LoopDetector"), fix_scale)),
loop_bundle_adjuster_(new module::loop_bundle_adjuster(map_db)),
loop_bundle_adjuster_(new module::loop_bundle_adjuster(
map_db,
util::yaml_optional_ref(yaml_node, "GlobalOptimizer")["num_iter"].as<unsigned int>(10),
util::yaml_optional_ref(yaml_node, "GlobalOptimizer")["use_huber_kernel"].as<bool>(false))),
map_db_(map_db),
graph_optimizer_(new optimize::graph_optimizer(util::yaml_optional_ref(yaml_node, "GraphOptimizer"), fix_scale)),
thr_neighbor_keyframes_(util::yaml_optional_ref(yaml_node, "GlobalOptimizer")["thr_neighbor_keyframes"].as<unsigned int>(15)) {
Expand Down
8 changes: 5 additions & 3 deletions src/stella_vslam/module/loop_bundle_adjuster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
namespace stella_vslam {
namespace module {

loop_bundle_adjuster::loop_bundle_adjuster(data::map_database* map_db, const unsigned int num_iter)
: map_db_(map_db), num_iter_(num_iter) {}
loop_bundle_adjuster::loop_bundle_adjuster(data::map_database* map_db,
const unsigned int num_iter,
const bool use_huber_kernel)
: map_db_(map_db), num_iter_(num_iter), use_huber_kernel_(use_huber_kernel) {}

void loop_bundle_adjuster::set_mapping_module(mapping_module* mapper) {
mapper_ = mapper;
Expand Down Expand Up @@ -42,7 +44,7 @@ void loop_bundle_adjuster::optimize(const std::shared_ptr<data::keyframe>& curr_
std::unordered_set<unsigned int> optimized_landmark_ids;
eigen_alloc_unord_map<unsigned int, Vec3_t> lm_to_pos_w_after_global_BA;
eigen_alloc_unord_map<unsigned int, Mat44_t> keyfrm_to_pose_cw_after_global_BA;
const auto global_BA = optimize::global_bundle_adjuster(num_iter_, false);
const auto global_BA = optimize::global_bundle_adjuster(num_iter_, use_huber_kernel_);
bool ok = global_BA.optimize(curr_keyfrm->graph_node_->get_keyframes_from_root(),
optimized_keyfrm_ids, optimized_landmark_ids,
lm_to_pos_w_after_global_BA,
Expand Down
6 changes: 5 additions & 1 deletion src/stella_vslam/module/loop_bundle_adjuster.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class loop_bundle_adjuster {
/**
* Constructor
*/
explicit loop_bundle_adjuster(data::map_database* map_db, const unsigned int num_iter = 10);
explicit loop_bundle_adjuster(data::map_database* map_db,
const unsigned int num_iter = 10,
const bool use_huber_kernel = false);

/**
* Destructor
Expand Down Expand Up @@ -56,6 +58,8 @@ class loop_bundle_adjuster {
//! number of iteration for optimization
const unsigned int num_iter_ = 10;

const bool use_huber_kernel_ = false;

//-----------------------------------------
// thread management

Expand Down

0 comments on commit 7b78cc9

Please sign in to comment.