Skyward boardcore
Loading...
Searching...
No Matches
PropagatorData.h
Go to the documentation of this file.
1/* Copyright (c) 2024 Skyward Experimental Rocketry
2 * Author: Emilio Corigliano
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#pragma once
24
26
27#include <Eigen/Core>
28#include <ostream>
29#include <userde.hpp>
30
31namespace Boardcore
32{
33
41{
42 uint64_t timestamp;
43 uint32_t nPropagations;
45
46 float az = 0;
47 static constexpr float ax = 0,
48 ay = 0;
50
52 NASState nasState)
54 {
55 }
56
57 static constexpr auto reflect()
58 {
59 return STRUCT_DEF(
61 FIELD_DEF(timestamp) FIELD_DEF(nPropagations) FIELD_DEF2(nas, n)
62 FIELD_DEF2(nas, e) FIELD_DEF2(nas, d) FIELD_DEF2(nas, vn)
63 FIELD_DEF2(nas, ve) FIELD_DEF2(nas, vd) FIELD_DEF2(nas, qx)
64 FIELD_DEF2(nas, qy) FIELD_DEF2(nas, qz) FIELD_DEF2(
65 nas, qw) FIELD_DEF2(nas, bx) FIELD_DEF2(nas, by)
66 FIELD_DEF2(nas, bz) FIELD_DEF(az));
67 }
68
69 NASState getNasState() const { return nas; }
70
76 Eigen::Vector3f getPosition()
77 {
78 return Eigen::Vector3f(nas.n, nas.e, nas.d);
79 }
80
84 void setPosition(Eigen::Vector3f xProp)
85 {
86 nas.n = xProp(0);
87 nas.e = xProp(1);
88 nas.d = xProp(2);
89 }
90
96 Eigen::Vector3f getVelocity()
97 {
98 return Eigen::Vector3f(nas.vn, nas.ve, nas.vd);
99 }
100
104 void setVelocity(Eigen::Vector3f vProp)
105 {
106 nas.vn = vProp(0);
107 nas.ve = vProp(1);
108 nas.vd = vProp(2);
109 }
110
114 void setZAcceleration(Eigen::Vector3f acc) { az = acc(2); }
115
121 Eigen::Vector3f getAcceleration() const
122 {
123 Eigen::Vector3f acc;
124 acc(0) = ax;
125 acc(1) = ay;
126 acc(2) = az;
127 return acc;
128 }
129
135 Eigen::Vector4f getQProp()
136 {
137 return Eigen::Vector4f(nas.qx, nas.qy, nas.qz, nas.qw);
138 }
139
143 void setQProp(Eigen::Vector4f qProp)
144 {
145 nas.qx = qProp(0);
146 nas.qy = qProp(1);
147 nas.qz = qProp(2);
148 nas.qw = qProp(3);
149 }
150
156 Eigen::Vector3f getBProp() { return Eigen::Vector3f(nas.n, nas.e, nas.d); }
157
161 void setBProp(Eigen::Vector3f bProp)
162 {
163 nas.bx = bProp(0);
164 nas.by = bProp(1);
165 nas.bz = bProp(2);
166 }
167};
168
169} // namespace Boardcore
170
Driver for the VN100S IMU.
float qz
Quaternion z.
Definition NASState.h:50
float n
North (x)
Definition NASState.h:38
float qx
Quaternion x.
Definition NASState.h:48
float e
East (y)
Definition NASState.h:39
float vd
Velocity Down (z)
Definition NASState.h:45
float d
Down (z)
Definition NASState.h:40
float bx
Gyroscope bias x.
Definition NASState.h:54
float qy
Quaternion y.
Definition NASState.h:49
float qw
Quaternion w.
Definition NASState.h:51
float by
Gyroscope bias y.
Definition NASState.h:55
float ve
Velocity East (y)
Definition NASState.h:44
float vn
Velocity North (x)
Definition NASState.h:43
float bz
Gyroscope bias z.
Definition NASState.h:56
State of the propagator, taking into account the prediction steps (0 if true NAS state) and the propa...
PropagatorState(uint64_t timestamp, uint32_t nPropagations, NASState nasState)
void setBProp(Eigen::Vector3f bProp)
Setter for the vector of quaternions' bias.
NASState getNasState() const
Eigen::Vector3f getVelocity()
Getter for the vector of velocities NED.
Eigen::Vector4f getQProp()
Getter for the vector of quaternions.
void setZAcceleration(Eigen::Vector3f acc)
Setter for the vector acceleration(only z-axis)
Eigen::Vector3f getPosition()
Getter for the vector of positions NED.
void setPosition(Eigen::Vector3f xProp)
Setter for the vector of positions NED.
void setVelocity(Eigen::Vector3f vProp)
Setter for the vector of velocities NED.
static constexpr float ax
static constexpr auto reflect()
Eigen::Vector3f getBProp()
Getter for the vector of quaternions' bias.
uint32_t nPropagations
Predictions from last received NAS state.
void setQProp(Eigen::Vector4f qProp)
Setter for the vector of quaternions.
uint64_t timestamp
Prediction timestamp (ARP timestamp) [ms].
Eigen::Vector3f getAcceleration() const
Getter for the vector acceleration.
static constexpr float ay
only az is used by the propagator