-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpose_graph_optimization.rs
52 lines (46 loc) · 1.49 KB
/
pose_graph_optimization.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use dialoguer::{theme::ColorfulTheme, Select};
use std::error::Error;
use robotics::mapping::{PoseGraph, PoseGraphSolver};
fn main() -> Result<(), Box<dyn Error>> {
// Create output directory if it didnt exist
std::fs::create_dir_all("./img")?;
let filenames = &[
"simulation-pose-pose.g2o",
"simulation-pose-landmark.g2o",
"dlr.g2o",
"intel.g2o",
"input_M3500_g2o.g2o",
"sphere2500.g2o",
"torus3D.g2o",
"parking-garage.g2o",
];
let filename_idx = Select::with_theme(&ColorfulTheme::default())
.with_prompt("Pick g2o file")
.default(0)
.items(&filenames[..])
.interact()
.unwrap();
let filename = format!("dataset/g2o/{}", filenames[filename_idx]);
let solvers = &["GaussNewton", "LevenbergMarquardt"];
let solver_idx = Select::with_theme(&ColorfulTheme::default())
.with_prompt("Pick Solver")
.default(0)
.items(&solvers[..])
.interact()
.unwrap();
let solver = match solver_idx {
0 => PoseGraphSolver::GaussNewton,
1 => PoseGraphSolver::LevenbergMarquardt,
_ => unreachable!(),
};
let plot = Select::with_theme(&ColorfulTheme::default())
.with_prompt("Plot the resut?")
.default(0)
.items(&[true, false])
.interact()
.unwrap();
let plot = plot == 0;
let mut graph = PoseGraph::new(filename.as_str(), solver)?;
graph.optimize(50, true, plot)?;
Ok(())
}