Commander: make low remaining flight time configurable and fix clearing condition (#22863)

* Commander: make low remaining flight time configurable and do not clear

- add _ACT param to disable/warning/RTL this feature
- publish rtl flight time estimate also in RTL, and thus fix re-validation
- make failure message clearer, distinguish from battery low

* battery check: add hysteresis for declaring battery_low_remaining_time false again


---------

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
Co-authored-by: KonradRudin <98741601+KonradRudin@users.noreply.github.com>
This commit is contained in:
Silvan Fuhrer
2024-03-12 12:56:01 +01:00
committed by GitHub
co-authored by KonradRudin
parent 7fe5ee64fe
commit 00cc68baa1
9 changed files with 117 additions and 30 deletions
+38 -25
View File
@@ -208,32 +208,37 @@ void RTL::on_inactive()
if ((now - _destination_check_time) > 2_s) {
_destination_check_time = now;
setRtlTypeAndDestination();
const bool global_position_recently_updated = _global_pos_sub.get().timestamp > 0
&& hrt_elapsed_time(&_global_pos_sub.get().timestamp) < 10_s;
rtl_time_estimate_s estimated_time{};
estimated_time.valid = false;
if (_navigator->home_global_position_valid() && global_position_recently_updated) {
switch (_rtl_type) {
case RtlType::RTL_DIRECT:
estimated_time = _rtl_direct.calc_rtl_time_estimate();
break;
case RtlType::RTL_DIRECT_MISSION_LAND:
case RtlType::RTL_MISSION_FAST:
case RtlType::RTL_MISSION_FAST_REVERSE:
estimated_time = _rtl_mission_type_handle->calc_rtl_time_estimate();
break;
default:
break;
}
}
_rtl_time_estimate_pub.publish(estimated_time);
publishRemainingTimeEstimate();
}
}
void RTL::publishRemainingTimeEstimate()
{
const bool global_position_recently_updated = _global_pos_sub.get().timestamp > 0
&& hrt_elapsed_time(&_global_pos_sub.get().timestamp) < 10_s;
rtl_time_estimate_s estimated_time{};
estimated_time.valid = false;
if (_navigator->home_global_position_valid() && global_position_recently_updated) {
switch (_rtl_type) {
case RtlType::RTL_DIRECT:
estimated_time = _rtl_direct.calc_rtl_time_estimate();
break;
case RtlType::RTL_DIRECT_MISSION_LAND:
case RtlType::RTL_MISSION_FAST:
case RtlType::RTL_MISSION_FAST_REVERSE:
estimated_time = _rtl_mission_type_handle->calc_rtl_time_estimate();
break;
default:
break;
}
}
_rtl_time_estimate_pub.publish(estimated_time);
}
void RTL::on_activation()
@@ -287,6 +292,14 @@ void RTL::on_active()
default:
break;
}
// Keep publishing remaining time estimates every 2 seconds
hrt_abstime now{hrt_absolute_time()};
if ((now - _destination_check_time) > 2_s) {
_destination_check_time = now;
publishRemainingTimeEstimate();
}
}
void RTL::setRtlTypeAndDestination()
+6
View File
@@ -106,6 +106,12 @@ private:
void setRtlTypeAndDestination();
/**
* @brief Publish the remaining time estimate to go to the RTL landing point.
*
*/
void publishRemainingTimeEstimate();
/**
* @brief Find RTL destination.
*