-
Notifications
You must be signed in to change notification settings - Fork 13.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
Commander: complete thread cycle before emergency shutdown #9563
Commander: complete thread cycle before emergency shutdown #9563
Conversation
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'm ok with the change, although adding another flag to commander is not ideal.
src/modules/commander/commander.cpp
Outdated
int ret_val = px4_shutdown_request(false, false); | ||
|
||
if (ret_val) { | ||
mavlink_log_critical(&mavlink_log_pub, "SYSTEM DOES NOT SUPPORT SHUTDOWN"); |
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.
Here we need to reset the flag dangerous_battery_level_requests_poweroff
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.
Right, thanks 👍
src/modules/commander/commander.cpp
Outdated
@@ -2747,6 +2740,20 @@ Commander::run() | |||
|
|||
arm_auth_update(now, params_updated || param_init_forced); | |||
|
|||
// Handle shutdown request from emergency battery action | |||
if(dangerous_battery_level_requests_poweroff){ |
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.
There's a minimal chance that the system is armed now, so that should be handled.
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.
Ooh good catch!! I will add it.
I agree, but could not think of something better. Hence why this is just a proposal, open for discussion :)
Edit: Just saw that the flag is needed in case when the shutdown is not supported. Never mind! |
Alternatively we could also move the whole battery check to the end of the |
d2d0c29
to
e4c110e
Compare
Problem: When an emergency landing occurs as part of the battery failsafe, the vehicle will shutdown immediately after landing.
https://github.com/PX4/Firmware/blob/1ee08da9c4182f7e30c2b39462bdead069c9c588/src/modules/commander/commander.cpp#L1964-L1972
However, many state updates like
vehicle_status.msg
are published at the very end of the cycle:https://github.com/PX4/Firmware/blob/1ee08da9c4182f7e30c2b39462bdead069c9c588/src/modules/commander/commander.cpp#L2632-L2677
In case of an emergency landing, the code in the second snippet for the updates is not executed, once disarmed. This means that QGC does not register the landed state and last seen state will be the landing in progress. In our case, this appears as a communication loss mid-flight, because armed, which our app treats differently compared to a communication loss when disarmed and landed.
In regard of the new DroneSDK, I would imagine that other apps might run into similar problems.
The proposed solution in this PR is to finish the thread cycle and execute the shutdown command at the very end. It would probably make sense to do the same thing for all calls of
px4_shutdown_request()
in the commander to avoid similar problems in the future.@bkueng May I request your input? :)