mc_pos_control: simplify unnecessary complicated boolean conditions

This commit is contained in:
Matthias Grob
2017-10-06 10:49:43 +02:00
committed by Dennis Mannhart
parent e1b970c30d
commit c177d6491a

View File

@@ -809,22 +809,14 @@ MulticopterPositionControl::poll_subscriptions()
/* we need either a valid position setpoint or a valid velocity setpoint */ /* we need either a valid position setpoint or a valid velocity setpoint */
if (PX4_ISFINITE(_pos_sp_triplet.current.lat) && PX4_ISFINITE(_pos_sp_triplet.current.lon)
&& PX4_ISFINITE(_pos_sp_triplet.current.alt) && _pos_sp_triplet.current.valid) {
_pos_sp_triplet.current.valid = true;
} else if (PX4_ISFINITE(_pos_sp_triplet.current.alt) && _pos_sp_triplet.current.valid) { if (!PX4_ISFINITE(_pos_sp_triplet.current.alt)) {
_pos_sp_triplet.current.valid = true;
} else {
_pos_sp_triplet.current.valid = false; _pos_sp_triplet.current.valid = false;
} }
if (PX4_ISFINITE(_pos_sp_triplet.previous.lat) && PX4_ISFINITE(_pos_sp_triplet.previous.lon) if (!PX4_ISFINITE(_pos_sp_triplet.previous.lat) ||
&& PX4_ISFINITE(_pos_sp_triplet.previous.alt) && _pos_sp_triplet.previous.valid) { !PX4_ISFINITE(_pos_sp_triplet.previous.lon) ||
_pos_sp_triplet.previous.valid = true; !PX4_ISFINITE(_pos_sp_triplet.previous.alt)) {
} else {
_pos_sp_triplet.previous.valid = false; _pos_sp_triplet.previous.valid = false;
} }
} }
@@ -3132,10 +3124,12 @@ MulticopterPositionControl::task_main()
* attitude setpoints for the transition). * attitude setpoints for the transition).
* - if not armed * - if not armed
*/ */
if (_control_mode.flag_armed && (!(_control_mode.flag_control_offboard_enabled &&
!(_control_mode.flag_control_position_enabled || if (_control_mode.flag_armed &&
_control_mode.flag_control_velocity_enabled || (!(_control_mode.flag_control_offboard_enabled &&
_control_mode.flag_control_acceleration_enabled)))) { !(_control_mode.flag_control_position_enabled ||
_control_mode.flag_control_velocity_enabled ||
_control_mode.flag_control_acceleration_enabled)))) {
if (_att_sp_pub != nullptr) { if (_att_sp_pub != nullptr) {
orb_publish(_attitude_setpoint_id, _att_sp_pub, &_att_sp); orb_publish(_attitude_setpoint_id, _att_sp_pub, &_att_sp);