mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Added crash detection and recovery
This commit is contained in:
parent
d0475a6987
commit
1dc5f88820
4 changed files with 83 additions and 12 deletions
|
@ -18,6 +18,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "common/time.h"
|
||||
#include "config/parameter_group.h"
|
||||
|
||||
#define MAX_PID_PROCESS_DENOM 16
|
||||
|
@ -57,6 +58,12 @@ typedef enum {
|
|||
PID_STABILISATION_ON
|
||||
} pidStabilisationState_e;
|
||||
|
||||
typedef enum {
|
||||
PID_CRASH_RECOVERY_OFF = 0,
|
||||
PID_CRASH_RECOVERY_ON,
|
||||
PID_CRASH_RECOVERY_BEEP
|
||||
} pidCrashRecovery_e;
|
||||
|
||||
typedef struct pidProfile_s {
|
||||
uint8_t P8[PID_ITEM_COUNT];
|
||||
uint8_t I8[PID_ITEM_COUNT];
|
||||
|
@ -83,6 +90,12 @@ typedef struct pidProfile_s {
|
|||
uint8_t dtermSetpointWeight; // Setpoint weight for Dterm (0= measurement, 1= full error, 1 > agressive derivative)
|
||||
uint16_t yawRateAccelLimit; // yaw accel limiter for deg/sec/ms
|
||||
uint16_t rateAccelLimit; // accel limiter roll/pitch deg/sec/ms
|
||||
uint16_t crash_dthreshold; // dterm crash value
|
||||
uint16_t crash_gthreshold; // gyro crash value
|
||||
uint16_t crash_time; // ms
|
||||
uint8_t crash_recovery_angle; // degrees
|
||||
uint8_t crash_recovery_rate; // degree/second
|
||||
pidCrashRecovery_e crash_recovery; // off, on, on and beeps when it is in crash recovery mode
|
||||
} pidProfile_t;
|
||||
|
||||
#if FLASH_SIZE <= 128
|
||||
|
@ -99,7 +112,7 @@ typedef struct pidConfig_s {
|
|||
PG_DECLARE(pidConfig_t, pidConfig);
|
||||
|
||||
union rollAndPitchTrims_u;
|
||||
void pidController(const pidProfile_t *pidProfile, const union rollAndPitchTrims_u *angleTrim);
|
||||
void pidController(const pidProfile_t *pidProfile, const union rollAndPitchTrims_u *angleTrim, timeUs_t currentTimeUs);
|
||||
|
||||
extern float axisPID_P[3], axisPID_I[3], axisPID_D[3];
|
||||
bool airmodeWasActivated;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue