Skyward boardcore
Loading...
Searching...
No Matches
NASState.h
Go to the documentation of this file.
1/* Copyright (c) 2022 Skyward Experimental Rocketry
2 * Author: Alberto Nidasio
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
25#include <Eigen/Core>
26#include <reflect.hpp>
27
28namespace Boardcore
29{
30
32{
33 uint64_t timestamp = 0;
34
35 // 13 extended kalman states
36
37 // Position [m]
38 float n = 0;
39 float e = 0;
40 float d = 0;
41
42 // Velocity [m/s]
43 float vn = 0;
44 float ve = 0;
45 float vd = 0;
46
47 // Attitude as quaternion, from body to NED frame
48 float qx = 0;
49 float qy = 0;
50 float qz = 0;
51 float qw = 1;
52
53 // Gyroscope bias
54 float bx = 0;
55 float by = 0;
56 float bz = 0;
57
59
60 NASState(uint64_t timestamp, const Eigen::Matrix<float, 13, 1>& x)
61 : timestamp(timestamp), n(x(0)), e(x(1)), d(x(2)), vn(x(3)), ve(x(4)),
62 vd(x(5)), qx(x(6)), qy(x(7)), qz(x(8)), qw(x(9)), bx(x(10)),
63 by(x(11)), bz(x(12))
64 {
65 }
66
67 Eigen::Matrix<float, 13, 1> getX() const
68 {
69 return Eigen::Matrix<float, 13, 1>(n, e, d, vn, ve, vd, qx, qy, qz, qw,
70 bx, by, bz);
71 }
72 static constexpr auto reflect()
73 {
74 return STRUCT_DEF(NASState,
75 FIELD_DEF(timestamp) FIELD_DEF(n) FIELD_DEF(e)
76 FIELD_DEF(d) FIELD_DEF(vn) FIELD_DEF(ve)
77 FIELD_DEF(vd) FIELD_DEF(qx) FIELD_DEF(qy)
78 FIELD_DEF(qz) FIELD_DEF(qw) FIELD_DEF(bx)
79 FIELD_DEF(by) FIELD_DEF(bz));
80 }
81};
82
83} // namespace Boardcore
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
Eigen::Matrix< float, 13, 1 > getX() const
Definition NASState.h:67
float ve
Velocity East (y)
Definition NASState.h:44
float vn
Velocity North (x)
Definition NASState.h:43
uint64_t timestamp
Definition NASState.h:33
float bz
Gyroscope bias z.
Definition NASState.h:56
NASState(uint64_t timestamp, const Eigen::Matrix< float, 13, 1 > &x)
Definition NASState.h:60
static constexpr auto reflect()
Definition NASState.h:72