GLIM
Loading...
Searching...
No Matches
sub_map.hpp
1#pragma once
2
3#include <memory>
4#include <vector>
5#include <Eigen/Core>
6#include <Eigen/Geometry>
7
8#include <glim/odometry/estimation_frame.hpp>
9
10namespace glim {
11
16struct SubMap {
17public:
18 using Ptr = std::shared_ptr<SubMap>;
19 using ConstPtr = std::shared_ptr<const SubMap>;
20
21 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22
23 SubMap() : id(-1), session_id(0) {}
24
29
31 EstimationFrame::ConstPtr origin_frame() const { return frames[frames.size() / 2]; }
32
34 EstimationFrame::ConstPtr origin_odom_frame() const { return odom_frames[frames.size() / 2]; }
35
42 template <typename T>
43 T* get_custom_data(const std::string& key) {
44 const auto found = custom_data.find(key);
45 if (found == custom_data.end()) {
46 return nullptr;
47 }
48 return reinterpret_cast<T*>(found->second.get());
49 }
50
57 template <typename T>
58 const T* get_custom_data(const std::string& key) const {
59 const auto found = custom_data.find(key);
60 if (found == custom_data.end()) {
61 return nullptr;
62 }
63 return reinterpret_cast<const T*>(found->second.get());
64 }
65
70 void save(const std::string& path) const;
71
78 static SubMap::Ptr load(const std::string& path);
79
80public:
81 int id;
83
84 Eigen::Isometry3d T_world_origin;
85 Eigen::Isometry3d T_origin_endpoint_L;
86 Eigen::Isometry3d T_origin_endpoint_R;
87
88 gtsam_points::PointCloud::Ptr frame;
89 std::vector<gtsam_points::GaussianVoxelMap::Ptr> voxelmaps;
90
91 std::vector<EstimationFrame::ConstPtr> frames;
92 std::vector<EstimationFrame::ConstPtr> odom_frames;
93
94 std::unordered_map<std::string, std::shared_ptr<void>> custom_data;
95};
96
97} // namespace glim
SubMap.
Definition sub_map.hpp:16
const T * get_custom_data(const std::string &key) const
Get the custom data and cast it to the specified type.
Definition sub_map.hpp:58
std::vector< EstimationFrame::ConstPtr > odom_frames
Original odometry frames.
Definition sub_map.hpp:92
void drop_frame_points()
Remove point clouds of the odometry estimation frames (to save memory)
Eigen::Isometry3d T_origin_endpoint_L
frame.front() pose w.r.t. the origin
Definition sub_map.hpp:85
static SubMap::Ptr load(const std::string &path)
Load a submap from storage.
int id
submap ID
Definition sub_map.hpp:81
EstimationFrame::ConstPtr origin_frame() const
Get the origin frame.
Definition sub_map.hpp:31
gtsam_points::PointCloud::Ptr frame
Merged submap frame.
Definition sub_map.hpp:88
std::unordered_map< std::string, std::shared_ptr< void > > custom_data
User-defined custom data.
Definition sub_map.hpp:94
void save(const std::string &path) const
Save the submap.
T * get_custom_data(const std::string &key)
Get the custom data and cast it to the specified type.
Definition sub_map.hpp:43
int session_id
session ID (Used for only offline mapping)
Definition sub_map.hpp:82
EstimationFrame::ConstPtr origin_odom_frame() const
Get the origin odometry frame.
Definition sub_map.hpp:34
Eigen::Isometry3d T_origin_endpoint_R
frame.back() pose w.r.t. the origin
Definition sub_map.hpp:86
std::vector< gtsam_points::GaussianVoxelMap::Ptr > voxelmaps
Multi-resolution voxelmaps.
Definition sub_map.hpp:89
Eigen::Isometry3d T_world_origin
frame[frame.size() / 2] pose w.r.t. the world
Definition sub_map.hpp:84
std::vector< EstimationFrame::ConstPtr > frames
Optimized odometry frames.
Definition sub_map.hpp:91