Advanced Failsafe

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Advanced Failsafe

Post by nhadrian »

Hi,

I started a new topic to collect ideas/developments about advanced Failsafe routines.
For beginning, I wrote a code incl. automatic RTH if Failsafe, code can be found in "Alt hold improvement" topic.
Basically I extended the basic of MIS.

Along with my modification, I set up a variable called failsafeStatus (it'll be in my next release), value can be 0 or 1:

Code: Select all

if (failsafeCnt > (5*FAILSAFE_DELAY)) {failsafeStatus = 1;} else {failsafeStatus = 0;}

(I have also replaced (failsafeCnt > (5*FAILSAFE_DELAY)) everywhere in code with this variable...)
This value can be used for general purposes.

I would like to insert this value into MSP, since for example for OSD users could be useful to print FAILSAFE on screen. Consecuently it should be placed into MSP_STATUS, but then all GUIs, OSDs should be modified according to this...:( Or a unique MSP_FAILSAFE should created? What do you think is the best way?

BR
Adrian

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Advanced Failsafe

Post by nhadrian »

Eric wrote:Can you please explain this line?

Code: Select all

if (BaroPID < -200) // reach the ground.


And if the quad is descending with a high speed, will this value be reached in the air and it disarm?
BTW, why it is -200 here? ;-)
Can you please help me to calculate a safe BaroPID value to used here? I do not want the quad to disarm in the air.


Hi,

yes. As you can see in code, in failsafe output throttle =1450 + BaroPID. If BaroPID is -200, then throttle output will be 1250. (so there is a negative bias in the calculation for most setups). That is far too small for stable descending.
With this I wanted to have a condition wich only depends on altitude not anything else (ie. landing on a tree. you can't trust in acc value because of resonances/movement but if the delay is too high, your copter will crash itself and also burn some ESCs or motors during struggling in the tree)
But with this condition, once copter can't descend anymore because of an obstruction, it'll stop.
Regarding to BaroPID, why 200? If you check this calculation:

Code: Select all

    //P     int16_t error16 = constrain(AltHold - EstAlt, -300, 300);     applyDeadband(error16, 10); //remove small P parametr to reduce noise near zero position     BaroPID = constrain((conf.P8[PIDALT] * error16 / 100), -150, +150);          //I     errorAltitudeI += error16 * conf.I8[PIDALT]/50;     errorAltitudeI = constrain(errorAltitudeI,-30000,30000);     BaroPID += (errorAltitudeI / 500); //I in range +/-60 

-200 BaroPID will mean copter is at least 150-200 cm higher than target altitude (it is even more because ot negative bias). If you copter is in the air, there isn't any reason why it would be 2m higher than the target with low RPM unless it is alreadyBR Adrian on the ground. The only possible explanation is that desired vario is far too high. But my personal experience is that 150-200 cm/s is the highest vario most copter can reach without wobbling of death.

Regarding to fast descend. If you are on a flat field without any obstackles, than it is a good idea! But once there are small hillsides, etc. Than you will not know how far is the landing area is from the copter. And you will maybe still descending with high speed and hit ie. a roof... Anyway, I'll thinking on it how to handle this question. Maybe a define for user choice...
When using sonar to determine how far the ground is than it would be great to have a fast descending period.

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Advanced Failsafe

Post by nhadrian »

I was thinking on a bit to find a reliable solution.

What do you think on this:
- define a FAILSAFE_SAFETY_ALT number, ie. 3 m (300 cm) and a FAILSAFE_FAST_VARIO, ie. 150 cm/s
- if the copter is higher than this altitude, it will descend with FAILSAFE_FAST_VARIO to reach this altitude, then continues with the lower FAILSAFE_SLOW_VARIO.
- following this way, any user can set up failsafe behaviour, regarding to circumstances of field and the copter setup (ie. if copter is stable enough, fast vario can be even 200 cm/s).

A sample calculation: copter is at 50 m (5000 cm), fast vario is 150 cm/s, slow wario is 50 cm/s, safety alt is 5 m (500 cm):
- fast descending time is (5000-500)/150 = 30 s
- slow descending time is 500/50 = 10 s
_______________________________________
- total descendign time is: = 40 s

BR
Adrian

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Advanced Failsafe

Post by nhadrian »

Hi,

I have attached my latest code, I inserted this two-step failsafe vario.
It is fully merged with r1303, and tried to make bnetter descriptions in config.h (sorry for my bad english... ;) )
Please note that since my copter would probably damaged due to a 50 cm/s auto lading (mini Y6 copter...) I didn't tested the failsafe vario mode, only the failsafe rth mode (because in failsafe RTH mode it stays in hovering over home on defined home altitude).
Also please note that I have tested with serial GPS, but I implemented the I2C_GPS, should work also.

Till now I left //NHADRIAN comments after each modified line/part for easier identification, but I'll remove in r10 finally.

BR
Adrian

PS.: mode infos about ALT hold mode in the other topic...
Attachments
Multiwii dev_r1303_NHA_r9.zip
(141.4 KiB) Downloaded 138 times

Post Reply