Moderator

Code for changes wanted - APv2.7

In the AUTO mode the failsafe function is:

> if (FAILSAFE_ACTION == 1){
                    set_mode(RTL);
                    throttle_cruise = THROTTLE_CRUISE;

So let's say if when switched to AUTO the plane now flies out of the RC Tx's range (out of sight too) en-route to waypoint #1 and the failsafe activates then the aircraft will RTL at cruise throttle. However when it comes back into range AUTO mode re-initializes and the plane attempts to fly back to waypoint #1, starting a loop which isn't desirable.

 

I don't know the code language but would like to have it so that RTL is locked after a failsafe condition until a certain radius from home is reached, then switched to normal RTL or to LOITER.

 

Can someone clued up on the code suggest the changes required to affect this?

 

 

 

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

Join diydrones

Email me when people reply –

Replies

  •  Jason I see this discussion is a little old but much the code rework much needed. I have experienced trouble with the failsafe in it not working at all. If I understand the code correctly, if the failsafe is not configured "#define THROTTLE_FAILSAFE 1" in AP_Config.h the plane would theoretically keep flying the course or what?
  • Developer

    OK, here is my code update for you...

     

     {                // we just exited failsafe
    switch(control_mode)
    {
    case AUTO:
    if (FAILSAFE_ACTION == 1){
    set_mode(RTL);
    throttle_cruise = THROTTLE_CRUISE;
    }
    break;
    }
    reset_I();
    }

     

    what this does is override the resetting of the control mode back to Auto. If you loose connection in Auto, it will return home until you flip your control switch if your FAILSAFE_ACTION is set to 1.

    enclosed is the file.

    Jason

    events.pde

    https://storage.ning.com/topology/rest/1.0/file/get/3692159426?profile=original
  • Developer

    Hi Graham, 

    Your right, 

     

    what we need to do is split the failsafe_event() to get a failsafe_event_on() and failsafe_event_off() 

    Then we can add that in. np. will have that for you today.

     

    Jason

  • Developer

    Have you tested this? i dont believe it would start the loop.

    the reason being that the control channel is the only other thing that can change the mode. when it goes into failsafe the mode is changed in software, so long as the transmitter switch is not flicked it will remain in RTL.

This reply was deleted.

Activity

Santiago Perez liked Santiago Perez's profile
2 hours ago
More…