My Project 1.0
Holistic Fusion: A Generic Framework for Multimodal Sensor Fusion
Loading...
Searching...
No Matches
OptimizerBase.h
Go to the documentation of this file.
1/*
2Copyright 2024 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 OPTIMIZER_BASE_HPP
9#define OPTIMIZER_BASE_HPP
10
11// GTSAM
12#include <gtsam/navigation/ImuBias.h>
13#include <gtsam/nonlinear/ISAM2Result.h>
14#include <gtsam/nonlinear/FixedLagSmoother.h>
15#include <gtsam/geometry/Pose3.h>
16
17// Workspace
19
20namespace holistic_fusion {
21
23 public:
24 // Constructior and Destructor
25 explicit OptimizerBase(const std::shared_ptr<GraphConfig> graphConfigPtr) : graphConfigPtr_(graphConfigPtr) {}
26 ~OptimizerBase() = default;
27
28 // Virtual function to be implemented by derived classes
29 // Add factors
30 virtual bool update() = 0;
31 virtual bool update(const gtsam::NonlinearFactorGraph& newGraphFactors, const gtsam::Values& newGraphValues,
32 const std::map<gtsam::Key, double>& newGraphKeysTimeStampMap, const int depth = 0) = 0;
33 virtual bool updateExistingValues(const gtsam::Values& newGraphValues) = 0;
34 // Run (Batch) Optimization and get result
35 virtual void optimize(int maxIterations) = 0;
36 virtual const gtsam::Values& getAllOptimizedStates() = 0;
37 virtual gtsam::KeyVector getAllOptimizedKeys() = 0;
38 virtual const gtsam::NonlinearFactorGraph& getNonlinearFactorGraph() const = 0;
39 // Get keyTimestampMap
40 virtual const std::map<gtsam::Key, double>& getFullKeyTimestampMap() = 0;
41
42 // Calculate State at Key
43 virtual gtsam::Pose3 calculateEstimatedPose3(const gtsam::Key& key) = 0;
44 virtual gtsam::Vector3 calculateEstimatedVelocity3(const gtsam::Key& key) = 0;
45 virtual gtsam::imuBias::ConstantBias calculateEstimatedBias(const gtsam::Key& key) = 0;
46 virtual gtsam::Point3 calculateEstimatedPoint3(const gtsam::Key& key) = 0;
47 virtual gtsam::Vector calculateEstimatedVector(const gtsam::Key& key) = 0;
48
49 // Marginal Covariance
50 virtual gtsam::Matrix calculateMarginalCovarianceMatrixAtKey(const gtsam::Key& key) = 0;
51
52 // Add latest IMU bias before optimization
53 virtual void addLatestImuBiasBelief(const gtsam::imuBias::ConstantBias& imuBias) {
54 latestImuBias_ = imuBias;
55 }
56
57 // Add latest pose before optimization
58 virtual void addLatestPoseBelief(const gtsam::Pose3& pose) {
59 latestPose_ = pose;
60 }
61
62 protected:
63 // Config
64 std::shared_ptr<GraphConfig> graphConfigPtr_;
65
66 // Latest IMU bias
67 gtsam::imuBias::ConstantBias latestImuBias_;
68 gtsam::Pose3 latestPose_;
69};
70
71} // namespace holistic_fusion
72
73#endif // OPTIMIZER_BASE_HPP
virtual const std::map< gtsam::Key, double > & getFullKeyTimestampMap()=0
virtual gtsam::imuBias::ConstantBias calculateEstimatedBias(const gtsam::Key &key)=0
virtual void addLatestPoseBelief(const gtsam::Pose3 &pose)
std::shared_ptr< GraphConfig > graphConfigPtr_
OptimizerBase(const std::shared_ptr< GraphConfig > graphConfigPtr)
virtual gtsam::Vector3 calculateEstimatedVelocity3(const gtsam::Key &key)=0
virtual bool updateExistingValues(const gtsam::Values &newGraphValues)=0
virtual gtsam::Point3 calculateEstimatedPoint3(const gtsam::Key &key)=0
virtual gtsam::Matrix calculateMarginalCovarianceMatrixAtKey(const gtsam::Key &key)=0
virtual void addLatestImuBiasBelief(const gtsam::imuBias::ConstantBias &imuBias)
virtual gtsam::KeyVector getAllOptimizedKeys()=0
virtual const gtsam::NonlinearFactorGraph & getNonlinearFactorGraph() const =0
virtual bool update(const gtsam::NonlinearFactorGraph &newGraphFactors, const gtsam::Values &newGraphValues, const std::map< gtsam::Key, double > &newGraphKeysTimeStampMap, const int depth=0)=0
virtual gtsam::Pose3 calculateEstimatedPose3(const gtsam::Key &key)=0
virtual const gtsam::Values & getAllOptimizedStates()=0
gtsam::imuBias::ConstantBias latestImuBias_
virtual void optimize(int maxIterations)=0
virtual gtsam::Vector calculateEstimatedVector(const gtsam::Key &key)=0