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
81 {
82 miosix::Lock<miosix::FastMutex> lock(nasStateMutex);
83 return lastRocketNasState;
84 }
85
92 {
93 miosix::Lock<miosix::FastMutex> lock(stateMutex);
94 return state;
95 }
96
97private:
101 void step() override;
102
103 float updatePeriod;
104 PropagatorState state;
105 NASState lastRocketNasState;
106 miosix::FastMutex nasStateMutex;
107 miosix::FastMutex stateMutex;
108 Eigen::Vector3f
109 last_real_velocity;
110 uint64_t t0 = 0, t1 = 0;
111 uint64_t lastReceivedTime =
112 0;
113};
114
115} // namespace Boardcore
Predictor class that linearly propagates the last available rocket position by means of the rocket NA...
Definition Propagator.h:51
NASState getRocketNasState()
Synchronized getter for the last rocket NAS State passed to the propagator.
Definition Propagator.h:80
void setRocketNasState(const NASState &newRocketNasState)
Synchronized setter for the latest rocket nas state. Also notifies the predictor of a new packet arri...
Propagator(std::chrono::milliseconds updatePeriod)
Constructor of the propagator class.
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:91
This file includes all the types the logdecoder script will decode.
State of the propagator, taking into account the prediction steps (0 if true NAS state) and the propa...