FW Positon control: do not use position_setpoint.valid to validate current position_setpoint

Instead of checking the .valid flag of position_setpoint, check for ISFINITE() of lat, lon, alt
    when pulling the position_setpoint triplet. This fixes problems where the .valid flag didn't
    reflect the proper state of the setpoint (e.g. .valid was true, .lat though NAN)

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer
2022-10-21 09:51:38 +02:00
parent d8e483ae20
commit 67b2c835e0
2 changed files with 27 additions and 13 deletions
@@ -222,6 +222,10 @@ private:
vehicle_local_position_s _local_pos{};
vehicle_status_s _vehicle_status{};
bool _position_setpoint_previous_valid{false};
bool _position_setpoint_current_valid{false};
bool _position_setpoint_next_valid{false};
perf_counter_t _loop_perf; // loop performance counter
// [us] Last absolute time position control has been called
@@ -664,9 +668,8 @@ private:
* May also change the position setpoint type depending on the desired behavior.
*
* @param now Current system time [us]
* @param pos_sp_curr_valid True if the current position setpoint is valid
*/
void set_control_mode_current(const hrt_abstime &now, bool pos_sp_curr_valid);
void set_control_mode_current(const hrt_abstime &now);
/**
* @brief Compensate trim throttle for air density and vehicle weight.