MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / ReadGravity

Function ReadGravity

deps/glomap/glomap/io/gravity_io.cc:6–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5namespace glomap {
6void ReadGravity(const std::string& gravity_path,
7 std::unordered_map<image_t, Image>& images) {
8 std::unordered_map<std::string, image_t> name_idx;
9 for (const auto& [image_id, image] : images) {
10 name_idx[image.file_name] = image_id;
11 }
12
13 std::ifstream file(gravity_path);
14
15 // Read in the file list
16 std::string line, item;
17 Eigen::Vector3d gravity;
18 int counter = 0;
19 while (std::getline(file, line)) {
20 std::stringstream line_stream(line);
21
22 // file_name
23 std::string name;
24 std::getline(line_stream, name, ' ');
25
26 // Gravity
27 for (double i = 0; i < 3; i++) {
28 std::getline(line_stream, item, ' ');
29 gravity[i] = std::stod(item);
30 }
31
32 // Check whether the image present
33 auto ite = name_idx.find(name);
34 if (ite != name_idx.end()) {
35 counter++;
36 images[ite->second].gravity_info.SetGravity(gravity);
37 // Make sure the initialization is aligned with the gravity
38 images[ite->second].cam_from_world.rotation =
39 images[ite->second].gravity_info.GetRAlign().transpose();
40 }
41 }
42 LOG(INFO) << counter << " images are loaded with gravity" << std::endl;
43}
44
45} // namespace glomap

Callers

nothing calls this directly

Calls 1

SetGravityMethod · 0.80

Tested by

no test coverage detected