-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
WIP: Fix FMU MC failsafe on RC loss #5388
Changes from all commits
0b5ffd6
ed2565c
8fdb5f9
757dea5
a1d835b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2833,19 +2833,21 @@ int commander_thread_main(int argc, char *argv[]) | |
internal_state.main_state == commander_state_s::MAIN_STATE_STAB || | ||
internal_state.main_state == commander_state_s::MAIN_STATE_ALTCTL || | ||
internal_state.main_state == commander_state_s::MAIN_STATE_POSCTL) && | ||
((status.rc_signal_lost && status_flags.gps_failure) || | ||
((status.rc_signal_lost /*&& status_flags.gps_failure*/) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want termination if we lose RC and still have GPS. The question is probably what the meaning of It could mean the following:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're in ACRO mode, flying manually and lose RC, currently you get "fly away" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually try to test this in SITL. I simulate GPS lost using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's hard to guess how things like commander are intended to work with over 5000 lines of code in one module and no documentation of design intent... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, the termination code is messed up and I'm guessing no one is really using it. I think it needs proper fixing. |
||
(status_flags.rc_signal_lost_cmd && status_flags.gps_failure_cmd))) { | ||
armed.force_failsafe = true; | ||
armed.lockdown = true; | ||
status_changed = true; | ||
static bool flight_termination_printed = false; | ||
|
||
if (!flight_termination_printed) { | ||
warnx("Flight termination because of RC signal loss and GPS failure"); | ||
PX4_WARN("Flight termination because of RC signal loss"); // and GPS failure"); | ||
flight_termination_printed = true; | ||
} | ||
|
||
if (counter % (1000000 / COMMANDER_MONITORING_INTERVAL) == 0) { | ||
mavlink_log_critical(&mavlink_log_pub, "RC and GPS lost: flight termination"); | ||
// mavlink_log_critical(&mavlink_log_pub, "RC and GPS lost: flight termination"); | ||
mavlink_log_critical(&mavlink_log_pub, "RC lost: flight termination"); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,7 @@ class MulticopterAttitudeControl | |
orb_id_t _actuators_id; /**< pointer to correct actuator controls0 uORB metadata structure */ | ||
|
||
bool _actuators_0_circuit_breaker_enabled; /**< circuit breaker to suppress output */ | ||
bool _termination_enabled; /**< true if flight termination circuit breaker not set */ | ||
|
||
struct control_state_s _ctrl_state; /**< control state */ | ||
struct vehicle_attitude_setpoint_s _v_att_sp; /**< vehicle attitude setpoint */ | ||
|
@@ -539,6 +540,7 @@ MulticopterAttitudeControl::parameters_update() | |
param_get(_params_handles.vtol_wv_yaw_rate_scale, &_params.vtol_wv_yaw_rate_scale); | ||
|
||
_actuators_0_circuit_breaker_enabled = circuit_breaker_enabled("CBRK_RATE_CTRL", CBRK_RATE_CTRL_KEY); | ||
_termination_enabled = !circuit_breaker_enabled("CBRK_FLIGHTTERM", CBRK_FLIGHTTERM_KEY); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should all be handled in the commander. And the output (fmu, px4io) drivers need to handle the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how fw_att_control works; I was just copying it without knowing whether the design was correct or fully tested :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where? I don't find armed or lockdown in the fw_pos and fw_att controllers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant handling nav_termination: instead of trying to assert lockdown, we should deploy a parachute or (somehow) kill motors here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think this is wrong because the |
||
|
||
return OK; | ||
} | ||
|
@@ -889,6 +891,12 @@ MulticopterAttitudeControl::task_main() | |
vehicle_status_poll(); | ||
vehicle_motor_limits_poll(); | ||
|
||
/* handle flight termination */ | ||
if (_termination_enabled && _v_control_mode.flag_control_termination_enabled) { | ||
// do something | ||
} | ||
|
||
|
||
/* Check if we are in rattitude mode and the pilot is above the threshold on pitch | ||
* or roll (yaw can rotate 360 in normal att control). If both are true don't | ||
* even bother running the attitude controllers */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did
_cycle_timestamp
not get updated in the RC lost case? If so that's a good catch!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I didn't realize the cause was the timestamp not being updated, maybe the mixing code should go back in the if block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah what was your change then? I was trying to find out what you fixed there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My change forces the output mixer to run even when the actuator topic is not being published.
The problem "Also, px4fmu quit running the output mixer when RC was lost." is due to the fact that the mixer was being run only on updates to the actuator topic(s). When commander asserts armed.force_failsafe, it appears that actuator values are no longer being published. How is this supposed to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solution to that is to either also watch the armed topic or enforce a minimum rate. Obviously the output is the combination of actuator and armed and so both need to be watched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I guess my FMU bugfix is correct, since it guarantees that actuator_outputs are published on every cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct like you changed it.