1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

LP-150 - prevent stab error conditions

This commit is contained in:
Alessio Morale 2016-05-03 01:00:28 +02:00
parent 6bd6ef5be1
commit e14e5febe2
3 changed files with 14 additions and 5 deletions

View File

@ -80,9 +80,12 @@ extern StabilizationData stabSettings;
// must be same as eventdispatcher to avoid needing additional mutexes
#define CBTASK_PRIORITY CALLBACK_TASK_FLIGHTCONTROL
#ifndef STABILIZATION_ATTITUDE_DOWNSAMPLED
// outer loop only executes every 4th uavobject update to save CPU
#define OUTERLOOP_SKIPCOUNT 4
#else
#define OUTERLOOP_SKIPCOUNT ATTITUDE_SENSORS_DOWNSAMPLE
#endif // STABILIZATION_ATTITUDE_DOWNSAMPLED
#endif // STABILIZATION_H
/**

View File

@ -365,14 +365,19 @@ static void stabilizationOuterloopTask()
static void AttitudeStateUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{
#ifndef STABILIZATION_ATTITUDE_DOWNSAMPLED
// to reduce CPU utilization, outer loop is not executed on every state update
static uint8_t cpusaver = 0;
if ((cpusaver++ % OUTERLOOP_SKIPCOUNT) == 0) {
#endif
// this does not need mutex protection as both eventdispatcher and stabi run in same callback task!
AttitudeStateGet(&attitude);
PIOS_CALLBACKSCHEDULER_Dispatch(callbackHandle);
#ifndef STABILIZATION_ATTITUDE_DOWNSAMPLED
}
#endif
}
/**

View File

@ -94,6 +94,7 @@
/* #define PIOS_INCLUDE_HCSR04 */
#define PIOS_SENSOR_RATE 500.0f
#define STABILIZATION_ATTITUDE_DOWNSAMPLED
#define ATTITUDE_SENSORS_DOWNSAMPLE 4
/* PIOS receiver drivers */