Skip to content
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

Fix: In Fixedwing, when RC is lost in MANUAL mode and throttle is red, the motor keeps turning with the last commanded throttle and does not go to RC_LOST_MODE #2287

Merged
merged 1 commit into from Oct 8, 2018

Conversation

dewagter
Copy link
Member

Solves #2286

@dewagter
Copy link
Member Author

  • if RC lost while in manual, then always set the RC_LOST_MODE

  • if RC_LOST_MODE is AP_MODE_HOME, then when not launched, this it will be killed HOME mode which is no problem

  • if you were in NAV mode, nothing changes

  • if you want to go to NAV mode on RC loss, this can be set

  • so I see no reason why not to always check the safety, and I do see big risks

@dewagter dewagter changed the title Fix rc lost in manual auto1 Fix: In Fixedwing, when RC is lost in MANUAL mode and throttle is red, the motor keeps turning with the last commanded throttle and does not go to RC_LOST_MODE Jun 28, 2018
@dewagter
Copy link
Member Author

Any objection to merge this?

Copy link
Member

@gautierhattenberger gautierhattenberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I can see here, is that if you enter HOME mode on the ground, you have no guarantee that the throttle is killed. It means that you'll have stabilization + nav + throttle, which is even worse, than the problem you want to solve:
If you are in MAN + RC_LOST + throttle but not launched, it may start flying, but when launch becomes true, it will enter HOME in kill mode -> no more throttle.
I think we need a solution that cuts the throttle without changing the mode when launch is false and RC is lost.

@dewagter
Copy link
Member Author

I personally think it is worse that on RC loss in MANUAL you do NOT enter the configured RC_LOST_MODE because it creates danger for third parties in normal operating conditions while the throttle on the ground HOME MODE creates danger for yourself in bad practice conditions. Now without GPS or in case of GPS problem, or in case you get RC loss with high headwind you do not enter the RC_LOST_MODE.

First, if you are in manual mode, it is good practice to switch off you plane before your transmitter.
But to reduce chances of personal damage due to HOME modes being triggered after landing and switching off the RC while in MANUAL, I would prefer another solution like:

on RC-LOSS with zero throttle from MANUAL or AUTO1 and entering HOME_MODE then kill.

@dewagter dewagter force-pushed the fix_rc_lost_in_manual_auto1 branch from e21d951 to 2b10abc Compare June 29, 2018 06:18
@dewagter
Copy link
Member Author

dewagter commented Jun 29, 2018

Here is a new proposition: (see code)

  • RC_LOST_MODE will always activate from MANUAL or AUTO1, no exceptions. Even without GPS, even without launch, also during static testing on the ground while doing safety checks before take-off, etc... ALWAYS.
  • When on the ground in manual, there was a risk of accidentally entering HOME mode (with throttle) when the RC was switched off before the plane (if launch was set). To solve this problem, when entering RC_LOST_MODE, if the throttle was OFF, then the throttle is killed, so even in HOME or NAV mode, the plane will not throttle up. If you switch off your RC from manual/auto1 after landing, it will never throttle up.

@dewagter dewagter force-pushed the fix_rc_lost_in_manual_auto1 branch from 2b10abc to d3d15fa Compare June 29, 2018 06:29
@gautierhattenberger
Copy link
Member

If I got it right, If you are running the motor on ground in manual and loose the RC, it will enter HOME with throttle, which is not completely solving the initial issue

@dewagter
Copy link
Member Author

Yes, you are right:

  • if you are on the ground in MANUAL
  • after a flight or having launch=1 (which is not the case when you power up your fixedwing)
  • and you switch off your RC WHILE giving throttle

Then, HOME mode will become active without kill mode, and throttle, (which you already had) will increase to HOME-MODE throttle values.

The current situation is when you lose RC in manual with throttle, than throttle also stays on.

@dewagter
Copy link
Member Author

@gautierhattenberger : if you have another suggestion, you are very welcome but:

  • Right now we are not allowed to fly with master in fixed-wing as it fails basic safety checks***.
  • Even worse: the problem you mention (sudden throttle on ground due to HOME mode on RC loss) can ALSO happen with the current master code: namely if you pressed launch in the GCS or have flown with GPS before the RC loss.
  • Finally, the exceptions based on certain conditions make it hard to explain to users.

