inav icon indicating copy to clipboard operation
inav copied to clipboard

Flying/not flying detection

Open digitalentity opened this issue 9 years ago • 46 comments

Add some heuristics to figure out if we are flying or not to allow different behavior of i.e. failsafe mode.

digitalentity avatar Oct 13 '17 23:10 digitalentity

Two cases happened to me recently where such information could be useful:

  1. I crashed at some distance and the RX signal was lost (probably because RX antenna was digging the ground). The quad engaged RTH (I saw this on FPV) and the motors were spinning almost full throttle trying to do something. But it didn't actually change much. It took me couple of minutes to get closer and disarm. During that time the RTH was active. Good that motors didn't get burned...

  2. I crashed in stabilized mode (horizon). I couldn't hear the motors and I didn't disarm. When getting closer I realised the motors were spinning fast, probably trying to level.

Not sure if we need to change #2, but in case of autonomous flight (#1) the procedure should be finished when already in the ground to minimise destruction and to conserve battery.

krzysztofmatula avatar Oct 15 '17 12:10 krzysztofmatula

Disable NAV_LAUNCH when flying to avoid issue where NAV_LAUNCH is always activated and the model is disarmed mid-flight.

teckel12 avatar Oct 24 '17 15:10 teckel12

#2410 If in the air, home reset just reset X & Y as it works previously. If not in the air, home reset should do a 3D reset (reset altitude as well).

teckel12 avatar Oct 26 '17 04:10 teckel12

I had the scenario of crash/signal lost/failsave triggered twice, It spins the motor very powerfull until the battery is dead. Second time I was prepared and took the radio to disarm though. But I am in favour of automated disarming in such scenario.

jelle737 avatar Oct 26 '17 19:10 jelle737

@jelle737 If in FAILSAFE mode and no longer flying, disarm would be ideal as well.

teckel12 avatar Oct 26 '17 20:10 teckel12

Is not just a longer Failsafe ignore time when "closed throttle" needed to get them through any RC gitches/packet loss ?

Redshifft avatar Dec 22 '17 10:12 Redshifft

@Redshifft This issue isn't really about failsafe, It's knowing when the model is flying or not. Once that is known, lots of other features/safeguards can be added based on that knowledge.

teckel12 avatar Dec 22 '17 15:12 teckel12

After we have this I'd add the ability to NOT reset the home point if we are "flying" and we mistakenly disarm and re-arm in the air.

giacomo892 avatar Apr 11 '18 20:04 giacomo892

@giacomo892 Or, if in the air and a home reset, just reset the X & Y (as it works now). But if NOT in the air, do a 3D home reset (altitude as well).

teckel12 avatar Apr 12 '18 14:04 teckel12

I've been trying to find what tells an aircraft it is flying, and what tells it is not.

First, the position alone is not telling, cannot check for the altitude or distance to home etc, the ground is obviously not always flat. Then the movement is not much clue either, a multirotor can hover still for a long time and be fine. Or it can be still on the ground because it crashed. Same for a plane, it can have null speed because there's a lot of wind and going well, or be stuck in a tree. Thus I see nothing in the GPS datas that could help.

So the me the logic should be to assume by default that yes, the aircraft is flying. Then case by case, mode by mode, find conditions that'd tend to proove the aircraft is afterall, not flying.

*** For both MR and FW, in modes ANGLE, RTH or WP or POSHOLD : If the pitch or roll angle is more than the max banking angle + some % for safety, for X seconds, then it shows the aircraft is unable to reach to the requested attitude. probable cause is : aircraft is crashed / not flying.

*** For both MR and FW : The sum of all I terms growing larger than X for Y seconds, shows the aircraft is unable to reach to the requested attitude over a long period of time. Not flying.

*** For MR : If at least one motor is at throttle>70% and at least one other is at <30%, and the pitch+roll+yaw are not varying by more than Y%, for more than X seconds, then not flying, because stuck or grounded. This one can potentially catch a lot of non-flying conditions, it's not normal to have a large differential in motors RPMs for a long time, on any kind of multirotor.

OlivierC-FR avatar May 02 '18 20:05 OlivierC-FR

@OlivierC-FR I had assumed something more on the lines of if GPS speed is basically zero, Acc X, Y, Z are not varying by more than a certain amount, and motors are below a certain point, it's no flying. It would be easier for FW as if the GPS position isn't changing, it's obviously not flying. For MR, some kind of minimum for motor speed would need to be factored in (to deal with a super stable hover on a calm day).

Not to say that I've put in a lot of thought into this, but I'd like to think we could keep it as simple as possible but still be accurate. We may want to ease our way into a feature like this. For example, only making it do things that wouldn't be catastrophic (like home position change).

teckel12 avatar May 02 '18 22:05 teckel12

But then what about aircrafts with no GPS ? And accelerometers not varying, this can happen during normal flight, for planes mostly.

OlivierC-FR avatar May 03 '18 05:05 OlivierC-FR

I think we should start by limiting flight modes to FS as this is most common case, RTH crashed/failed for whatever reason. If I'm not wrong ardupilot/copter have something like that so maybe it makes sense to check their ideas also. http://ardupilot.org/copter/docs/crash_check.htmlv https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/crash_check.cpp

pmarkiewicz avatar May 03 '18 08:05 pmarkiewicz

@OlivierC-FR This is INAV, I think GPS would be a requirement? If you don't have a GPS, wouldn't you be using BF or CF? Also, I believe this would be an option anyway so you'd just lose some functionality if you didn't have a GPS.

teckel12 avatar May 03 '18 15:05 teckel12

You're right, GPS is basically almost a pre-req. Problem is that GPS are not the most reliable devices. I still think the unability of the stabilization loop to reach the target pitch/roll/yaw angles within a given delay would be a good indicator of the aircraft flying or not.

Some basic angle check for the RTH/WP modes, like a pitch or roll angle higer than 90° for some seconds, would avoid a lot of bad events I'm fairly sure.

But that's not proper flying/not flying detection as the topic of this PR says, it's just an extra safety for a specific mode.

OlivierC-FR avatar May 03 '18 17:05 OlivierC-FR

I understand the problem with "flying" condition, but there are some cases when we could tell that something is not as expected, ie. plane doing RTH or nav mission should change the position. As we assume GPS data to be good enough to do the RTH or mission, we can belive them the same way for the fact the craft is not moving in desired direction or not moving at all.

On the other hand if the GPS position changes significantly the craft is probably flying and then some actions should also be possible like armnig despite the distance from the first waypoint of the mission, in case we disarmed the craft by accident or for whatever reason.

Tygrys-1 avatar May 14 '18 19:05 Tygrys-1

But that's not proper flying/not flying detection as the topic of this PR says, it's just an extra safety for a specific mode.

I think we need extra safety for the specific modes ASAP. :)

Tygrys-1 avatar May 14 '18 19:05 Tygrys-1

This issue / pull request has been automatically marked as stale because it has not had any activity in 60 days. The resources of the INAV team are limited, and so we are asking for your help. This issue / pull request will be closed if no further activity occurs within two weeks.

stale[bot] avatar Jul 13 '18 20:07 stale[bot]

Definitely not stale.

giacomo892 avatar Jul 13 '18 20:07 giacomo892

Bad bot

fiam avatar Jul 13 '18 21:07 fiam