Skyward boardcore
Loading...
Searching...
No Matches
VN300.h
Go to the documentation of this file.
1/* Copyright (c) 2023 Skyward Experimental Rocketry
2 * Authors: Lorenzo Cucchi, Fabrizio Monti
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 <sensors/Sensor.h>
27
28#include "VN300Data.h"
29#include "VN300Defs.h"
30
31namespace Boardcore
32{
33
37class VN300 : public Sensor<VN300Data>, public VNCommonSerial
38{
39public:
54 VN300(USART& usart, int userBaudRate, VN300Defs::SampleOptions sampleOption,
55 CRCOptions crc, std::chrono::milliseconds timeout,
56 VN300Defs::AntennaPosition antPosA = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
57 VN300Defs::AntennaPosition antPosB = {1.0, 0.0, 0.0, 0.0, 0.0, 0.0},
58 Eigen::Matrix3f rotMat = Eigen::Matrix3f::Identity());
59
60 bool init() override;
61
62 bool selfTest() override;
63
64protected:
68 VN300Data sampleImpl() override;
69
70private:
78 bool setAntennaA(VN300Defs::AntennaPosition antPos);
79
90 bool setCompassBaseline(VN300Defs::AntennaPosition antPos);
91
100 bool setReferenceFrame(Eigen::Matrix3f rotMat);
101
107 bool setBinaryOutput();
108
114 VN300Data sampleFull();
115
122 VN300Data sampleReduced();
123
132 void buildBinaryDataFull(const VN300Defs::BinaryDataFull& rawData,
133 VN300Data& data, const uint64_t timestamp);
134
143 void buildBinaryDataReduced(const VN300Defs::BinaryDataReduced& rawData,
144 VN300Data& data, const uint64_t timestamp);
145
146 VN300Defs::SampleOptions sampleOption;
147
150 Eigen::Matrix3f rotMat;
151
155 const char* preSampleBin1 = "";
156};
157
158} // namespace Boardcore
Base sensor class with has to be extended by any sensor driver.
Definition Sensor.h:91
Driver for STM32F4 low level USART/UART peripheral.
Definition USART.h:170
Driver class for VN300 IMU.
Definition VN300.h:38
VN300(USART &usart, int userBaudRate, VN300Defs::SampleOptions sampleOption, CRCOptions crc, std::chrono::milliseconds timeout, VN300Defs::AntennaPosition antPosA={0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, VN300Defs::AntennaPosition antPosB={1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, Eigen::Matrix3f rotMat=Eigen::Matrix3f::Identity())
Constructor.
Definition VN300.cpp:31
bool selfTest() override
Check if the sensor is working.
Definition VN300.cpp:144
bool init() override
Initialize the sensor.
Definition VN300.cpp:43
VN300Data sampleImpl() override
Sample action implementation.
Definition VN300.cpp:146
USART & usart
Serial interface that is needed to communicate with the sensor via ASCII codes.
SampleOptions
Sample options (data output packets) available.
Definition VN300Defs.h:210
This file includes all the types the logdecoder script will decode.
Data class for VN300.
Definition VN300Data.h:51
Structure to handle antenna A position units [m].
Definition VN300Defs.h:178