This pull request solves all this and makes nothing worse as far as I can see. The behavior becomes:

    1. simple rule: RC lost in MANUAL/AUTO1 -> RC_LOST_MODE. Always. Like it was in 2005.
    1. simple rule: RC lost without throttle, then throttle stays off. Always.

*** every model airfield wants to see: turn on the transmitter, turn on plane, give a bit of throttle, turn off the transmitter, the throttle must turn off. right now paparazzi fixed-wing does not do that.

@gautierhattenberger
Copy link
Member

For now, I don't have a magic solution. What is really annoying me is that an aircraft not kill in MAN with a bit of throttle, in case of RC lost will:

  • keep the current throttle (current situation, not satisfactory)
  • switch to RC_LOST, so most likely HOME which will increase the throttle to try to climb to safe alt (your proposed modification)

I can see big issues in both case.
Something we could do at least (close to your second rule): when RC is lost in MAN before takeoff, don't switch to RC_LOST/HOME (current behavior) but at least stop throttle if kill mode is still enabled.

@dewagter
Copy link
Member Author

dewagter commented Jul 2, 2018

With this pull request: if you lose RC with a bit of throttle BEFORE launch, then it switches to HOME mode WITHOUT throttle.

Without this pull request, with a bit of throttle, on RC_LOST, then throttle stays until RC is restored. Even the kill button on the ground station does not work.

The only problem that remains is that after launch (and if you flightplan did not have kill on land), if you had throttle in RC while losing RC, and you have RC_LOST_MODE as HOME or NAV and you have good GPS, then will it throttle up, while before this pull request it would stay at the last received RC throttle value. However, IMHO, this is not a normal condition:

Normal use conditions:

  • switching off your plane before your transmitter is the best practice in any mode (no problem)
  • switching off your transmitter before your plane without throttle (now solved: throttle will always stay off: before it would go to RC_LOST mode since launch is active)
  • switching off your transmitter with throttle on, before launch (solved: with PR: it enters RC_LOST_MODE + launch(0) = no throttle. Current situation is last manual throttle command is FROZEN, GCS can not kill)
  • real RC-loss on a long final in MAN/AUTO1 mode = RC_LOST_MODE (same as now in most cases, but now there are exceptions, and this PR removes them)

Problem cases:

  1. Real RC loss in flight at a moment where zero manual throttle is given (which can happen in fixedwing), but the pilot expects HOME mode (now the plane will be in kill mode; you need to unkill through telemetry)
  2. Real RC loss while taxing back from the landing location with a bit of throttle: the plane might take-off again while entering HOME. Do you have experience with this? Since the transmitter is close, we never had this before.
  3. Very bad practice situation where the pilot is in MANUAL, gives throttle after a flight which did not do AUTO2 landing with a kill throttle at the end and switches off his transmitter expecting the throttle will switch off. To me, this case can be neglected.

Possible solutions:

  • add a landing detector like in rotorcraft to give the safest response both in flight and on the ground (risk: get false detections inflight)

@gautierhattenberger
Copy link
Member

I agree that the proper solution would be an efficient and robust "in_flight" detector, which is not so easy on a fixedwing platform. I guess we could start listing the possible criteria for this.

Some comments:

  • the autopilot_set_motors_on function is empty on fixedwing firmware at the moment, the only way to stop the motor is to overwrite the throttle command I think (we could change this of course).
  • the threshold on 1% is really low and barely never happen if you move the throttle stick by hand

What about:

if (rc_lost_while_in_use) {
 if (launch) {
  mode_changed = autopilot_set_mode(RC_LOST_MODE);
 } else {
   autopilot_set_motors_on(false); /* assuming the function is implemented... */
 }
}

So if RC is lost in MAN/AUTO1, go to RC_LOST_MODE unless you have not start flying (then stop motors). Problems that may arise after flight are less likely to happen as you said, and a "in_flight" detection might improve this later.

@dewagter
Copy link
Member Author

