My Project 1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
HolisticFusionDualGraph.h
Go to the documentation of this file.
1/*
2Copyright 2022 by Julian Nubert, Robotic Systems Lab, ETH Zurich.
3All rights reserved.
4This file is released under the "BSD-3-Clause License".
5Please see the LICENSE file that has been included as part of this package.
6 */
7
8#ifndef HOLISTIC_FUSION_H
9#define HOLISTIC_FUSION_H
10
11// Package
13
14// Defined macros
15#define ROS_QUEUE_SIZE 100
16#define REQUIRED_GNSS_NUM_NOT_JUMPED 20 // 2*singleGnssJumping = 2*20 = 40
17#define GNSS_COVARIANCE_VIOLATION_THRESHOLD 0.2 // 10000
18#define GREEN_START "\033[92m"
19#define YELLOW_START "\033[33m"
20#define RED_START "\033[31m"
21#define COLOR_END "\033[0m"
22
23namespace holistic_fusion {
24
25// Actual Class
27 public: // Interface
28 // Constructor
30 // Destructor
32 // Setup
33 virtual bool setup();
34
35 // Graph selection
36 void activateGlobalGraph(const gtsam::Vector3& imuPosition, const gtsam::Rot3& imuRotation, const double measurementTime);
38
39 // Adder functions
41 std::shared_ptr<SafeNavState> addDualOdometryMeasurementAndReturnNavState(const UnaryMeasurement6D& odometryKm1,
42 const UnaryMeasurement6D& odometryK,
43 const Eigen::Matrix<double, 6, 1>& poseBetweenNoise);
45 void addDualGnssPositionMeasurement(const UnaryMeasurement3D& W_t_W_frame, const Eigen::Vector3d& lastPosition,
46 const Eigen::Vector3d& gnssCovarianceXYZ, const bool attemptGraphSwitching,
47 const bool addedYawBefore);
48
49 // Status
51 const std::lock_guard<std::mutex> swappingActiveGraphLock(swappingActiveGraphMutex_);
52 return activeSmootherPtr_ == globalSmootherPtr_;
53 }
55 const std::lock_guard<std::mutex> swappingActiveGraphLock(swappingActiveGraphMutex_);
56 return activeSmootherPtr_ == fallbackSmootherPtr_; //&& numOptimizationsSinceGraphSwitching_ >= 1;
57 }
58
59 // Graph Manipulation
61
62 protected:
63 // Methods -------------
68 bool isGnssCovarianceViolated_(const Eigen::Vector3d& gnssCovarianceXYZ);
69
72 Eigen::Vector3d W_t_W_Frame1_to_W_t_W_Frame2_(const Eigen::Vector3d& W_t_W_frame1, const std::string& frame1, const std::string& frame2,
73 const Eigen::Matrix3d& R_W_frame2);
74
75 private: // Variables -------------
76 // Factor graph
77 std::shared_ptr<GraphManager> graphMgrPtr_ = nullptr;
78
80 std::vector<std::string> graphNames_{"globalGraph", "fallbackGraph"};
81
82 // Timestamp Maps
83 std::shared_ptr<std::map<gtsam::Key, double>> globalGraphKeysTimestampsMapBufferPtr_;
84 std::shared_ptr<std::map<gtsam::Key, double>> fallbackGraphKeysTimestampsMapBufferPtr_;
85
87 std::shared_ptr<gtsam::IncrementalFixedLagSmoother> activeSmootherPtr_ = globalSmootherPtr_;
88 std::shared_ptr<gtsam::NonlinearFactorGraph> activeFactorsBufferPtr_ = globalFactorsBufferPtr_;
89 std::shared_ptr<gtsam::PreintegratedCombinedMeasurements> activeImuBufferPreintegratorPtr_ = globalImuBufferPreintegratorPtr_;
90 std::shared_ptr<gtsam::Values> activeGraphValuesBufferPtr_ = globalGraphValuesBufferPtr_;
92
93 // Mutex
96};
97
98} // namespace holistic_fusion
99
100#endif // HOLISTIC_FUSION_H
void addDualGnssPositionMeasurement(const UnaryMeasurement3D &W_t_W_frame, const Eigen::Vector3d &lastPosition, const Eigen::Vector3d &gnssCovarianceXYZ, const bool attemptGraphSwitching, const bool addedYawBefore)
No return.
std::shared_ptr< std::map< gtsam::Key, double > > globalGraphKeysTimestampsMapBufferPtr_
void optimizeGraph_()
Worker functions / Updating the factor graph.
std::vector< std::string > graphNames_
Graph names.
void activateGlobalGraph(const gtsam::Vector3 &imuPosition, const gtsam::Rot3 &imuRotation, const double measurementTime)
bool isGnssCovarianceViolated_(const Eigen::Vector3d &gnssCovarianceXYZ)
std::shared_ptr< std::map< gtsam::Key, double > > fallbackGraphKeysTimestampsMapBufferPtr_
std::shared_ptr< SafeNavState > addDualOdometryMeasurementAndReturnNavState(const UnaryMeasurement6D &odometryKm1, const UnaryMeasurement6D &odometryK, const Eigen::Matrix< double, 6, 1 > &poseBetweenNoise)
Return.
std::shared_ptr< gtsam::PreintegratedCombinedMeasurements > activeImuBufferPreintegratorPtr_
std::shared_ptr< gtsam::IncrementalFixedLagSmoother > activeSmootherPtr_
Selector.
std::shared_ptr< GraphManager > graphMgrPtr_
Eigen::Vector3d W_t_W_Frame1_to_W_t_W_Frame2_(const Eigen::Vector3d &W_t_W_frame1, const std::string &frame1, const std::string &frame2, const Eigen::Matrix3d &R_W_frame2)
Utility functions / Geometric transformation to IMU in world frame.
std::shared_ptr< gtsam::Values > activeGraphValuesBufferPtr_
std::shared_ptr< std::map< gtsam::Key, double > > activeGraphKeysTimestampsMapBufferPtr_
std::shared_ptr< gtsam::NonlinearFactorGraph > activeFactorsBufferPtr_
HolisticFusion()
Constructor --------—.