LP-500 HoTT Bridge Module ported from TauLabs
[librepilot.git] / flight / modules / Stabilization / inc / stabilization.h
blobfbf8dbf9b41929f46a5dabf4a3b723e575dfea9c
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
4 * @{
5 * @addtogroup StabilizationModule Stabilization Module
6 * @brief Stabilization PID loops in an airframe type independent manner
7 * @note This object updates the @ref ActuatorDesired "Actuator Desired" based on the
8 * PID loops on the @ref AttitudeDesired "Attitude Desired" and @ref AttitudeState "Attitude State"
9 * @{
11 * @file stabilization.h
12 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
13 * @brief Attitude stabilization module.
15 * @see The GNU Public License (GPL) Version 3
17 *****************************************************************************/
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 3 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * for more details.
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #ifndef STABILIZATION_H
34 #define STABILIZATION_H
36 #include <openpilot.h>
37 #include <pid.h>
38 #include <stabilizationsettings.h>
39 #include <stabilizationbank.h>
42 int32_t StabilizationInitialize();
44 typedef struct {
45 StabilizationSettingsData settings;
46 StabilizationBankData stabBank;
47 float gyro_alpha;
48 float floatThrustPIDScaleCurve[STABILIZATIONBANK_THRUSTPIDSCALECURVE_NUMELEM];
49 float acroInsanityFactors[STABILIZATIONBANK_ACROINSANITYFACTOR_NUMELEM];
50 struct {
51 float min_thrust;
52 float max_thrust;
53 float thrust_difference;
54 float power_trim;
55 float half_power_delay;
56 float max_power_factor_angle;
57 } cruiseControl;
58 struct {
59 int8_t gyroupdates;
60 int8_t rateupdates;
61 } monitor;
62 float rattitude_mode_transition_stick_position;
63 struct pid innerPids[3], outerPids[3];
64 // TPS [Roll,Pitch,Yaw][P,I,D]
65 bool thrust_pid_scaling_enabled[3][3];
66 } StabilizationData;
69 extern StabilizationData stabSettings;
71 #define AXES 4
72 #define FAILSAFE_TIMEOUT_MS 30
74 #ifndef PIOS_STABILIZATION_STACK_SIZE
75 #define STACK_SIZE_BYTES 800
76 #else
77 #define STACK_SIZE_BYTES PIOS_STABILIZATION_STACK_SIZE
78 #endif
80 // must be same as eventdispatcher to avoid needing additional mutexes
81 #define CBTASK_PRIORITY CALLBACK_TASK_FLIGHTCONTROL
83 #ifndef STABILIZATION_ATTITUDE_DOWNSAMPLED
84 // outer loop only executes every 4th uavobject update to save CPU
85 #define OUTERLOOP_SKIPCOUNT 4
86 #else
87 #define OUTERLOOP_SKIPCOUNT ATTITUDE_SENSORS_DOWNSAMPLE
88 #endif // STABILIZATION_ATTITUDE_DOWNSAMPLED
89 #endif // STABILIZATION_H
91 /**
92 * @}
93 * @}