0.2.0
Loading...
Searching...
No Matches
KvhObs.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
13
14#pragma once
15
16#include "ImuObs.hpp"
17#include "uart/protocol/packet.hpp"
18#include <bitset>
19
20namespace NAV
21{
23class KvhObs final : public ImuObs
24{
25 public:
29 KvhObs(const ImuPos& imuPos, uart::protocol::Packet& packet)
30 : ImuObs(imuPos), raw(packet) {}
31
34 explicit KvhObs(const ImuPos& imuPos)
35 : ImuObs(imuPos) {}
36
39 [[nodiscard]] static std::string type()
40 {
41 return "KvhObs";
42 }
43
46 [[nodiscard]] static std::vector<std::string> parentTypes()
47 {
48 return { ImuObs::type() };
49 }
50
52 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors()
53 {
55 desc.emplace_back("Status [bits]");
56 desc.emplace_back("Sequence Number [-]");
57 return desc;
58 }
59
61 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return 22; }
62
64 [[nodiscard]] std::vector<std::string> staticDataDescriptors() const override { return GetStaticDataDescriptors(); }
65
67 [[nodiscard]] size_t staticDescriptorCount() const override { return GetStaticDescriptorCount(); }
68
72 [[nodiscard]] std::optional<double> getValueAt(size_t idx) const override
73 {
75 switch (idx)
76 {
77 case 0: // Time since startup [ns]
78 case 1: // Mag uncomp X [Gauss]
79 case 2: // Mag uncomp Y [Gauss]
80 case 3: // Mag uncomp Z [Gauss]
81 case 4: // Accel uncomp X [m/s^2]
82 case 5: // Accel uncomp Y [m/s^2]
83 case 6: // Accel uncomp Z [m/s^2]
84 case 7: // Gyro uncomp X [rad/s]
85 case 8: // Gyro uncomp Y [rad/s]
86 case 9: // Gyro uncomp Z [rad/s]
87 case 10: // Mag Comp X [Gauss]
88 case 11: // Mag Comp Y [Gauss]
89 case 12: // Mag Comp Z [Gauss]
90 case 13: // Accel Comp X [m/s^2]
91 case 14: // Accel Comp Y [m/s^2]
92 case 15: // Accel Comp Z [m/s^2]
93 case 16: // Gyro Comp X [rad/s]
94 case 17: // Gyro Comp Y [rad/s]
95 case 18: // Gyro Comp Z [rad/s]
96 case 19: // Temperature [°C]
97 return ImuObs::getValueAt(idx);
98 case 20: // Status [bits]
99 return static_cast<double>(status.to_ulong());
100 case 21: // Sequence Number [-]
101 if (sequenceNumber < 128) { return sequenceNumber; }
102 break;
103 default:
104 return std::nullopt;
105 }
106 return std::nullopt;
107 }
108
110 uart::protocol::Packet raw;
111
123 std::bitset<8> status{};
124
126 uint8_t sequenceNumber = UINT8_MAX;
127};
128
129} // namespace NAV
#define INS_ASSERT(_EXPR)
Assert function wrapper.
Definition Assert.h:19
Parent Class for all IMU Observations.
IMU Observation storage class.
Definition ImuObs.hpp:25
static std::string type()
Returns the type of the data class.
Definition ImuObs.hpp:34
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition ImuObs.hpp:47
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition ImuObs.hpp:76
const ImuPos & imuPos
Position and rotation information for conversion from platform to body frame.
Definition ImuObs.hpp:115
IMU Position.
Definition ImuPos.hpp:26
Kvh Observation storage Class.
Definition KvhObs.hpp:24
uart::protocol::Packet raw
Complete message raw binary data including header and checksum.
Definition KvhObs.hpp:110
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition KvhObs.hpp:46
static std::string type()
Returns the type of the data class.
Definition KvhObs.hpp:39
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition KvhObs.hpp:61
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition KvhObs.hpp:52
uint8_t sequenceNumber
Increments for each message and resets to 0 after 127.
Definition KvhObs.hpp:126
KvhObs(const ImuPos &imuPos, uart::protocol::Packet &packet)
Constructor.
Definition KvhObs.hpp:29
std::bitset< 8 > status
Status Byte.
Definition KvhObs.hpp:123
std::vector< std::string > staticDataDescriptors() const override
Returns a vector of data descriptors.
Definition KvhObs.hpp:64
size_t staticDescriptorCount() const override
Get the amount of descriptors.
Definition KvhObs.hpp:67
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition KvhObs.hpp:72
KvhObs(const ImuPos &imuPos)
Constructor.
Definition KvhObs.hpp:34