mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Corrected missed USE_ACC logic and some minor cleanup (#14093)
This commit is contained in:
parent
f27da4ed8d
commit
7dec49ce42
7 changed files with 13 additions and 5 deletions
|
@ -46,14 +46,20 @@
|
||||||
#define CM_S_TO_KM_H(centimetersPerSecond) ((centimetersPerSecond) * 36 / 1000)
|
#define CM_S_TO_KM_H(centimetersPerSecond) ((centimetersPerSecond) * 36 / 1000)
|
||||||
#define CM_S_TO_MPH(centimetersPerSecond) ((centimetersPerSecond) * 10000 / 5080 / 88)
|
#define CM_S_TO_MPH(centimetersPerSecond) ((centimetersPerSecond) * 10000 / 5080 / 88)
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
#define MIN(a,b) \
|
#define MIN(a,b) \
|
||||||
__extension__ ({ __typeof__ (a) _a = (a); \
|
__extension__ ({ __typeof__ (a) _a = (a); \
|
||||||
__typeof__ (b) _b = (b); \
|
__typeof__ (b) _b = (b); \
|
||||||
_a < _b ? _a : _b; })
|
_a < _b ? _a : _b; })
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
#define MAX(a,b) \
|
#define MAX(a,b) \
|
||||||
__extension__ ({ __typeof__ (a) _a = (a); \
|
__extension__ ({ __typeof__ (a) _a = (a); \
|
||||||
__typeof__ (b) _b = (b); \
|
__typeof__ (b) _b = (b); \
|
||||||
_a > _b ? _a : _b; })
|
_a > _b ? _a : _b; })
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ABS(x) \
|
#define ABS(x) \
|
||||||
__extension__ ({ __typeof__ (x) _x = (x); \
|
__extension__ ({ __typeof__ (x) _x = (x); \
|
||||||
_x > 0 ? _x : -_x; })
|
_x > 0 ? _x : -_x; })
|
||||||
|
|
|
@ -1328,7 +1328,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, timeUs_t currentTim
|
||||||
|
|
||||||
float pidSetpointDelta = 0;
|
float pidSetpointDelta = 0;
|
||||||
|
|
||||||
#ifdef USE_FEEDFORWARD
|
#if defined(USE_FEEDFORWARD) && defined(USE_ACC)
|
||||||
if (FLIGHT_MODE(ANGLE_MODE) && pidRuntime.axisInAngleMode[axis]) {
|
if (FLIGHT_MODE(ANGLE_MODE) && pidRuntime.axisInAngleMode[axis]) {
|
||||||
// this axis is fully under self-levelling control
|
// this axis is fully under self-levelling control
|
||||||
// it will already have stick based feedforward applied in the input to their angle setpoint
|
// it will already have stick based feedforward applied in the input to their angle setpoint
|
||||||
|
|
|
@ -397,8 +397,9 @@ void pidInitConfig(const pidProfile_t *pidProfile)
|
||||||
}
|
}
|
||||||
pidRuntime.angleGain = pidProfile->pid[PID_LEVEL].P / 10.0f;
|
pidRuntime.angleGain = pidProfile->pid[PID_LEVEL].P / 10.0f;
|
||||||
pidRuntime.angleFeedforwardGain = pidProfile->pid[PID_LEVEL].F / 100.0f;
|
pidRuntime.angleFeedforwardGain = pidProfile->pid[PID_LEVEL].F / 100.0f;
|
||||||
|
#ifdef USE_ACC
|
||||||
pidRuntime.angleEarthRef = pidProfile->angle_earth_ref / 100.0f;
|
pidRuntime.angleEarthRef = pidProfile->angle_earth_ref / 100.0f;
|
||||||
|
#endif
|
||||||
pidRuntime.horizonGain = MIN(pidProfile->pid[PID_LEVEL].I / 100.0f, 1.0f);
|
pidRuntime.horizonGain = MIN(pidProfile->pid[PID_LEVEL].I / 100.0f, 1.0f);
|
||||||
pidRuntime.horizonIgnoreSticks = (pidProfile->horizon_ignore_sticks) ? 1.0f : 0.0f;
|
pidRuntime.horizonIgnoreSticks = (pidProfile->horizon_ignore_sticks) ? 1.0f : 0.0f;
|
||||||
|
|
||||||
|
@ -406,7 +407,9 @@ void pidInitConfig(const pidProfile_t *pidProfile)
|
||||||
pidRuntime.horizonLimitSticksInv = (pidProfile->pid[PID_LEVEL].D) ? 1.0f / pidRuntime.horizonLimitSticks : 1.0f;
|
pidRuntime.horizonLimitSticksInv = (pidProfile->pid[PID_LEVEL].D) ? 1.0f / pidRuntime.horizonLimitSticks : 1.0f;
|
||||||
pidRuntime.horizonLimitDegrees = (float)pidProfile->horizon_limit_degrees;
|
pidRuntime.horizonLimitDegrees = (float)pidProfile->horizon_limit_degrees;
|
||||||
pidRuntime.horizonLimitDegreesInv = (pidProfile->horizon_limit_degrees) ? 1.0f / pidRuntime.horizonLimitDegrees : 1.0f;
|
pidRuntime.horizonLimitDegreesInv = (pidProfile->horizon_limit_degrees) ? 1.0f / pidRuntime.horizonLimitDegrees : 1.0f;
|
||||||
|
#ifdef USE_ACC
|
||||||
pidRuntime.horizonDelayMs = pidProfile->horizon_delay_ms;
|
pidRuntime.horizonDelayMs = pidProfile->horizon_delay_ms;
|
||||||
|
#endif
|
||||||
|
|
||||||
pidRuntime.maxVelocity[FD_ROLL] = pidRuntime.maxVelocity[FD_PITCH] = pidProfile->rateAccelLimit * 100 * pidRuntime.dT;
|
pidRuntime.maxVelocity[FD_ROLL] = pidRuntime.maxVelocity[FD_PITCH] = pidProfile->rateAccelLimit * 100 * pidRuntime.dT;
|
||||||
pidRuntime.maxVelocity[FD_YAW] = pidProfile->yawRateAccelLimit * 100 * pidRuntime.dT;
|
pidRuntime.maxVelocity[FD_YAW] = pidProfile->yawRateAccelLimit * 100 * pidRuntime.dT;
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
#include "drivers/adc.h"
|
#include "drivers/adc.h"
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/io_def.h"
|
|
||||||
#include "drivers/io_types.h"
|
#include "drivers/io_types.h"
|
||||||
#include "drivers/resource.h"
|
#include "drivers/resource.h"
|
||||||
#include "drivers/rx/rx_cc2500.h"
|
#include "drivers/rx/rx_cc2500.h"
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
#include "drivers/adc.h"
|
#include "drivers/adc.h"
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "drivers/io_def.h"
|
|
||||||
#include "drivers/io_types.h"
|
#include "drivers/io_types.h"
|
||||||
#include "drivers/resource.h"
|
#include "drivers/resource.h"
|
||||||
#include "drivers/rx/rx_cc2500.h"
|
#include "drivers/rx/rx_cc2500.h"
|
||||||
|
|
|
@ -83,7 +83,7 @@ timeUs_t RcStatsGetFullThrottleTimeUs(void)
|
||||||
|
|
||||||
int8_t RcStatsGetAverageThrottle(void)
|
int8_t RcStatsGetAverageThrottle(void)
|
||||||
{
|
{
|
||||||
return (float)totalTrottleNumber/(float)counter + 0.5; // rounding
|
return (float)totalTrottleNumber/(float)counter + 0.5f; // rounding
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyRcStatsArming(void)
|
void NotifyRcStatsArming(void)
|
||||||
|
|
|
@ -445,6 +445,7 @@ uint32_t clockMicrosToCycles(uint32_t micros)
|
||||||
{
|
{
|
||||||
return micros;
|
return micros;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getCycleCounter(void)
|
uint32_t getCycleCounter(void)
|
||||||
{
|
{
|
||||||
return (uint32_t) (micros64() & 0xFFFFFFFF);
|
return (uint32_t) (micros64() & 0xFFFFFFFF);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue