2010-10-03 22:39:23 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @addtogroup OpenPilotModules OpenPilot Modules
|
|
|
|
* @{
|
|
|
|
* @addtogroup StabilizationModule Stabilization Module
|
|
|
|
* @brief Stabilization PID loops in an airframe type independent manner
|
|
|
|
* @note This object updates the @ref ActuatorDesired "Actuator Desired" based on the
|
2013-05-18 19:36:45 +02:00
|
|
|
* PID loops on the @ref AttitudeDesired "Attitude Desired" and @ref AttitudeState "Attitude State"
|
2010-10-03 22:39:23 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file stabilization.c
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief Attitude stabilization module.
|
|
|
|
*
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2013-05-02 23:31:14 +02:00
|
|
|
#include <openpilot.h>
|
2013-09-01 12:10:55 +02:00
|
|
|
#include <pios_struct_helper.h>
|
2014-04-28 19:11:00 +02:00
|
|
|
#include <pid.h>
|
|
|
|
#include <manualcontrolcommand.h>
|
|
|
|
#include <flightmodesettings.h>
|
|
|
|
#include <stabilizationsettings.h>
|
|
|
|
#include <stabilizationdesired.h>
|
|
|
|
#include <stabilizationstatus.h>
|
|
|
|
#include <stabilizationbank.h>
|
|
|
|
#include <stabilizationsettingsbank1.h>
|
|
|
|
#include <stabilizationsettingsbank2.h>
|
|
|
|
#include <stabilizationsettingsbank3.h>
|
|
|
|
#include <relaytuning.h>
|
|
|
|
#include <relaytuningsettings.h>
|
|
|
|
#include <ratedesired.h>
|
|
|
|
#include <sin_lookup.h>
|
|
|
|
#include <stabilization.h>
|
|
|
|
#include <innerloop.h>
|
|
|
|
#include <outerloop.h>
|
|
|
|
|
|
|
|
|
|
|
|
// Public variables
|
|
|
|
StabilizationData stabSettings;
|
2010-10-03 22:39:23 +02:00
|
|
|
|
|
|
|
// Private variables
|
2014-04-28 19:11:00 +02:00
|
|
|
static int cur_flight_mode = -1;
|
2010-10-03 22:39:23 +02:00
|
|
|
|
|
|
|
// Private functions
|
2013-05-18 14:17:26 +02:00
|
|
|
static void SettingsUpdatedCb(UAVObjEvent *ev);
|
2013-12-10 21:07:56 +01:00
|
|
|
static void BankUpdatedCb(UAVObjEvent *ev);
|
2013-12-11 14:56:00 +01:00
|
|
|
static void SettingsBankUpdatedCb(UAVObjEvent *ev);
|
2014-04-28 19:11:00 +02:00
|
|
|
static void FlightModeSwitchUpdatedCb(UAVObjEvent *ev);
|
|
|
|
static void StabilizationDesiredUpdatedCb(UAVObjEvent *ev);
|
2010-10-03 22:39:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Module initialization
|
|
|
|
*/
|
2011-06-20 07:35:40 +02:00
|
|
|
int32_t StabilizationStart()
|
2010-10-03 22:39:23 +02:00
|
|
|
{
|
2013-05-18 14:17:26 +02:00
|
|
|
StabilizationSettingsConnectCallback(SettingsUpdatedCb);
|
2014-04-28 19:11:00 +02:00
|
|
|
ManualControlCommandConnectCallback(FlightModeSwitchUpdatedCb);
|
2013-12-10 21:07:56 +01:00
|
|
|
StabilizationBankConnectCallback(BankUpdatedCb);
|
2013-12-11 14:56:00 +01:00
|
|
|
StabilizationSettingsBank1ConnectCallback(SettingsBankUpdatedCb);
|
|
|
|
StabilizationSettingsBank2ConnectCallback(SettingsBankUpdatedCb);
|
|
|
|
StabilizationSettingsBank3ConnectCallback(SettingsBankUpdatedCb);
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationDesiredConnectCallback(StabilizationDesiredUpdatedCb);
|
|
|
|
SettingsUpdatedCb(StabilizationSettingsHandle());
|
|
|
|
StabilizationDesiredUpdatedCb(StabilizationDesiredHandle());
|
|
|
|
FlightModeSwitchUpdatedCb(ManualControlCommandHandle());
|
2013-12-11 14:56:00 +01:00
|
|
|
|
2013-05-15 05:20:52 +02:00
|
|
|
#ifdef PIOS_INCLUDE_WDG
|
2014-04-28 19:11:00 +02:00
|
|
|
// PIOS_WDG_RegisterFlag(PIOS_WDG_STABILIZATION);
|
2013-05-15 05:20:52 +02:00
|
|
|
#endif
|
2013-05-18 14:17:26 +02:00
|
|
|
return 0;
|
2011-06-20 07:35:40 +02:00
|
|
|
}
|
|
|
|
|
2010-10-03 22:39:23 +02:00
|
|
|
/**
|
|
|
|
* Module initialization
|
|
|
|
*/
|
|
|
|
int32_t StabilizationInitialize()
|
|
|
|
{
|
2013-05-18 14:17:26 +02:00
|
|
|
// Initialize variables
|
2014-03-02 18:59:36 +01:00
|
|
|
StabilizationDesiredInitialize();
|
2013-05-18 14:17:26 +02:00
|
|
|
StabilizationSettingsInitialize();
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationStatusInitialize();
|
2013-12-11 13:05:05 +01:00
|
|
|
StabilizationBankInitialize();
|
2013-12-11 14:56:00 +01:00
|
|
|
StabilizationSettingsBank1Initialize();
|
|
|
|
StabilizationSettingsBank2Initialize();
|
|
|
|
StabilizationSettingsBank3Initialize();
|
2013-05-18 14:17:26 +02:00
|
|
|
RateDesiredInitialize();
|
2014-04-28 19:11:00 +02:00
|
|
|
ManualControlCommandInitialize(); // only used for PID bank selection based on flight mode switch
|
2013-05-18 14:17:26 +02:00
|
|
|
// Code required for relay tuning
|
|
|
|
sin_lookup_initalize();
|
|
|
|
RelayTuningSettingsInitialize();
|
|
|
|
RelayTuningInitialize();
|
2012-08-03 19:15:57 +02:00
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
stabilizationOuterloopInit();
|
|
|
|
stabilizationInnerloopInit();
|
|
|
|
pid_zero(&stabSettings.outerPids[0]);
|
|
|
|
pid_zero(&stabSettings.outerPids[1]);
|
|
|
|
pid_zero(&stabSettings.outerPids[2]);
|
|
|
|
pid_zero(&stabSettings.innerPids[0]);
|
|
|
|
pid_zero(&stabSettings.innerPids[1]);
|
|
|
|
pid_zero(&stabSettings.innerPids[2]);
|
2013-05-18 14:17:26 +02:00
|
|
|
return 0;
|
2010-10-03 22:39:23 +02:00
|
|
|
}
|
|
|
|
|
2013-06-04 05:37:40 +02:00
|
|
|
MODULE_INITCALL(StabilizationInitialize, StabilizationStart);
|
2011-06-20 07:35:40 +02:00
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
static void StabilizationDesiredUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
2010-10-03 22:39:23 +02:00
|
|
|
{
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationStatusData status;
|
|
|
|
StabilizationDesiredStabilizationModeData mode;
|
|
|
|
int t;
|
|
|
|
|
|
|
|
StabilizationDesiredStabilizationModeGet(&mode);
|
|
|
|
for (t = 0; t < AXES; t++) {
|
|
|
|
switch (cast_struct_to_array(mode, mode.Roll)[t]) {
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_DIRECT;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_DIRECT;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_RATE:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_DIRECT;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_RATE;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_ATTITUDE;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_RATE;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_DIRECT;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_AXISLOCK;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_WEAKLEVELING;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_RATE;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_DIRECT;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_VIRTUALFLYBAR;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_RATTITUDE;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_RATE;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_DIRECT;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_RELAYTUNING;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYATTITUDE:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_ATTITUDE;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_RELAYTUNING;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_ALTITUDEHOLD:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_ALTITUDE;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_CRUISECONTROL;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_VERTICALVELOCITY:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_VERTICALVELOCITY;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_CRUISECONTROL;
|
|
|
|
break;
|
|
|
|
case STABILIZATIONDESIRED_STABILIZATIONMODE_CRUISECONTROL:
|
|
|
|
cast_struct_to_array(status.OuterLoop, status.OuterLoop.Roll)[t] = STABILIZATIONSTATUS_OUTERLOOP_DIRECT;
|
|
|
|
cast_struct_to_array(status.InnerLoop, status.InnerLoop.Roll)[t] = STABILIZATIONSTATUS_INNERLOOP_CRUISECONTROL;
|
|
|
|
break;
|
2013-05-18 14:17:26 +02:00
|
|
|
}
|
|
|
|
}
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationStatusSet(&status);
|
2010-10-03 22:39:23 +02:00
|
|
|
}
|
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
static void FlightModeSwitchUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
2010-10-03 22:39:23 +02:00
|
|
|
{
|
2014-04-28 19:11:00 +02:00
|
|
|
uint8_t fm;
|
2012-08-02 11:12:12 +02:00
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
ManualControlCommandFlightModeSwitchPositionGet(&fm);
|
2012-09-10 10:10:26 +02:00
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
if (fm == cur_flight_mode) {
|
|
|
|
return;
|
2013-05-18 14:17:26 +02:00
|
|
|
}
|
2014-04-28 19:11:00 +02:00
|
|
|
cur_flight_mode = fm;
|
|
|
|
SettingsBankUpdatedCb(NULL);
|
2010-10-03 22:39:23 +02:00
|
|
|
}
|
|
|
|
|
2013-12-11 14:56:00 +01:00
|
|
|
static void SettingsBankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
2010-10-03 22:39:23 +02:00
|
|
|
{
|
2014-03-22 03:34:03 +01:00
|
|
|
if (cur_flight_mode < 0 || cur_flight_mode >= FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM) {
|
2014-01-14 20:03:42 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-04-28 19:11:00 +02:00
|
|
|
if ((ev) && ((stabSettings.settings.FlightModeMap[cur_flight_mode] == 0 && ev->obj != StabilizationSettingsBank1Handle()) ||
|
|
|
|
(stabSettings.settings.FlightModeMap[cur_flight_mode] == 1 && ev->obj != StabilizationSettingsBank2Handle()) ||
|
|
|
|
(stabSettings.settings.FlightModeMap[cur_flight_mode] == 2 && ev->obj != StabilizationSettingsBank3Handle()) ||
|
|
|
|
stabSettings.settings.FlightModeMap[cur_flight_mode] > 2)) {
|
2014-01-21 22:43:41 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-10 20:58:05 +01:00
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
switch (stabSettings.settings.FlightModeMap[cur_flight_mode]) {
|
2013-12-11 14:56:00 +01:00
|
|
|
case 0:
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *)&stabSettings.stabBank);
|
2013-12-11 14:56:00 +01:00
|
|
|
break;
|
2013-05-18 14:17:26 +02:00
|
|
|
|
2013-12-11 14:56:00 +01:00
|
|
|
case 1:
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *)&stabSettings.stabBank);
|
2013-12-11 14:56:00 +01:00
|
|
|
break;
|
2013-05-18 14:17:26 +02:00
|
|
|
|
2013-12-11 14:56:00 +01:00
|
|
|
case 2:
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationSettingsBank3Get((StabilizationSettingsBank3Data *)&stabSettings.stabBank);
|
2013-12-11 14:56:00 +01:00
|
|
|
break;
|
2013-12-10 21:10:01 +01:00
|
|
|
}
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationBankSet(&stabSettings.stabBank);
|
2013-12-10 21:07:56 +01:00
|
|
|
}
|
2013-05-18 14:17:26 +02:00
|
|
|
|
2013-12-10 21:07:56 +01:00
|
|
|
static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
|
|
|
{
|
2014-04-28 19:11:00 +02:00
|
|
|
StabilizationBankGet(&stabSettings.stabBank);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// Set the roll rate PID constants
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure(&stabSettings.innerPids[0], stabSettings.stabBank.RollRatePID.Kp,
|
|
|
|
stabSettings.stabBank.RollRatePID.Ki,
|
|
|
|
stabSettings.stabBank.RollRatePID.Kd,
|
|
|
|
stabSettings.stabBank.RollRatePID.ILimit);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// Set the pitch rate PID constants
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure(&stabSettings.innerPids[1], stabSettings.stabBank.PitchRatePID.Kp,
|
|
|
|
stabSettings.stabBank.PitchRatePID.Ki,
|
|
|
|
stabSettings.stabBank.PitchRatePID.Kd,
|
|
|
|
stabSettings.stabBank.PitchRatePID.ILimit);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// Set the yaw rate PID constants
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure(&stabSettings.innerPids[2], stabSettings.stabBank.YawRatePID.Kp,
|
|
|
|
stabSettings.stabBank.YawRatePID.Ki,
|
|
|
|
stabSettings.stabBank.YawRatePID.Kd,
|
|
|
|
stabSettings.stabBank.YawRatePID.ILimit);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// Set the roll attitude PI constants
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure(&stabSettings.outerPids[0], stabSettings.stabBank.RollPI.Kp,
|
|
|
|
stabSettings.stabBank.RollPI.Ki,
|
2013-12-16 19:42:24 +01:00
|
|
|
0,
|
2014-04-28 19:11:00 +02:00
|
|
|
stabSettings.stabBank.RollPI.ILimit);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// Set the pitch attitude PI constants
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure(&stabSettings.outerPids[1], stabSettings.stabBank.PitchPI.Kp,
|
|
|
|
stabSettings.stabBank.PitchPI.Ki,
|
2013-12-16 19:42:24 +01:00
|
|
|
0,
|
2014-04-28 19:11:00 +02:00
|
|
|
stabSettings.stabBank.PitchPI.ILimit);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// Set the yaw attitude PI constants
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure(&stabSettings.outerPids[2], stabSettings.stabBank.YawPI.Kp,
|
|
|
|
stabSettings.stabBank.YawPI.Ki,
|
2013-12-16 19:42:24 +01:00
|
|
|
0,
|
2014-04-28 19:11:00 +02:00
|
|
|
stabSettings.stabBank.YawPI.ILimit);
|
2014-01-10 23:16:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
|
|
|
|
{
|
2014-04-28 19:11:00 +02:00
|
|
|
// needs no mutex, as long as eventdispatcher and Stabilization are both TASK_PRIORITY_CRITICAL
|
|
|
|
StabilizationSettingsGet(&stabSettings.settings);
|
2013-12-16 19:42:24 +01:00
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
// Set up the derivative term
|
2014-04-28 19:11:00 +02:00
|
|
|
pid_configure_derivative(stabSettings.settings.DerivativeCutoff, stabSettings.settings.DerivativeGamma);
|
2013-05-18 14:17:26 +02:00
|
|
|
|
|
|
|
// The dT has some jitter iteration to iteration that we don't want to
|
|
|
|
// make thie result unpredictable. Still, it's nicer to specify the constant
|
|
|
|
// based on a time (in ms) rather than a fixed multiplier. The error between
|
|
|
|
// update rates on OP (~300 Hz) and CC (~475 Hz) is negligible for this
|
|
|
|
// calculation
|
|
|
|
const float fakeDt = 0.0025f;
|
2014-04-28 19:11:00 +02:00
|
|
|
if (stabSettings.settings.GyroTau < 0.0001f) {
|
|
|
|
stabSettings.gyro_alpha = 0; // not trusting this to resolve to 0
|
2013-05-18 14:17:26 +02:00
|
|
|
} else {
|
2014-04-28 19:11:00 +02:00
|
|
|
stabSettings.gyro_alpha = expf(-fakeDt / stabSettings.settings.GyroTau);
|
2013-05-18 14:17:26 +02:00
|
|
|
}
|
|
|
|
|
2014-01-14 20:03:42 +01:00
|
|
|
// force flight mode update
|
2014-01-15 20:37:13 +01:00
|
|
|
cur_flight_mode = -1;
|
2013-12-18 11:01:16 +01:00
|
|
|
|
2014-03-18 03:40:19 +01:00
|
|
|
// Rattitude stick angle where the attitude to rate transition happens
|
2014-04-28 19:11:00 +02:00
|
|
|
if (stabSettings.settings.RattitudeModeTransition < (uint8_t)10) {
|
|
|
|
stabSettings.rattitude_mode_transition_stick_position = 10.0f / 100.0f;
|
2014-03-18 03:40:19 +01:00
|
|
|
} else {
|
2014-04-28 19:11:00 +02:00
|
|
|
stabSettings.rattitude_mode_transition_stick_position = (float)stabSettings.settings.RattitudeModeTransition / 100.0f;
|
2014-03-18 03:40:19 +01:00
|
|
|
}
|
2014-01-11 22:22:20 +01:00
|
|
|
|
2014-04-28 19:11:00 +02:00
|
|
|
stabSettings.cruiseControl.cruise_control_min_thrust = (float)stabSettings.settings.CruiseControlMinThrust / 100.0f;
|
|
|
|
stabSettings.cruiseControl.cruise_control_max_thrust = (float)stabSettings.settings.CruiseControlMaxThrust / 100.0f;
|
|
|
|
stabSettings.cruiseControl.cruise_control_max_angle_cosine = cos_lookup_deg(stabSettings.settings.CruiseControlMaxAngle);
|
|
|
|
stabSettings.cruiseControl.cruise_control_max_power_factor = stabSettings.settings.CruiseControlMaxPowerFactor;
|
|
|
|
stabSettings.cruiseControl.cruise_control_power_trim = stabSettings.settings.CruiseControlPowerTrim / 100.0f;
|
|
|
|
stabSettings.cruiseControl.cruise_control_inverted_power_switch = stabSettings.settings.CruiseControlInvertedPowerSwitch;
|
|
|
|
stabSettings.cruiseControl.cruise_control_neutral_thrust = (float)stabSettings.settings.CruiseControlNeutralThrust / 100.0f;
|
2010-10-03 22:39:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-03-02 02:25:30 +01:00
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|