MSCEqF 1.0
Multi State Constraint Equivariant Filter for visual inertial navigation
Loading...
Searching...
No Matches
state.hpp
1// Copyright (C) 2023 Alessandro Fornasier.
2// Control of Networked Systems, University of Klagenfurt, Austria.
3//
4// All rights reserved.
5//
6// This software is licensed under the terms of the BSD-2-Clause-License with
7// no commercial use allowed, the full terms of which are made available
8// in the LICENSE file. No license in patents is granted.
9//
10// You can contact the authors at <alessandro.fornasier@ieee.org>
11
12#ifndef STATE_HPP
13#define STATE_HPP
14
15#include <map>
16#include <variant>
17
18#include "msceqf/system/system.hpp"
19#include "msceqf/options/msceqf_options.hpp"
20#include "msceqf/state/state_elements.hpp"
21
22namespace msceqf
23{
30{
31 public:
32 using MSCEqFStateKey = std::variant<MSCEqFStateElementName, uint>;
33 using MSCEqFKey = std::variant<MSCEqFStateKey, fp>;
34
35 using MSCEqFStateMap = std::unordered_map<MSCEqFStateKey, MSCEqFStateElementSharedPtr>;
36 using MSCEqFClonesMap = std::map<fp, MSCEqFStateElementSharedPtr>;
37
41 MSCEqFState() = delete;
42
54
56 MSCEqFState(const MSCEqFState& other);
57 MSCEqFState(MSCEqFState&& other) noexcept;
58 MSCEqFState& operator=(const MSCEqFState& other);
59 MSCEqFState& operator=(MSCEqFState&& other) noexcept;
61
69 [[nodiscard]] const SE23& D() const;
70
79 [[nodiscard]] const SE3 B() const;
80
89 [[nodiscard]] const SE3 C() const;
90
98 [[nodiscard]] const Vector6& delta() const;
99
107 [[nodiscard]] const SE3& E() const;
108
116 [[nodiscard]] const In& L() const;
117
126 [[nodiscard]] const SOT3& Q(const uint& feat_id) const;
127
136 [[nodiscard]] const SE3& clone(const fp& timestamp) const;
137
144 [[nodiscard]] const uint& index(const MSCEqFKey& key) const;
145
152 [[nodiscard]] const uint& dof(const MSCEqFKey& key) const;
153
159 [[nodiscard]] inline size_t clonesSize() const { return clones_.size(); }
160
167 [[nodiscard]] const fp& cloneTimestampToMarginalize() const;
168
174 [[nodiscard]] const MatrixX& cov() const;
175
183 [[nodiscard]] const MatrixX covBlock(const MSCEqFKey& key) const;
184
193 [[nodiscard]] const MatrixX subCov(const std::vector<MSCEqFKey>& keys) const;
194
203 [[nodiscard]] const MatrixX subCovCols(const std::vector<MSCEqFKey>& keys) const;
204
210 [[nodiscard]] inline const StateOptions& opts() const { return opts_; }
211
221 void initializeStateElement(const MSCEqFStateKey& key, const MatrixX& cov_block);
222
229 void stochasticCloning(const fp& timestamp);
230
236 void marginalizeCloneAt(const fp& timestamp);
237
244 static std::string toString(const MSCEqFStateKey& key);
245
256 [[nodiscard]] const MSCEqFState Random() const;
257
268 [[nodiscard]] const MSCEqFState operator*(const MSCEqFState& other) const;
269
270 private:
274 void preallocate();
275
283 [[nodiscard]] bool insertStateElement(const MSCEqFStateKey& key, MSCEqFStateElementUniquePtr ptr);
284
292 [[nodiscard]] bool insertCloneElement(const fp& timestamp, MSCEqFStateElementUniquePtr ptr);
293
300 [[nodiscard]] const MSCEqFStateElementSharedPtr& getPtr(const MSCEqFKey& key) const;
301
302 friend class Symmetry;
303 friend class Propagator;
304 friend class Updater;
305 friend class ZeroVelocityUpdater;
306
307 StateOptions opts_;
308
309 MatrixX cov_;
310 MSCEqFStateMap state_;
311 MSCEqFClonesMap clones_;
312};
313
314} // namespace msceqf
315
316#endif // STATE_HPP
this class represent the state of the MSCEqF. This includes the state of the lifted system (element o...
Definition state.hpp:30
const SE3 C() const
Get a copy of to the SE3 component of the Semi Direct Bias Group element of the MSCEqF state that inc...
std::variant< MSCEqFStateElementName, uint > MSCEqFStateKey
Key to access the msceqf state map.
Definition state.hpp:32
const MatrixX & cov() const
Get a reference to the covariance matrix.
std::unordered_map< MSCEqFStateKey, MSCEqFStateElementSharedPtr > MSCEqFStateMap
MSCEqF state map.
Definition state.hpp:35
const In & L() const
Get a reference to the In element of the MSCEqF state.
const SE3 B() const
Get a copy of the SE3 component of the Semi Direct Bias Group element of the MSCEqF state that includ...
const MSCEqFState operator*(const MSCEqFState &other) const
operator* overloading for MSCEqFState. This function will perform the composition this * other for ea...
const uint & index(const MSCEqFKey &key) const
Get a reference to the index of the state element or the clone element corresponding to the given key...
const MSCEqFState Random() const
Return a random MSCEqF state without changing this. This method *WILL NOT change the actual values of...
void stochasticCloning(const fp &timestamp)
Augment the MSCEqF clones map with a new clone of the actual E element of the MSCEqF state....
const MatrixX subCovCols(const std::vector< MSCEqFKey > &keys) const
Get a constant copy of the the covariance submatrix (including cross-correlations) constructed with c...
const SE3 & E() const
Get a reference to the SE3 element of the MSCEqF state.
MSCEqFState(const StateOptions &opts, const SystemState &xi0)
Construct the state of the MSCEqF given the options.
const StateOptions & opts() const
Get the state options.
Definition state.hpp:210
const uint & dof(const MSCEqFKey &key) const
Get a reference to the dof of the state element or the clone element corresponding to the given key.
std::variant< MSCEqFStateKey, fp > MSCEqFKey
Key to access the msceqf state and clones map.
Definition state.hpp:33
const SOT3 & Q(const uint &feat_id) const
Get a reference to the SOT3 element of the MSCEqF state that correspond to the given feature id.
const SE23 & D() const
Get a reference to the SE23 component of the Semi Direct Bias Group element of the MSCEqF state.
const MatrixX covBlock(const MSCEqFKey &key) const
get a constant copy of the covariance block relative to the elements (states or clones) corresponding...
const SE3 & clone(const fp &timestamp) const
Get a reference to the SE3 element of the MSCEqF clones that correspond to the given timestamp.
MSCEqFState(const MSCEqFState &other)
Rule of Five.
void initializeStateElement(const MSCEqFStateKey &key, const MatrixX &cov_block)
Initialize MSCEqF state element into the state map, and the relative covariance block.
const Vector6 & delta() const
Get a reference to the R6 component of the Semi Direct Bias Group element of the MSCEqF state.
void marginalizeCloneAt(const fp &timestamp)
Marginalize out clone at a given timestamp.
std::map< fp, MSCEqFStateElementSharedPtr > MSCEqFClonesMap
MSCEqF clones map.
Definition state.hpp:36
const fp & cloneTimestampToMarginalize() const
Get the timestamp of the clone to marginalize. We implement our keyframing strategy here....
const MatrixX subCov(const std::vector< MSCEqFKey > &keys) const
Get a constant copy of the the covariance submatrix (including cross-correlations) constructed with c...
size_t clonesSize() const
Get the amount of clones.
Definition state.hpp:159
static std::string toString(const MSCEqFStateKey &key)
Get a string describing the given MSCEqFStateKey.
MSCEqFState()=delete
Deleted default constructor.
Definition propagator.hpp:25
Definition symmetry.hpp:23
The SystemState class represent the state of the system posed on the Homogenous space.
Definition system.hpp:29
Updater class. This class implements the Multi State Constraint update step of the MSCEqF filter.
Definition updater.hpp:30
Zero velocity updater class. This class implements the Equivariant Zero Velocity Update (ZVU) of the ...
Definition zero_velocity_updater.hpp:26
Definition msceqf_options.hpp:98