41 std::function<
void(
float)> setActuator)
42 : getCurrentPosition(getCurrentPosition), setActuator(setActuator),
43 trajectoryOpenSet(trajectoryOpenSet),
44 trajectoryCloseSet(trajectoryCloseSet), configInterp(configInterp)
56 if (configInterp.
DM == 0)
59 choosenOpenTrajectory = &trajectoryOpenSet.
trajectories[0];
60 choosenCloseTrajectory = &trajectoryCloseSet.
trajectories[0];
65 round((currentMass - configInterp.
INITIAL_MASS) / configInterp.
DM);
68 index = std::max(index, 0);
69 uint32_t boundedIndex = std::min(
static_cast<uint32_t
>(index),
70 trajectoryOpenSet.
length() - 1);
72 choosenOpenTrajectory = &trajectoryOpenSet.
trajectories[boundedIndex];
73 choosenCloseTrajectory = &trajectoryCloseSet.
trajectories[boundedIndex];
79void AirBrakesInterp::step()
81 auto currentPosition = getCurrentPosition();
84 if (lastPosition.
timestamp >= currentPosition.timestamp)
87 lastPosition = currentPosition;
90 float percentage = controlInterp(currentPosition);
93 float filterCoeff = 0;
115 lastPercentage + (percentage - lastPercentage) * filterCoeff;
124 lastPercentage = percentage;
125 setActuator(percentage);
128float AirBrakesInterp::controlInterp(TrajectoryPoint currentPosition)
133 floor((currentPosition.z / configInterp.
DZ)) + configInterp.
N_FORWARD;
135 index_z = std::max(index_z, 0);
139 index_z = std::min(index_z, std::min(choosenCloseTrajectory->
trjSize - 1,
140 choosenOpenTrajectory->
trjSize - 1));
143 choosenCloseTrajectory->
points[index_z];
145 choosenOpenTrajectory->
points[index_z];
151 if (currentPosition.vz <= trjPointClosed.
vz)
155 else if (currentPosition.vz >= trjPointOpen.
vz)
161 return (currentPosition.vz - trjPointClosed.
vz) /
162 (trjPointOpen.
vz - trjPointClosed.
vz);
bool init() override
Initializes the Algorithm object, must be called as soon as the object is created.
AirBrakesInterp(std::function< TimedTrajectoryPoint()> getCurrentPosition, const TrajectorySet &trajectoryOpenSet, const TrajectorySet &trajectoryCloseSet, const AirBrakesInterpConfig &configInterp, std::function< void(float)> setActuator)
void begin()
Starts the execution of the algorithm and set the running flag to true.
std::atomic< bool > running
Trajectory point with timestamp and velocity module.
float vz
Vertical velocity [m/s].
Trajectory * trajectories
This file includes all the types the logdecoder script will decode.
float FILTER_MINIMUM_ALTITUDE
float FILTER_MAXIMUM_ALTITUDE
float STARTING_FILTER_VALUE
float ABK_CRITICAL_ALTITUDE