Failsafe Modification

To meet a competition requirement I am attempting to modify the fail safe so that the long fail safe causes full roll right and full pitch, terminating the flight.  When the modified code is uploaded and the rc connection is disabled, the aircraft responds as desired, the issue is that the new flight mode does not show up in mission planner, so I am unable to assign it to a switch position.  I am unsure of where in the code the flight modes for the mission planner are located,  any help that anyone might be able to offer would be greatly appreciated, thanks!

The ways I have modified the code (V2.33), are summarized as follows:

1. Added a new flight mode FTS right after Manual in the main loop, seen below

case FTS:

                   //This flight mode was added by Devin Jensen to fulfill mission requirements
                   nav_roll = g.roll_limit;
                   nav_pitch = g.pitch_limit_max;               

break;

2. Added a new flight mode FTS right after initializing in defines.h, seen below

#define FTS 17              //This flight mode was added by Devin Jensen to fulfill mission requirements

3. Modified the short and long fail safe functions by removing the switch statements, and setting the flight mode to RTL for short fail safe and FTS for long fail safe, regardless of current flight mode, seen below.

static void failsafe_short_on_event(int fstype)
{
    // This is how to handle a short loss of control signal failsafe.
    failsafe = fstype;
    ch3_failsafe_timer = millis();
        gcs_send_text_P(SEVERITY_LOW, PSTR("Failsafe - Short event on, "));
    set_mode(RTL);
}

static void failsafe_long_on_event(int fstype)
{
    // This is how to handle a long loss of control signal failsafe.
    gcs_send_text_P(SEVERITY_LOW, PSTR("Failsafe - Long event on, "));
    APM_RC.clearOverride();        //  If the GCS is locked up we allow control to revert to RC
    failsafe = fstype;
    set_mode(FTS);
}

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • nice however does the "gcs_send_text_P" work for you? I don't get any messages on the GSC screen. 

    Shouldn't it apear were ARMEND and DISARMED shows up?

    Thx

    Andy

This reply was deleted.

Activity