2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
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"
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
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>
38 #include <stabilizationsettings.h>
39 #include <stabilizationbank.h>
42 int32_t StabilizationInitialize();
45 StabilizationSettingsData settings
;
46 StabilizationBankData stabBank
;
48 float floatThrustPIDScaleCurve
[STABILIZATIONBANK_THRUSTPIDSCALECURVE_NUMELEM
];
49 float acroInsanityFactors
[STABILIZATIONBANK_ACROINSANITYFACTOR_NUMELEM
];
53 float thrust_difference
;
55 float half_power_delay
;
56 float max_power_factor_angle
;
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];
69 extern StabilizationData stabSettings
;
72 #define FAILSAFE_TIMEOUT_MS 30
74 #ifndef PIOS_STABILIZATION_STACK_SIZE
75 #define STACK_SIZE_BYTES 800
77 #define STACK_SIZE_BYTES PIOS_STABILIZATION_STACK_SIZE
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
87 #define OUTERLOOP_SKIPCOUNT ATTITUDE_SENSORS_DOWNSAMPLE
88 #endif // STABILIZATION_ATTITUDE_DOWNSAMPLED
89 #endif // STABILIZATION_H