MSCEqF 1.0
Multi State Constraint Equivariant Filter for visual inertial navigation
Loading...
Searching...
No Matches
system.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_HPP
21#define SYSTEM_HPP
22
23#include <variant>
24
25#include "msceqf/system/system_elements.hpp"
26#include "msceqf/options/msceqf_options.hpp"
27
28namespace msceqf
29{
37{
38 public:
39 using SystemStateKey = std::variant<SystemStateElementName, uint>;
40 using SystemStateMap = std::unordered_map<SystemStateKey, SystemStateElementSharedPtr>;
41 using SystemStateAlgebraMap = std::unordered_map<SystemStateKey, VectorX>;
42
46 SystemState() = delete;
47
56 SystemState(const StateOptions& opts, const SE23& T0 = SE23(), const Vector6& b0 = Vector6::Zero());
57
75 template <typename... Args>
76 SystemState(const StateOptions& opts, Args&&... pairs_of_key_ptr) : opts_(opts), state_()
77 {
78 preallocate();
79
80 insertSystemStateElement(std::make_pair(
81 SystemStateElementName::S,
82 createSystemStateElement<CameraExtrinsicState>(std::make_tuple(opts.initial_camera_extrinsics_))));
83
84 if (opts.enable_camera_intrinsics_calibration_)
85 {
86 insertSystemStateElement(std::make_pair(
87 SystemStateElementName::K,
88 createSystemStateElement<CameraIntrinsicState>(std::make_tuple(opts.initial_camera_intrinsics_))));
89 }
90
91 (insertSystemStateElement(std::forward<decltype(pairs_of_key_ptr)>(pairs_of_key_ptr)), ...);
92 }
93
95 SystemState(const SystemState& other);
96 SystemState(SystemState&& other) noexcept;
97 SystemState& operator=(const SystemState& other);
98 SystemState& operator=(SystemState&& other) noexcept;
100
106 [[nodiscard]] const SE23& T() const;
107
113 [[nodiscard]] const SE3 P() const;
114
120 [[nodiscard]] const SE3 V() const;
121
127 [[nodiscard]] const Vector6& b() const;
128
136 [[nodiscard]] const SE3& S() const;
137
145 [[nodiscard]] const In& K() const;
146
154 [[nodiscard]] const Vector4 k() const;
155
163 [[nodiscard]] const Vector3& f(const uint& feat_id) const;
164
170 [[nodiscard]] const Vector3 ge3() const;
171
177 [[nodiscard]] inline const StateOptions& opts() const { return opts_; }
178
185 static std::string toString(const SystemStateKey& key);
186
187 private:
192 void preallocate();
193
200 void insertSystemStateElement(std::pair<SystemStateKey, SystemStateElementUniquePtr>&& key_ptr);
201
208 void insertSystemStateElement(std::vector<std::pair<SystemStateKey, SystemStateElementUniquePtr>>& keys_ptrs);
209
210 friend class Symmetry;
211
212 StateOptions opts_;
213
214 SystemStateMap state_;
215};
216
217} // namespace msceqf
218
219#endif // SYSTEM_HPP
220
221// [COMMENT] I can use unorderd map as soon as i check for out of order images when getting a image...
std::variant< SystemStateElementName, uint > SystemStateKey
Key to access the system state map.
Definition system.hpp:39
const SE23 & T() const
return a constant reference to the extended pose element (R,v,p) of the system state as a SE23-torsor
friend class Symmetry
Symmetry can access private members of SystemState.
Definition system.hpp:210
std::unordered_map< SystemStateKey, VectorX > SystemStateAlgebraMap
System state algebra map.
Definition system.hpp:41
const StateOptions & opts() const
Get the state options.
Definition system.hpp:177
std::unordered_map< SystemStateKey, SystemStateElementSharedPtr > SystemStateMap
System state map.
Definition system.hpp:40
static std::string toString(const SystemStateKey &key)
Get a string describing the given SystemStateKey.
SystemState(const StateOptions &opts, const SE23 &T0=SE23(), const Vector6 &b0=Vector6::Zero())
Initialize a system state with given extended pose and bias (Identity and zero by default)....
SystemState(const SystemState &other)
Rule of Five.
const SE3 V() const
return a copy of the pose element (R,v) of the system state as a SE3-torsor
const Vector6 & b() const
return a constant reference to the bias element of the system state as a vector
const Vector3 & f(const uint &feat_id) const
return a constant reference to a persistent feature element of the system state as a vector,...
const In & K() const
return a constant reference to the camera intrinsics element of the system state as a In-torsor If th...
SystemState()=delete
Deleted default constructor.
const Vector4 k() const
return a copy of the camera intrinsics element of the system state as a 4-vector If the camera intrin...
SystemState(const StateOptions &opts, Args &&... pairs_of_key_ptr)
Construct system state given a multiple pairs of key-pointer of states element. This methods prealloc...
Definition system.hpp:76
const Vector3 ge3() const
return a copy of g*e3 as a vector
const SE3 & S() const
return a constant reference to the camera extrinsics element of the system state as a SE3-torsor....
const SE3 P() const
return a copy of the pose element (R,p) of the system state as a SE3-torsor
Definition msceqf_options.hpp:106