-
Notifications
You must be signed in to change notification settings - Fork 85
/
main.cpp
65 lines (51 loc) · 1.5 KB
/
main.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "SESync/SESync.h"
#include "SESync/SESync_utils.h"
#include <fstream>
#ifdef GPERFTOOLS
#include <gperftools/profiler.h>
#endif
using namespace std;
using namespace SESync;
bool write_poses = false;
int main(int argc, char **argv) {
if (argc != 2) {
cout << "Usage: " << argv[0] << " [input .g2o file]" << endl;
exit(1);
}
size_t num_poses;
measurements_t measurements = read_g2o_file(argv[1], num_poses);
cout << "Loaded " << measurements.size() << " measurements between "
<< num_poses << " poses from file " << argv[1] << endl
<< endl;
if (measurements.size() == 0) {
cout << "Error: No measurements were read!"
<< " Are you sure the file exists?" << endl;
exit(1);
}
SESyncOpts opts;
opts.verbose = true; // Print output to stdout
// Initialization method
// Options are: Chordal, Random
opts.initialization = Initialization::Chordal;
// Specific form of the synchronization problem to solve
// Options are: Simplified, Explicit, SOSync
opts.formulation = Formulation::Simplified;
// Initial
opts.num_threads = 4;
#ifdef GPERFTOOLS
ProfilerStart("SE-Sync.prof");
#endif
/// RUN SE-SYNC!
SESyncResult results = SESync::SESync(measurements, opts);
#ifdef GPERFTOOLS
ProfilerStop();
#endif
if (write_poses) {
// Write output
string filename = "poses.txt";
cout << "Saving final poses to file: " << filename << endl;
ofstream poses_file(filename);
poses_file << results.xhat;
poses_file.close();
}
}