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 Apache License, Version 2.0
7// (the "License"); you may not use this file except in compliance with the
8// License. You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15// License for the specific language governing permissions and limitations
16// under the License.
17//
18// You can contact the authors at <alessandro.fornasier@ieee.org>
19
20#ifndef STATE_HPP
21#define STATE_HPP
22
23#include <map>
24#include <variant>
25
26#include "msceqf/system/system.hpp"
27#include "msceqf/options/msceqf_options.hpp"
28#include "msceqf/state/state_elements.hpp"
29
30namespace msceqf
31{
38{
39 public:
40 using MSCEqFStateKey = std::variant<MSCEqFStateElementName, uint>;
41 using MSCEqFKey = std::variant<MSCEqFStateKey, fp>;
42
43 using MSCEqFStateMap = std::unordered_map<MSCEqFStateKey, MSCEqFStateElementSharedPtr>;
44 using MSCEqFClonesMap = std::map<fp, MSCEqFStateElementSharedPtr>;
45
49 MSCEqFState() = delete;
50
62
64 MSCEqFState(const MSCEqFState& other);
65 MSCEqFState(MSCEqFState&& other) noexcept;
66 MSCEqFState& operator=(const MSCEqFState& other);
67 MSCEqFState& operator=(MSCEqFState&& other) noexcept;
69
77 [[nodiscard]] const SE23& D() const;
78
87 [[nodiscard]] const SE3 B() const;
88
97 [[nodiscard]] const SE3 C() const;
98
106 [[nodiscard]] const Vector6& delta() const;
107
115 [[nodiscard]] const SE3& E() const;
116
124 [[nodiscard]] const In& L() const;
125
134 [[nodiscard]] const SOT3& Q(const uint& feat_id) const;
135
144 [[nodiscard]] const SE3& clone(const fp& timestamp) const;
145
152 [[nodiscard]] const uint& index(const MSCEqFKey& key) const;
153
160 [[nodiscard]] const uint& dof(const MSCEqFKey& key) const;
161
167 [[nodiscard]] inline size_t clonesSize() const { return clones_.size(); }
168
175 [[nodiscard]] const fp& cloneTimestampToMarginalize() const;
176
182 [[nodiscard]] const MatrixX& cov() const;
183
191 [[nodiscard]] const MatrixX covBlock(const MSCEqFKey& key) const;
192
201 [[nodiscard]] const MatrixX subCov(const std::vector<MSCEqFKey>& keys) const;
202
211 [[nodiscard]] const MatrixX subCovCols(const std::vector<MSCEqFKey>& keys) const;
212
218 [[nodiscard]] inline const StateOptions& opts() const { return opts_; }
219
229 void initializeStateElement(const MSCEqFStateKey& key, const MatrixX& cov_block);
230
237 void stochasticCloning(const fp& timestamp);
238
244 void marginalizeCloneAt(const fp& timestamp);
245
252 static std::string toString(const MSCEqFStateKey& key);
253
264 [[nodiscard]] const MSCEqFState Random() const;
265
276 [[nodiscard]] const MSCEqFState operator*(const MSCEqFState& other) const;
277
278 private:
282 void preallocate();
283
291 [[nodiscard]] bool insertStateElement(const MSCEqFStateKey& key, MSCEqFStateElementUniquePtr ptr);
292
300 [[nodiscard]] bool insertCloneElement(const fp& timestamp, MSCEqFStateElementUniquePtr ptr);
301
308 [[nodiscard]] const MSCEqFStateElementSharedPtr& getPtr(const MSCEqFKey& key) const;
309
310 friend class Symmetry;
311 friend class Propagator;
312 friend class Updater;
313 friend class ZeroVelocityUpdater;
314
315 StateOptions opts_;
316
317 MatrixX cov_;
318 MSCEqFStateMap state_;
319 MSCEqFClonesMap clones_;
320};
321
322} // namespace msceqf
323
324#endif // STATE_HPP
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:40
const MatrixX & cov() const
Get a reference to the covariance matrix.
std::unordered_map< MSCEqFStateKey, MSCEqFStateElementSharedPtr > MSCEqFStateMap
MSCEqF state map.
Definition state.hpp:43
const In & L() const
Get a reference to the In element of the MSCEqF state.
friend class Updater
Updater can access private members of MSCEqFState.
Definition state.hpp:312
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....
friend class Symmetry
Symmetry can access private members of MSCEqFState.
Definition state.hpp:310
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:218
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:41
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.
friend class Propagator
Propagator can access private members of MSCEqFState.
Definition state.hpp:311
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:44
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...
friend class ZeroVelocityUpdater
Zero velocity updater can access private members of MSCEqFState.
Definition state.hpp:313
size_t clonesSize() const
Get the amount of clones.
Definition state.hpp:167
static std::string toString(const MSCEqFStateKey &key)
Get a string describing the given MSCEqFStateKey.
MSCEqFState()=delete
Deleted default constructor.
The SystemState class represent the state of the system posed on the Homogenous space.
Definition system.hpp:37
Definition msceqf_options.hpp:106