mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 21:53:34 +08:00
Updated code style to fix confusing if conditions
This commit is contained in:
committed by
Julian Oes
parent
a134da6e12
commit
714c90b9db
@@ -1407,14 +1407,18 @@ Commander::run()
|
||||
status.system_type = (uint8_t)system_type;
|
||||
}
|
||||
|
||||
bool is_rotary = is_rotary_wing(&status) || (is_vtol(&status) && vtol_status.vtol_in_rw_mode);
|
||||
bool is_fixed = is_fixed_wing(&status) || (is_vtol(&status) && !vtol_status.vtol_in_rw_mode);
|
||||
bool is_ground = is_ground_rover(&status);
|
||||
|
||||
/* disable manual override for all systems that rely on electronic stabilization */
|
||||
if (is_rotary_wing(&status) || (is_vtol(&status) && vtol_status.vtol_in_rw_mode)) {
|
||||
if (is_rotary) {
|
||||
status.vehicle_type = vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
|
||||
} else if (is_fixed_wing(&status) || is_vtol(&status)) {
|
||||
} else if (is_fixed) {
|
||||
status.vehicle_type = vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
|
||||
} else if (is_ground_rover(&status)) {
|
||||
} else if (is_ground) {
|
||||
status.vehicle_type = vehicle_status_s::VEHICLE_TYPE_GROUND;
|
||||
}
|
||||
|
||||
@@ -1638,7 +1642,9 @@ Commander::run()
|
||||
if (is_vtol(&status)) {
|
||||
|
||||
// Check if there has been any change while updating the flags
|
||||
if ((status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) != vtol_status.vtol_in_rw_mode) {
|
||||
bool is_rotary = status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
|
||||
if (is_rotary != vtol_status.vtol_in_rw_mode) {
|
||||
status.vehicle_type = vtol_status.vtol_in_rw_mode ?
|
||||
vehicle_status_s::VEHICLE_TYPE_ROTARY_WING :
|
||||
vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
@@ -1660,7 +1666,9 @@ Commander::run()
|
||||
status_changed = true;
|
||||
}
|
||||
|
||||
if (armed.soft_stop != (status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING)) {
|
||||
const bool is_not_rotary_wing = (status.vehicle_type != vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
|
||||
|
||||
if (armed.soft_stop != is_not_rotary_wing) {
|
||||
armed.soft_stop = status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING;
|
||||
status_changed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user