diff --git a/include/glim/odometry/estimation_frame.hpp b/include/glim/odometry/estimation_frame.hpp index b5707520..add5795a 100644 --- a/include/glim/odometry/estimation_frame.hpp +++ b/include/glim/odometry/estimation_frame.hpp @@ -48,6 +48,36 @@ struct EstimationFrame { */ void set_T_world_sensor(FrameID frame_id, const Eigen::Isometry3d& T); + /** + * @brief Get the custom data and cast it to the specified type. + * @note This method does not check the type of the custom data. + * @param key Key of the custom data + * @return T* Pointer to the custom data. nullptr if not found. + */ + template + T* get_custom_data(const std::string& key) { + const auto found = custom_data.find(key); + if (found == custom_data.end()) { + return nullptr; + } + return reinterpret_cast(found->second.get()); + } + + /** + * @brief Get the custom data and cast it to the specified type. + * @note This method does not check the type of the custom data. + * @param key Key of the custom data + * @return T* Pointer to the custom data. nullptr if not found. + */ + template + const T* get_custom_data(const std::string& key) const { + const auto found = custom_data.find(key); + if (found == custom_data.end()) { + return nullptr; + } + return reinterpret_cast(found->second.get()); + } + public: long id; ///< Frame ID double stamp; ///< Timestamp