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 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_ELEMENTS_HPP
21#define STATE_ELEMENTS_HPP
22
23#include <memory>
24
25#include "types/fptypes.hpp"
26
27namespace msceqf
28{
36enum class MSCEqFStateElementName
37{
38 Dd,
39 E,
40 L,
41};
42
53{
54 public:
55 virtual ~MSCEqFStateElement() = default;
56
62 [[nodiscard]] const uint& getIndex() { return idx_; }
63
69 [[nodiscard]] const uint& getDof() { return dof_; }
70
76 void updateIndex(const uint& new_idx) { idx_ = new_idx; }
77
83 virtual void updateRight(const VectorX& delta) = 0;
84
90 virtual void updateLeft(const VectorX& delta) = 0;
91
97 virtual std::unique_ptr<MSCEqFStateElement> clone() const = 0;
98
99 protected:
102 MSCEqFStateElement(const MSCEqFStateElement&) = default;
104 MSCEqFStateElement& operator=(const MSCEqFStateElement&) = default;
105 MSCEqFStateElement& operator=(MSCEqFStateElement&&) = default;
106
113 MSCEqFStateElement(const uint& idx, const uint& dof) : idx_(idx), dof_(dof){};
114
115 uint idx_;
116 uint dof_;
117};
118
124{
129 MSCEqFSDBState() = delete;
130
136 MSCEqFSDBState(const uint& idx) : MSCEqFStateElement(idx, 15), Dd_(){};
137
143 void updateRight(const VectorX& delta) override { Dd_.multiplyRight(SDB::exp(delta)); }
144
150 void updateLeft(const VectorX& delta) override { Dd_.multiplyLeft(SDB::exp(delta)); }
151
157 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFSDBState>(*this); }
158
159 SDB Dd_;
160};
161
167{
172 MSCEqFSE3State() = delete;
173
179 MSCEqFSE3State(const uint& idx) : MSCEqFStateElement(idx, 6), E_(){};
180
186 void updateRight(const VectorX& delta) override { E_.multiplyRight(SE3::exp(delta)); }
187
193 void updateLeft(const VectorX& delta) override { E_.multiplyLeft(SE3::exp(delta)); }
194
200 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFSE3State>(*this); }
201
202 SE3 E_;
203};
204
210{
215 MSCEqFInState() = delete;
216
222 MSCEqFInState(const uint& idx) : MSCEqFStateElement(idx, 4), L_(){};
223
229 void updateRight(const VectorX& delta) override { L_.multiplyRight(In::exp(delta)); }
230
236 void updateLeft(const VectorX& delta) override { L_.multiplyLeft(In::exp(delta)); }
237
243 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFInState>(*this); }
244
245 In L_;
246};
247
253{
258 MSCEqFSOT3State() = delete;
259
265 MSCEqFSOT3State(const uint& idx) : MSCEqFStateElement(idx, 4), Q_(){};
266
272 void updateRight(const VectorX& delta) override { Q_.multiplyRight(SOT3::exp(delta)); }
273
279 void updateLeft(const VectorX& delta) override { Q_.multiplyLeft(SOT3::exp(delta)); }
280
286 std::unique_ptr<MSCEqFStateElement> clone() const override { return std::make_unique<MSCEqFSOT3State>(*this); }
287
288 SOT3 Q_;
289};
290
291using MSCEqFStateElementSharedPtr = std::shared_ptr<MSCEqFStateElement>;
292using MSCEqFStateElementUniquePtr = std::unique_ptr<MSCEqFStateElement>;
293using MSCEqFSDBStateSharedPtr = std::shared_ptr<MSCEqFSDBState>;
294using MSCEqFSDBStateUniquePtr = std::unique_ptr<MSCEqFSDBState>;
295using MSCEqFSE3StateSharedPtr = std::shared_ptr<MSCEqFSE3State>;
296using MSCEqFSE3StateUniquePtr = std::unique_ptr<MSCEqFSE3State>;
297using MSCEqFInStateSharedPtr = std::shared_ptr<MSCEqFInState>;
298using MSCEqFInStateUniquePtr = std::unique_ptr<MSCEqFInState>;
299using MSCEqFSOT3StateSharedPtr = std::shared_ptr<MSCEqFSOT3State>;
300using MSCEqFSOT3StateUniquePtr = std::unique_ptr<MSCEqFSOT3State>;
301
309template <typename T>
310[[nodiscard]] static MSCEqFStateElementUniquePtr createMSCEqFStateElement(const uint& idx)
311{
312 if constexpr (std::is_base_of_v<MSCEqFStateElement, T>)
313 {
314 return std::make_unique<T>(idx);
315 }
316 else
317 {
318 return nullptr;
319 }
320}
321
322} // namespace msceqf
323
324#endif // STATE_ELEMENTS_HPP
uint idx_
Starting index of the element in the residual, and in the covariance.
Definition state_elements.hpp:115
virtual std::unique_ptr< MSCEqFStateElement > clone() const =0
Clone.
void updateIndex(const uint &new_idx)
Update index.
Definition state_elements.hpp:76
const uint & getIndex()
Get the starting index of the state element in the residual, and in the covariance.
Definition state_elements.hpp:62
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:69
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:116
MSCEqFStateElement(const uint &idx, const uint &dof)
Construct a MSCEqFStateElement object.
Definition state_elements.hpp:113
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Special Intrinsic (In) element of state of the MSCEqF.
Definition state_elements.hpp:243
MSCEqFInState(const uint &idx)
Construct an identity MSCEqFInState object.
Definition state_elements.hpp:222
In L_
The Intrinsic element of the state.
Definition state_elements.hpp:245
void updateLeft(const VectorX &delta) override
Update the Intrinsic element of the state by left multiplication.
Definition state_elements.hpp:236
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:229
void updateRight(const VectorX &delta) override
Update the Semi Direct Bias element of the state by right multiplication.
Definition state_elements.hpp:143
MSCEqFSDBState(const uint &idx)
Construct an identity MSCEqFSDBState object.
Definition state_elements.hpp:136
SDB Dd_
The Semi Direct Bias element of the state.
Definition state_elements.hpp:159
void updateLeft(const VectorX &delta) override
Update the Semi Direct Bias element of the state by left multiplication.
Definition state_elements.hpp:150
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Semi Direct bias (SDB) element of state of the MSCEqF.
Definition state_elements.hpp:157
MSCEqFSDBState()=delete
Deleted default constructor.
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Special Euclidean Group (SE3) element of state of the MSCEqF.
Definition state_elements.hpp:200
MSCEqFSE3State(const uint &idx)
Construct an identity MSCEqFSE3State object.
Definition state_elements.hpp:179
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:193
SE3 E_
The Special Euclidean element of the state.
Definition state_elements.hpp:202
void updateRight(const VectorX &delta) override
Update the Special Euclidean Group element of the state by right multiplication.
Definition state_elements.hpp:186
MSCEqFSOT3State()=delete
Deleted default constructor.
MSCEqFSOT3State(const uint &idx)
Construct an identity MSCEqFSOT3State object.
Definition state_elements.hpp:265
void updateLeft(const VectorX &delta) override
Update the Scaled Orthogonal Transforms element of the state by left multiplication.
Definition state_elements.hpp:279
std::unique_ptr< MSCEqFStateElement > clone() const override
Clone the Scaled Orthogonal Transforms (SOT3) element of state of the MSCEqF.
Definition state_elements.hpp:286
void updateRight(const VectorX &delta) override
Update the Scaled Orthogonal Transforms element of the state by right multiplication.
Definition state_elements.hpp:272
SOT3 Q_
The Scaled Orthogonal Transforms element of the state.
Definition state_elements.hpp:288