dewagter commented Jul 3, 2018

  • as far as I can see, autopilot_set_motors_on from autopilot.c calls the autopilot_static_set_motors_on (which is empty in fixedwing) but also sets autopilot.kill_throttle which should set the v_ctl_throttle_setpoint to zero. Will test again.

@dewagter
Copy link
Member Author

Any idea to reintegrate this pull request? We can not fly fixedwing with master until this is fixed. Our minimum viable requirement is:

  • before takeoff, in manual, when throttle is applied and the RC is lost, then throttle is removed.

(This should also solve the fly-away condition that master has now when flying without GPS: then inflight is not set and throttle stays with stabilization)

@dewagter
Copy link
Member Author

Extra detail: we set RC_LOST_MODE to failsafe.

@gautierhattenberger
Copy link
Member

what about the last code I proposed ? if rc lost and not launched, turn off motor (either directly or by implementing the proper function in autopilot.c if setting kill_throttle is not enough)

@gautierhattenberger
Copy link
Member

side note: with autopilot generation, you can define the failsafe behavior you like ;)

@gautierhattenberger
Copy link
Member

After checking, the kill_throttle is only here to prevent the AP to use the motor (so in AUTO2 and above), MAN and AUTO1 are not affected. So it is not exactly the same thing than rotorcraft where motors_on(false) should turn them off in all modes.
It means that it might be necessary to explicitly set throttle command to 0 if mode is MAN/AUTO1 and RC_LOST and not launched (and set AP to RC_LOST_MODE if launch is true).

@gautierhattenberger gautierhattenberger added Airborne Blocking an issue that is essential to use of paparazzi Fixedwing labels Sep 12, 2018
@dewagter
Copy link
Member Author

@gautierhattenberger Your proposed solution would be an improvement compared to the current master.

Nevertheless, I still think it has several problems:

  • the GCS shows an undefined mode
  • when RC_LOST_MODE is failsafe, the throttle is cut but the failsafe actuators are not set
  • when no GPS is plugged, then launch is not set

The only logical solution to me (and the ones I asked) is

  • RC lost while in use => RC_LOST_MODE (ALWAYS)
  • If RC_LOST_MODE == mode that can set throttle => extra safety to avoid setting throttle on the ground, e.g. with a launch == 0 -> kill and maybe additionally kill if rc_throttle == 0 for after manual landings.

@gautierhattenberger
Copy link
Member

So something like

if (rc_lost_while_in_use) {
  mode_changed = autopilot_set_mode(RC_LOST_MODE);
}

and replace https://github.com/paparazzi/paparazzi/blob/master/sw/airborne/firmwares/fixedwing/autopilot_static.c#L235
with

if (autopilot.launch) {
  nav_home();
} else {
  stop motor
}

?

…en pressed. When not launched, the RC_LOST_MODE is not set and throttle is kept from the last manual input. Solves #2286
@dewagter
Copy link
Member Author

dewagter commented Oct 8, 2018

  • RC lost when in use? -> Always activate RC_LOST_MODE
  • RC_LOST_MODE == MANUAL: works fine if you configure your RC to send zero throttle like in model aircraft
  • RC_LOST_MODE == NAV? If you selected this, then go to NAV. If NAV gives throttle, that is because you asked it to...
  • RC_LOST_MODE == HOME_MODE: Home mode should not give throttle when on the ground. So a fix for Home mode was proposed.

Copy link
Member

@gautierhattenberger gautierhattenberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hopefully we won't have side effect...

CI builds failure are not related to PR

@gautierhattenberger gautierhattenberger merged commit 61fa239 into master Oct 8, 2018
@gautierhattenberger gautierhattenberger deleted the fix_rc_lost_in_manual_auto1 branch October 8, 2018 11:17
shuoli-robotics pushed a commit to shuoli-robotics/paparazzi that referenced this pull request Oct 15, 2018
…en pressed. When not launched, the RC_LOST_MODE is not set and throttle is kept from the last manual input. Solves paparazzi#2286 (paparazzi#2287)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Airborne Blocking an issue that is essential to use of paparazzi Fixedwing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants