mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 17:23:34 +08:00
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:
co-authored by
KonradRudin
parent
7fe5ee64fe
commit
00cc68baa1
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user