Skyward boardcore
Loading...
Searching...
No Matches
Propagator.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#include <logger/Logger.h>
27#include <miosix.h>
28
29#include <chrono>
30
31#include "PropagatorData.h"
33#include "sensors/SensorData.h"
34
35namespace Boardcore
36{
37
38static constexpr std::chrono::microseconds MAX_PROPAGATION_TIME =
39 std::chrono::seconds(5);
41
42static constexpr std::chrono::microseconds MAX_ACCELERATION_TIME =
43 std::chrono::seconds(5);
45
50class Propagator : public Algorithm
51{
52public:
58 explicit Propagator(std::chrono::milliseconds updatePeriod);
59
64 bool init() override;
65
72 void setRocketNasState(const NASState& newRocketNasState);
73
80 {
81 miosix::Lock<miosix::FastMutex> lock(stateMutex);
82 return state;
83 }
84
85private:
89 void step() override;
90
91 float updatePeriod;
92 PropagatorState state;
93 NASState lastRocketNasState;
94 miosix::FastMutex stateMutex;
95 Eigen::Vector3f
96 last_real_velocity;
97 uint64_t t0 = 0, t1 = 0;
98 uint64_t lastReceivedTime =
99 0;
100};
101
102} // namespace Boardcore
Predictor class that linearly propagates the last available rocket position by means of the rocket NA...
Definition Propagator.h:51
void setRocketNasState(const NASState &newRocketNasState)
Synchronized setter for the latest rocket nas state. Also notifies the predictor of a new packet arri...
bool init() override
Dummy init since we don't have to setup anything.
PropagatorState getState()
Synchronized getter for the State of the predictor.
Definition Propagator.h:79
Driver for the VN100S IMU.
State of the propagator, taking into account the prediction steps (0 if true NAS state) and the propa...