mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-04-08 00:53:48 +02:00
Flight/ManualControl: Added a hysteresis loop to the manual control connection/disconnection status. I seem to get glitching without it - probably because of the receiver catching noise. It still occasionally glitches but I don't want to make it longer. Probably should be an adjustable setting.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1527 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
c21d058110
commit
d3b677298c
@ -82,6 +82,10 @@ static void manualControlTask(void* parameters)
|
|||||||
AttitudeDesiredData attitude;
|
AttitudeDesiredData attitude;
|
||||||
portTickType lastSysTime;
|
portTickType lastSysTime;
|
||||||
float flightMode;
|
float flightMode;
|
||||||
|
|
||||||
|
uint8_t disconnected_count = 0;
|
||||||
|
uint8_t connected_count = 0;
|
||||||
|
enum {CONNECTED, DISCONNECTED} connection_state = DISCONNECTED;
|
||||||
|
|
||||||
// Main task loop
|
// Main task loop
|
||||||
lastSysTime = xTaskGetTickCount();
|
lastSysTime = xTaskGetTickCount();
|
||||||
@ -184,10 +188,30 @@ static void manualControlTask(void* parameters)
|
|||||||
else
|
else
|
||||||
ManualControlCommandGet(&cmd); /* Under GCS control */
|
ManualControlCommandGet(&cmd); /* Under GCS control */
|
||||||
|
|
||||||
|
// Implement hysteresis loop on connection status
|
||||||
// Must check both Max and Min in case they reversed
|
// Must check both Max and Min in case they reversed
|
||||||
if (cmd.Channel[settings.Throttle] < settings.ChannelMax[settings.Throttle] &&
|
if (cmd.Channel[settings.Throttle] < settings.ChannelMax[settings.Throttle] &&
|
||||||
cmd.Channel[settings.Throttle] < settings.ChannelMin[settings.Throttle])
|
cmd.Channel[settings.Throttle] < settings.ChannelMin[settings.Throttle])
|
||||||
{
|
{
|
||||||
|
if (disconnected_count++ > 10)
|
||||||
|
{
|
||||||
|
connection_state = DISCONNECTED;
|
||||||
|
connected_count = 0;
|
||||||
|
disconnected_count = 0;
|
||||||
|
} else
|
||||||
|
disconnected_count++;
|
||||||
|
} else {
|
||||||
|
if (connected_count++ > 10)
|
||||||
|
{
|
||||||
|
connection_state = CONNECTED;
|
||||||
|
connected_count = 0;
|
||||||
|
disconnected_count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
connected_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connection_state == DISCONNECTED) {
|
||||||
cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE;
|
cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE;
|
||||||
cmd.Throttle = 0; // Shut down engine with no control
|
cmd.Throttle = 0; // Shut down engine with no control
|
||||||
cmd.Roll = 0;
|
cmd.Roll = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user