MSCEqF 1.0
Multi State Constraint Equivariant Filter for visual inertial navigation
Loading...
Searching...
No Matches
system_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 SYSTEM_ELEMENTS_HPP
21#define SYSTEM_ELEMENTS_HPP
22
23#include <memory>
24
25#include "types/fptypes.hpp"
26
27namespace msceqf
28{
36enum class SystemStateElementName
37{
38 T,
39 b,
40 S,
41 K,
42};
43
49{
50 public:
51 virtual ~SystemStateElement() = default;
52
58 virtual std::unique_ptr<SystemStateElement> clone() const = 0;
59
60 protected:
62 SystemStateElement() = default;
63 SystemStateElement(const SystemStateElement&) = default;
65 SystemStateElement& operator=(const SystemStateElement&) = default;
66 SystemStateElement& operator=(SystemStateElement&&) = default;
67};
68
73struct ExtendedPoseState final : public SystemStateElement
74{
75 ExtendedPoseState() : T_(){};
76 ExtendedPoseState(const SE23& T) : T_(T){};
77
83 std::unique_ptr<SystemStateElement> clone() const override { return std::make_unique<ExtendedPoseState>(*this); }
84
85 SE23 T_;
86};
87
92struct BiasState final : public SystemStateElement
93{
94 BiasState() : b_(Vector6::Zero()){};
95 BiasState(const Vector6& b) : b_(b){};
96
102 std::unique_ptr<SystemStateElement> clone() const override { return std::make_unique<BiasState>(*this); }
103
104 Vector6 b_;
105};
106
111struct CameraExtrinsicState final : public SystemStateElement
112{
113 CameraExtrinsicState() : S_(){};
114 CameraExtrinsicState(const Quaternion& q, const Vector3& t) : S_(q, {t}){};
115 CameraExtrinsicState(const Matrix3& R, const Vector3& t) : S_(R, {t}){};
116 CameraExtrinsicState(const Matrix4& S) : S_(S){};
117 CameraExtrinsicState(const SE3& S) : S_(S){};
118
124 std::unique_ptr<SystemStateElement> clone() const override { return std::make_unique<CameraExtrinsicState>(*this); }
125
126 SE3 S_;
127};
128
133struct CameraIntrinsicState final : public SystemStateElement
134{
135 CameraIntrinsicState() : K_(){};
136 CameraIntrinsicState(const fp& fx, const fp& fy, const fp& cx, const fp& cy) : K_(fx, fy, cx, cy){};
137 CameraIntrinsicState(const Vector4& intr) : K_(intr){};
138 CameraIntrinsicState(const Matrix3& K) : K_(K){};
139 CameraIntrinsicState(const In& K) : K_(K){};
140
146 std::unique_ptr<SystemStateElement> clone() const override { return std::make_unique<CameraIntrinsicState>(*this); }
147
148 In K_;
149};
150
155struct FeatureState final : public SystemStateElement
156{
157 public:
158 FeatureState() : f_(Vector3::Zero()){};
159 FeatureState(const Vector3& f) : f_(f){};
160 FeatureState(const fp& x, const fp& y, const fp& z) : f_({x, y, z}){};
161
167 std::unique_ptr<SystemStateElement> clone() const override { return std::make_unique<FeatureState>(*this); }
168
169 Vector3 f_;
170};
171
172using SystemStateElementSharedPtr = std::shared_ptr<SystemStateElement>;
173using SystemStateElementUniquePtr = std::unique_ptr<SystemStateElement>;
174using ExtendedPoseStateSharedPtr = std::shared_ptr<ExtendedPoseState>;
175using ExtendedPoseUniquePtr = std::unique_ptr<ExtendedPoseState>;
176using BiasStateStateSharedPtr = std::shared_ptr<BiasState>;
177using BiasStateStateUniquePtr = std::unique_ptr<BiasState>;
178using CameraExtrinsicStateStateSharedPtr = std::shared_ptr<CameraExtrinsicState>;
179using CameraExtrinsicStateStateUniquePtr = std::unique_ptr<CameraExtrinsicState>;
180using CameraIntrinsicStateStateSharedPtr = std::shared_ptr<CameraIntrinsicState>;
181using CameraIntrinsicStateStateUniquePtr = std::unique_ptr<CameraIntrinsicState>;
182using FeatureStateStateStateSharedPtr = std::shared_ptr<FeatureState>;
183using FeatureStateStateStateUniquePtr = std::unique_ptr<FeatureState>;
184
197template <typename T, typename... Args>
198[[nodiscard]] static SystemStateElementUniquePtr createSystemStateElement(const std::tuple<Args...>& args)
199{
200 return std::apply(
201 [](const auto&... args) {
202 if constexpr (std::is_base_of_v<SystemStateElement, T> && std::is_constructible_v<T, decltype(args)...>)
203 {
204 return std::make_unique<T>(args...);
205 }
206 else
207 {
208 return nullptr;
209 }
210 },
211 args);
212}
213
214} // namespace msceqf
215
216#endif // SYSTEM_ELEMENTS_HPP
SystemStateElement()=default
Rule of Five.
virtual std::unique_ptr< SystemStateElement > clone() const =0
Clone.
Vector6 b_
The Inertial Measurement Unit (IMU) biases (bw, ba).
Definition system_elements.hpp:104
std::unique_ptr< SystemStateElement > clone() const override
Clone the bias state element of the system.
Definition system_elements.hpp:102
SE3 S_
The camera extrinsics calibration (SR, St).
Definition system_elements.hpp:126
std::unique_ptr< SystemStateElement > clone() const override
Clone the camera extrinsics state element of the system.
Definition system_elements.hpp:124
std::unique_ptr< SystemStateElement > clone() const override
Clone the camera instirnsic state element of the system.
Definition system_elements.hpp:146
In K_
The camera intrinsics calibration (K).
Definition system_elements.hpp:148
SE23 T_
The extended pose of the system (R, v, p).
Definition system_elements.hpp:85
std::unique_ptr< SystemStateElement > clone() const override
Clone the extended pose state element of the system.
Definition system_elements.hpp:83
Vector3 f_
The persistent feature (f).
Definition system_elements.hpp:169
std::unique_ptr< SystemStateElement > clone() const override
Clone the persistent feature state element of the system.
Definition system_elements.hpp:167