NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
altitudehold.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #pragma once
18 
19 #include "flight/anglerate.h"
20 
21 #include "sensors/barometer.h"
22 #include "../config/altitudehold.h"
23 
24 struct instruments;
25 struct althold {
26  int32_t setVelocity;
27  uint8_t velocityControl;
28  int32_t errorVelocityI;
30  int32_t AltHold;
31  int32_t vario; // variometer in cm/s
32 
35  int32_t EstAlt; // in cm
36 
38 
39  int16_t throttle;
40 
41  struct instruments *ins;
42  struct rx *rx;
43  const struct config *config;
44 };
45 
46 void althold_init(struct althold *self, struct instruments *ins, struct rx *rx, const struct config *config);
47 
48 void althold_calc_altitude(struct althold *self, uint32_t currentTime);
49 
50 void althold_apply(struct althold *self);
51 void althold_update(struct althold *self);
52 
53 int32_t althold_get_est_altitude(struct althold *self);
struct rx * rx
Definition: altitudehold.h:42
int32_t vario
Definition: altitudehold.h:31
Definition: config.h:81
uint8_t isAltHoldChanged
Definition: altitudehold.h:37
const struct config * config
Definition: altitudehold.h:43
uint8_t velocityControl
Definition: altitudehold.h:27
int32_t setVelocity
Definition: altitudehold.h:26
uint32_t currentTime
Definition: rx.h:97
int32_t althold_get_est_altitude(struct althold *self)
void althold_init(struct althold *self, struct instruments *ins, struct rx *rx, const struct config *config)
int32_t altHoldThrottleAdjustment
Definition: altitudehold.h:29
struct instruments * ins
Definition: altitudehold.h:41
int32_t errorVelocityI
Definition: altitudehold.h:28
void althold_update(struct althold *self)
void althold_calc_altitude(struct althold *self, uint32_t currentTime)
int16_t initialThrottleHold
Definition: altitudehold.h:34
int16_t initialRawThrottleHold
Definition: altitudehold.h:33
void althold_apply(struct althold *self)
int32_t EstAlt
Definition: altitudehold.h:35
Definition: altitudehold.h:25
int32_t AltHold
Definition: altitudehold.h:30
Definition: instruments.h:11
int16_t throttle
output throttle difference
Definition: altitudehold.h:39