MSCEqF 1.0
Multi State Constraint Equivariant Filter for visual inertial navigation
Loading...
Searching...
No Matches
state_elements.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_ELEMENTS_HPP
13#define STATE_ELEMENTS_HPP
14
15#include <memory>
16
17#include "types/fptypes.hpp"
18
19namespace msceqf
20{
28enum class MSCEqFStateElementName
29{
30 Dd,
31 E,
32 L,
33};
34
45{
46 public:
47 virtual ~MSCEqFStateElement() = default;
48
54 [[nodiscard]] const uint& getIndex() { return idx_; }
55
61 [[nodiscard]] const uint& getDof() { return dof_; }
62
68 void updateIndex(const uint& new_idx) { idx_ = new_idx; }
69
75 virtual void updateRight(const VectorX& delta) = 0;
76
82 virtual void updateLeft(const VectorX& delta) = 0;
83
89 virtual std::unique_ptr<MSCEqFStateElement> clone() const = 0;
90
91 protected:
94 MSCEqFStateElement(const MSCEqFStateElement&) = default;
96 MSCEqFStateElement& operator=(const MSCEqFStateElement&) = default;
97 MSCEqFStateElement& operator=(MSCEqFStateElement&&) = default;
98
105 MSCEqFStateElement(const uint& idx, const uint& dof) : idx_(idx), dof_(dof){};
106
107 uint idx_;
108 uint dof_;
109};
110
116{
121 MSCEqFSDBState() = delete;
122
128 MSCEqFSDBState(const uint& idx) : MSCEqFStateElement(idx, 15), Dd_(){};
129
135 void updateRight(const VectorX& delta) override { Dd_.multiplyRight(SDB::exp(delta)); }
136
142 void updateLeft(const VectorX& delta) override { Dd_.multiplyLeft(SDB::exp(delta)); }
143
149 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFSDBState>(*this); }
150
151 SDB Dd_;
152};
153
159{
164 MSCEqFSE3State() = delete;
165
171 MSCEqFSE3State(const uint& idx) : MSCEqFStateElement(idx, 6), E_(){};
172
178 void updateRight(const VectorX& delta) override { E_.multiplyRight(SE3::exp(delta)); }
179
185 void updateLeft(const VectorX& delta) override { E_.multiplyLeft(SE3::exp(delta)); }
186
192 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFSE3State>(*this); }
193
194 SE3 E_;
195};
196
202{
207 MSCEqFInState() = delete;
208
214 MSCEqFInState(const uint& idx) : MSCEqFStateElement(idx, 4), L_(){};
215
221 void updateRight(const VectorX& delta) override { L_.multiplyRight(In::exp(delta)); }
222
228 void updateLeft(const VectorX& delta) override { L_.multiplyLeft(In::exp(delta)); }
229
235 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFInState>(*this); }
236
237 In L_;
238};
239
245{
250 MSCEqFSOT3State() = delete;
251
257 MSCEqFSOT3State(const uint& idx) : MSCEqFStateElement(idx, 4), Q_(){};
258
264 void updateRight(const VectorX& delta) override { Q_.multiplyRight(SOT3::exp(delta)); }
265
271 void updateLeft(const VectorX& delta) override { Q_.multiplyLeft(SOT3::exp(delta)); }
272
278 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFSOT3State>(*this); }
279
280 SOT3 Q_;
281};
282
283using MSCEqFStateElementSharedPtr = std::shared_ptr<MSCEqFStateElement>;
284using MSCEqFStateElementUniquePtr = std::unique_ptr<MSCEqFStateElement>;
285using MSCEqFSDBStateSharedPtr = std::shared_ptr<MSCEqFSDBState>;
286using MSCEqFSDBStateUniquePtr = std::unique_ptr<MSCEqFSDBState>;
287using MSCEqFSE3StateSharedPtr = std::shared_ptr<MSCEqFSE3State>;
288using MSCEqFSE3StateUniquePtr = std::unique_ptr<MSCEqFSE3State>;
289using MSCEqFInStateSharedPtr = std::shared_ptr<MSCEqFInState>;
290using MSCEqFInStateUniquePtr = std::unique_ptr<MSCEqFInState>;
291using MSCEqFSOT3StateSharedPtr = std::shared_ptr<MSCEqFSOT3State>;
292using MSCEqFSOT3StateUniquePtr = std::unique_ptr<MSCEqFSOT3State>;
293
301template <typename T>
302[[nodiscard]] static MSCEqFStateElementUniquePtr createMSCEqFStateElement(const uint& idx)
303{
304 if constexpr (std::is_base_of_v<MSCEqFStateElement, T>)
305 {
306 return std::make_unique<T>(idx);
307 }
308 else
309 {
310 return nullptr;
311 }
312}
313
314} // namespace msceqf
315
316#endif // STATE_ELEMENTS_HPP
This class represent the base class for a general element of the MSCEqF state. This include the index...
Definition state_elements.hpp:45
uint idx_
Starting index of the element in the residual, and in the covariance.
Definition state_elements.hpp:107
virtual std::unique_ptr< MSCEqFStateElement > clone() const =0
Clone.
void updateIndex(const uint &new_idx)
Update index.
Definition state_elements.hpp:68
const uint & getIndex()
Get the starting index of the state element in the residual, and in the covariance.
Definition state_elements.hpp:54
virtual void updateRight(const VectorX &delta)=0
update function to update the value of the state element by right multiplication
const uint & getDof()
Get the degrees of freedom of the state element (dimension of relative covariance and residual block)
Definition state_elements.hpp:61
MSCEqFStateElement()=delete
Rule of Five.
virtual void updateLeft(const VectorX &delta)=0
update function to update the value of the state element by left multiplication
uint dof_
Degrees of freedom of the element (dimension of relative covariance and residual block)
Definition state_elements.hpp:108
MSCEqFStateElement(const uint &idx, const uint &dof)
Construct a MSCEqFStateElement object.
Definition state_elements.hpp:105
This struct represent the Intrinsic state of the MSCEqF.
Definition state_elements.hpp:202
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Special Intrinsic (In) element of state of the MSCEqF.
Definition state_elements.hpp:235
MSCEqFInState(const uint &idx)
Construct an identity MSCEqFInState object.
Definition state_elements.hpp:214
In L_
The Intrinsic element of the state.
Definition state_elements.hpp:237
void updateLeft(const VectorX &delta) override
Update the Intrinsic element of the state by left multiplication.
Definition state_elements.hpp:228
MSCEqFInState()=delete
Deleted default constructor.
void updateRight(const VectorX &delta) override
Update the Intrinsic element of the state by right multiplication.
Definition state_elements.hpp:221
This struct represent the Semi Direct bias state of the MSCEqF.
Definition state_elements.hpp:116
void updateRight(const VectorX &delta) override
Update the Semi Direct Bias element of the state by right multiplication.
Definition state_elements.hpp:135
MSCEqFSDBState(const uint &idx)
Construct an identity MSCEqFSDBState object.
Definition state_elements.hpp:128
SDB Dd_
The Semi Direct Bias element of the state.
Definition state_elements.hpp:151
void updateLeft(const VectorX &delta) override
Update the Semi Direct Bias element of the state by left multiplication.
Definition state_elements.hpp:142
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Semi Direct bias (SDB) element of state of the MSCEqF.
Definition state_elements.hpp:149
MSCEqFSDBState()=delete
Deleted default constructor.
This struct represent the Special Euclidean Group of dimension 3 state of the MSCEqF.
Definition state_elements.hpp:159
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Special Euclidean Group (SE3) element of state of the MSCEqF.
Definition state_elements.hpp:192
MSCEqFSE3State(const uint &idx)
Construct an identity MSCEqFSE3State object.
Definition state_elements.hpp:171
MSCEqFSE3State()=delete
Deleted default constructor.
void updateLeft(const VectorX &delta) override
Update the Special Euclidean Group element of the state by left multiplication.
Definition state_elements.hpp:185
SE3 E_
The Special Euclidean element of the state.
Definition state_elements.hpp:194
void updateRight(const VectorX &delta) override
Update the Special Euclidean Group element of the state by right multiplication.
Definition state_elements.hpp:178
This struct represent the Scaled Orthogonal Transforms state of the MSCEqF.
Definition state_elements.hpp:245
MSCEqFSOT3State()=delete
Deleted default constructor.
MSCEqFSOT3State(const uint &idx)
Construct an identity MSCEqFSOT3State object.
Definition state_elements.hpp:257
void updateLeft(const VectorX &delta) override
Update the Scaled Orthogonal Transforms element of the state by left multiplication.
Definition state_elements.hpp:271
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Scaled Orthogonal Transforms (SOT3) element of state of the MSCEqF.
Definition state_elements.hpp:278
void updateRight(const VectorX &delta) override
Update the Scaled Orthogonal Transforms element of the state by right multiplication.
Definition state_elements.hpp:264
SOT3 Q_
The Scaled Orthogonal Transforms element of the state.
Definition state_elements.hpp:280