-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In flight emergency rearm #9254
In flight emergency rearm #9254
Conversation
@breadoven to answer your question about if a quad can even rearm in flight. Sure, no problem. |
OK, in that case just need to think of some sort of sanity check or just skip it for multirotor and always allow rearm. Can't help but think that PID behaviour should reveal some difference between sitting on the ground and hovering above it or even descending at minimum throttle. Problem is it needs to be reliable always otherwise you'll miss it at the point of disarm which is when it gets checked. |
@breadoven The guys on RCGroups will be happy with this addition. |
I guess the solution for quads is to check what happens after you disarm ... if it plummets it's still flying, if it doesn't plummet after a second or so it probably isn't flying so cancel the rearm timeout window. |
I'm not sure if you've read my post here - #8736 (comment) How fast the multicopter falls or looses attitude control depends on the ESC settings... If Damped-Light is not used, and brake_on_stop is turned off. The quad will practically auto-rotate for a time... But BLheli32 Damped-Light is ON by default and very beneficial to have active. |
Makes sense and probably necessary to stop the quad shooting off in some random direction when it does rearm. Will have a look at adding it. I've also added something to check if the quad drops after disarm which looks like it might work. Just checks vertical velocity at least 1s after disarm. If it's > -1m/s it cancels the emergency rearm. Can be ground tested but flight testing might be a bit tricky. Of course the best solution to inadvertent disarm is to have a dedicated arming switch on transmitters that is deliberately placed away from the other switches, somewhere where your fingers wouldn't normally wander, but still easy to get to quickly. Somewhere in the middle at the top possibly with some physical protection to stop it getting knocked whilst still being easy to operate with a finger. None of the manufacturers do this as far as I can see. I relocate one of the switches if need be so it's away from the others but still easy to use when you need to ... no more accidental disarms. |
Its interesting that most accidental disarms occur with fixed wings, more so than multicopters.. I generally think this is because fixed wings often have all the RC switches, knobs and channels dedicated to a function or operation. And when people get in a fluster, there main go to switches are Disarm and RTH. I very rarely accidentally disarm a quad in flight. But the arm switch needs to be prominent and easy to access if needs be... And if a disarm does happen by long range pilots, at altitude. Its a long fall to the ground.
Could this be a problem ? It doesn't take long for a disarm free fall to break 4km/h. And it may take the pilot a second or so to work out what he has done, before rearming... Which would leave a larger multicopter in the same predicament, as if there was not emergency rearming. For accidental disarming and rearming at low altitudes < 10m if the pilot doesn't have the altitude to recover. This is were the G-shock detector of Betaflight and Arducopter work well. To auto disarm on impact, even after a midair rearm. |
This check cancels the emergency rearm only if the vertical velocity doesn't exceed -1 m/s after 1 second, i.e. the quad hasn't dropped because something is stopping it ... like the ground. Theoretically after 1 second the freefall velocity would be around 10 m/s. Works OK testing on the ground after a simulated takeoff and landing that wasn't hard enough to trigger the landing bump detection, throttle at mid stick. If you rearm within 1 second it arms, after 1 second it doesn't because there's no vertical velocity. To fully test it to ensure it does emergency rearm after 1 second you'd need vertical velocity more than -1 m/s which is tricky unless you disarm in flight. Maybe SITL can check this. |
What if you accidentally disarm while ascending rapidly, there the momentum may keep you above -1m/s vertical speed for multiple seconds? |
Yes it needs testing or some calcs to check the timings. Or other checks could be added depends how complicated you want to make it. Checking throttle > hover throttle and +ve vertical speed would be useful. |
I did some testing with a quad today at low altitude over thick grass and hay.. There are a couple things to look at.
But it didn't appear you added your throttle check suggestion ? It may fix the problem. |
Just to clarify: you're saying you connect the battery, then arm for the first time and it ends up in Angle for the 5s after arming ?
Yes it should only cancel the emergency rearm if vertical velocity is between +-1 m/s, i.e. neither dropping or climbing. However, this check only starts 1.5 s after rearming so it will always rearm within the first 1.5s. It's only after 1.5s that it might no rearm if vertical velocity indicates it's not flying. I tested it and it seems to work when static on the ground. I guess the problem here is you can't allow for all possible situations. You could for instance do a full throttle climb, cut the throttle to 0 then disarm. If the quad reaches the top of the climb > 1.5s later at the point you try and rearm with the vertical velocity at 0 then emergency rearming will fail. But this is a pretty unique situation that's unlikely to happen in reality. What was the quad doing when it failed to rearm in your test ... was it climbing when disarmed or just hovering ? There are no throttle checks as of yet. |
It was disarmed in slow forward flight with a slow climb.. I'd considered that even a lighter weight 7" in slow forward flight, with that much prop area, could potentially hold altitude for over 1.5s.
I agree, freestyle maneuvers are always going to be impossible for a flight detector to predict... But I think a throttle check would increase reliability, for the way most users fly... Anyone cruising or doing long range flying is unlikely to lower the throttle back to idle until they land. |
Ah, yes I was wondering about that ... sounds like it's acting like an autogyro which could maintain lift due to the forward speed and air wash over the props. Looks like a speed check is required to account for this although without a pitot this might also get it wrong at times. Alternatively you could just scrap this check if the rearm time window is limited to 5s. I was thinking you could change the 5s to a setting up to perhaps 30s in which case inadvertent rearm on the ground would be a problem. As you say, it does take a few seconds to twig you've hit the disarm switch ... so perhaps 5s is marginal. |
Sorry, I over looked answering this question.. |
I've redone the logic for this so it should work better and possibly fix the above issue (wasn't sure why it was happening with the old logic). It should work the same way but it now checks for horizontal speed and also gyro rates. I'm thinking gyro rates should be completely different for a quad on the ground, pretty well 0, and a quad that disarmed in flight, probably quite high given it no longer has the motors keeping it stable. It still uses the 5s re-arming window but given the way it now works this could possibly be scrapped completely if the in flight check is reliable enough. (still need to commit the change) |
I tested it again under controlled conditions.. This method appears to be a nice balance. I haven't tried disarming it at altitude or at a higher speed.. It just feels too risky ATM. |
@breadoven I ran some test with both Fixed wing and Multicopter. Quad inflight rearming.
Fixed wing inflight rearming.
I tested disarming in Acro, Angle, Cruise, CH, RTH and WP.. With all working as expected. Besides ACRO on a fixed wing when its disarmed.. I have two other recommendations that would help.
All in all, Great work ! |
Do you mean it took a few seconds to detect a landing, or just that it was possible to emergency rearm for a few seconds after landing, something that wasn't possible if no in flight rearm had occurred ?
Was this on the ground, in flight or both ? Not sure how this could happen unless Manual mode was activated in some way. Nothing in this change should affect how Manual mode works. Guess I can check it again myself on HITL. And I agree about the arming screen. I'll see how easy it is to reduce the display duration. Not sure about the Programming logic functions, sounds a bit more complicated to prevent problems there. At the end of the day if you mistakenly disarm in flight being able to recover the model should be the main consideration. Thanks for testing again. Did you use the crash cage on the quad ? |
It detected the disarm instantly in flight, which is good... It was the second part you asked above.. Which I thought was fine..
It was inflight.. I didn't actually ground test the airplane first.. This plane doesn't have a logger.. And unfortunately the Arming screen covers the mode selection on the OSD too,. So I can't look at that..
No problem.. The TPU cage was a little heavy for the poor old quad.. But fortunately your a clever guy, and got the flight detector coding correct.. So it wasn't needed. |
I made a change to prevent emergency rearm working if a landing has been detected, something that definitely shouldn't be possible. The OSD arming screen issue is caused by Safehomes which increases the display time from 1.5s to 4.5s. It's not easy to change this so given accidental disarm isn't something that will happen very often I don't think it's worth fixing. |
I’m currently looking at arming screens for a different PR. In that PR, I’m allowing for the arm screen time to be set in CLI. So having a short override for an inflight rearm would be useful. There could be a REARMED_IN_FLIGHT flag set upon inflight rearm and cleared at disarm. It would be simple to check that and handle the arming screen appropriately. This way, the arming screen could be:
This flag could also be used to decide if the programming framework is reset or not. I think the more things that continue as if the flight hadn’t been interrupted, the better. |
I had a look over this again. And used the analogue DVR. |
Rearming in flight will not have any effect on the home point. It hasn’t since about version 2.0; when home position reset was defaulted to first arm. You would need to disconnect the battery. Then the home position will be set on the next arm. |
You can set the Home position to update every arm if you select that option so this would be an issue. Not sure why you'd want to change Home every arm though and I'd have thought most people stick to the default of 1st Arm only. The only reason Manual mode might become active without the mode being selected is if the sensors are calibrating. There's no reason for the sensors to recalibrate on arming so I can't see how Manual could have become active during an in flight rearm. Having a REARMED_IN_FLIGHT flag would be the easiest way of handling things although Arming flags seem to be down to 2 bits and one of them seems to be reserved. The only other option would be a general state flag which is probably OK. Although this wouldn't help in all cases because some things get reset on disarm. |
Exactly! On fixed wing it indeed doesn't make much sense to change the home position on every arm, but on multi-copters it does. For example, you are in a flying field with some people, cars, obstacles nearby your first arm position. You can arm, briefly fly some distance to a clearer part of the field, land, disarm and arm again so that "new" home position is the actual return point in case of an RTH. By doing this you reduce the risk of the craft hitting something or someone during the automated landing sequence. |
This is what the home reset mode is for. No need to risk an in flight disarm resetting the home point. You can fly to where you want the home point. Trigger the home reset mode. You don’t even need to land, let alone disarm. Then carry on with your flight. Best of both worlds. |
Oh!! I wasn't aware of this feature!! It indeed sounds great!!! For sure, best of both worlds. Awesome! |
Added a flag to indicate emergency in flight rearming which is used to prevent the home position and reference altitude resetting, logic conditions resetting and also reduces the arming screen display time to 1/3 of the normal time, i.e. 0.5s just to give brief indication craft has rearmed. The flag resets 1s after arming once it's done its job. Preventing the home position and altitude reference from resetting isn't easy because they're normally constantly reset when disarmed (depending on the reset setting used). To avoid this causing a problem during an emergency rearm the logic has been changed so home position and reference altitude are constantly reset only before the first arm but for subsequent rearms they are reset immediately after arming. This happens within a fraction of a second after arming so shouldn't affect things in any obvious way other than altitudes noticeably recalibrating for a second or so. Seems to test OK in HITL. Edit: Also noticed Programming/Logic stuff is reset not only on Arm but also on Disarm so the fix here doesn't work since it only works on Arming. Fixing the Disarm reset is more problematic. |
No problem.. Thanks for the heads-up.. I won't test it again until this is sorted. |
The issues mentioned above have been fixed now except for the logic conditions. Can't really see how to fix that unless you don't reset them on disarm. Is this necessary or just a belt and braces reset @DzikuVx ? I tested the Home position and Altitude reference resets on HITL and it now appears to work as required. Might have also fixed a bug if you had reset Home Each Arm but reset Altitude only on First Arm ... which messes up the OSD MSL altitude display. Changing the reference altitude to gpsOrigin seems to fix this and makes more sense than the Home reference altitude used previously. |
I see no reason to reset them. Surely a reboot by disconnecting and reconnecting the battery is good enough. When would you ever want to reset your logic states when powered?? In flight disarming also causes a problem with both analogue and digital VTX's reverting to low power mode. I'm aware that one uses |
I think this can be merged now. The outstanding issues regarding Logic conditions resetting and HD VTX low power on disarm can be fixed separately. |
This feature just saved my quad today. Big thanks @breadoven 🫡 |
I generated some test data for this issue today ;) I turned on https://drive.google.com/file/d/1T9uLWiTPyu61En0Iby_PLuAP0nXPPb5N/view?usp=sharing Hopefully almost nothing happened with my quad... Just right door was broken and little scratches on props when quad hit on the sugar beet after falling from 38m ;) |
@Macianno There is a change for 8.0 that should stop this problem with the G bump detection and would have stopped it in this case, see https://github.com/iNavFlight/inav/pull/10138/files. Only allows G Bump detection to work below 1m/s horizontal velocity which is way below the 12 m/s your quad was doing when it disarmed. In flight rearm is currently limited to disarming by switch only. This is the only way in flight disarm should happen if everything else is working as expected. |
@breadoven Thank you for this explanation. Can you explain to me how |
|
Similar to #8736 but allows for rapid rearm without any arming checks and for a limited timeout period only, currently set at 5s.
Works on the basis of checking if flight was flagged at takeoff with no landing detected since + an additional sanity check on whether the craft still appears to be in flight. Multirotor flight sanity is checked after disarm based on vertical velocity ... if there is none 1.5s after disarming then it's probably not flying so emergency disarm is cancelled. Angle is activated for 5s after an emergency rearm on a multirotor to try and avoid it flying off unpredictably. Change also prevents Nav Launch from activating after an in flight rearm.
The 5s rearm window could be changed to a setting if need be.