mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 07:00:34 +08:00
battery: make time remaining estimation dependent on level flight cha… (#22401)
* battery: make time remaining estimation dependent on level flight characteristis for FW * battery: fix that FW flight is also correctly detected when vehicle_status is not updated Signed-off-by: Silvan Fuhrer <silvan@auterion.com> * FixedwingPositionControl: Move constant to header file * flight phase estimation: use tecs height rate reference to check for level flight --------- Signed-off-by: Silvan Fuhrer <silvan@auterion.com> Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
@@ -2454,6 +2454,9 @@ FixedwingPositionControl::Run()
|
||||
_flaps_setpoint = 0.f;
|
||||
_spoilers_setpoint = 0.f;
|
||||
|
||||
// reset flight phase estimate
|
||||
_flight_phase_estimation_pub.get().flight_phase = flight_phase_estimation_s::FLIGHT_PHASE_UNKNOWN;
|
||||
|
||||
// by default we don't want yaw to be contoller directly with rudder
|
||||
_att_sp.fw_control_yaw_wheel = false;
|
||||
|
||||
@@ -2569,6 +2572,10 @@ FixedwingPositionControl::Run()
|
||||
_roll_slew_rate.setForcedValue(_roll);
|
||||
}
|
||||
|
||||
// Publish estimate of level flight
|
||||
_flight_phase_estimation_pub.get().timestamp = hrt_absolute_time();
|
||||
_flight_phase_estimation_pub.update();
|
||||
|
||||
// if there's any change in landing gear setpoint publish it
|
||||
if (_new_landing_gear_position != old_landing_gear_position
|
||||
&& _new_landing_gear_position != landing_gear_s::GEAR_KEEP) {
|
||||
@@ -2672,6 +2679,28 @@ FixedwingPositionControl::tecs_update_pitch_throttle(const float control_interva
|
||||
hgt_rate_sp);
|
||||
|
||||
tecs_status_publish(alt_sp, airspeed_sp, airspeed_rate_estimate, throttle_trim_compensated);
|
||||
|
||||
if (_tecs_is_running && !_vehicle_status.in_transition_mode
|
||||
&& (_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING)) {
|
||||
const TECS::DebugOutput &tecs_output{_tecs.getStatus()};
|
||||
|
||||
// Check level flight: the height rate setpoint is not set or set to 0 and we are close to the target altitude and target altitude is not moving
|
||||
if ((fabsf(tecs_output.height_rate_reference) < MAX_ALT_REF_RATE_FOR_LEVEL_FLIGHT) &&
|
||||
fabsf(_current_altitude - tecs_output.altitude_reference) < _param_nav_fw_alt_rad.get()) {
|
||||
_flight_phase_estimation_pub.get().flight_phase = flight_phase_estimation_s::FLIGHT_PHASE_LEVEL;
|
||||
|
||||
} else if (((tecs_output.altitude_reference - _current_altitude) >= _param_nav_fw_alt_rad.get()) ||
|
||||
(tecs_output.height_rate_reference >= MAX_ALT_REF_RATE_FOR_LEVEL_FLIGHT)) {
|
||||
_flight_phase_estimation_pub.get().flight_phase = flight_phase_estimation_s::FLIGHT_PHASE_CLIMB;
|
||||
|
||||
} else if (((_current_altitude - tecs_output.altitude_reference) >= _param_nav_fw_alt_rad.get()) ||
|
||||
(tecs_output.height_rate_reference <= -MAX_ALT_REF_RATE_FOR_LEVEL_FLIGHT)) {
|
||||
_flight_phase_estimation_pub.get().flight_phase = flight_phase_estimation_s::FLIGHT_PHASE_DESCEND;
|
||||
|
||||
} else {
|
||||
//We can't infer the flight phase , do nothing, estimation is reset at each step
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/SubscriptionCallback.hpp>
|
||||
#include <uORB/topics/airspeed_validated.h>
|
||||
#include <uORB/topics/flight_phase_estimation.h>
|
||||
#include <uORB/topics/landing_gear.h>
|
||||
#include <uORB/topics/launch_detection_status.h>
|
||||
#include <uORB/topics/manual_control_setpoint.h>
|
||||
@@ -165,6 +166,9 @@ static constexpr float MANUAL_TOUCHDOWN_NUDGE_INPUT_DEADZONE = 0.15f;
|
||||
// [s] time interval after touchdown for ramping in runway clamping constraints (touchdown is assumed at FW_LND_TD_TIME after start of flare)
|
||||
static constexpr float POST_TOUCHDOWN_CLAMP_TIME = 0.5f;
|
||||
|
||||
// [m/s] maximum reference altitude rate threshhold
|
||||
static constexpr float MAX_ALT_REF_RATE_FOR_LEVEL_FLIGHT = 0.1f;
|
||||
|
||||
class FixedwingPositionControl final : public ModuleBase<FixedwingPositionControl>, public ModuleParams,
|
||||
public px4::WorkItem
|
||||
{
|
||||
@@ -215,6 +219,7 @@ private:
|
||||
uORB::Publication<landing_gear_s> _landing_gear_pub {ORB_ID(landing_gear)};
|
||||
uORB::Publication<normalized_unsigned_setpoint_s> _flaps_setpoint_pub{ORB_ID(flaps_setpoint)};
|
||||
uORB::Publication<normalized_unsigned_setpoint_s> _spoilers_setpoint_pub{ORB_ID(spoilers_setpoint)};
|
||||
uORB::PublicationData<flight_phase_estimation_s> _flight_phase_estimation_pub{ORB_ID(flight_phase_estimation)};
|
||||
|
||||
manual_control_setpoint_s _manual_control_setpoint{};
|
||||
position_setpoint_triplet_s _pos_sp_triplet{};
|
||||
@@ -388,6 +393,7 @@ private:
|
||||
TECS _tecs;
|
||||
|
||||
bool _tecs_is_running{false};
|
||||
|
||||
// VTOL / TRANSITION
|
||||
bool _is_vtol_tailsitter{false};
|
||||
matrix::Vector2d _transition_waypoint{(double)NAN, (double)NAN};
|
||||
|
||||
@@ -68,6 +68,7 @@ void LoggedTopics::add_default_topics()
|
||||
add_optional_topic("follow_target_estimator", 200);
|
||||
add_optional_topic("follow_target_status", 400);
|
||||
add_optional_topic("flaps_setpoint", 1000);
|
||||
add_optional_topic("flight_phase_estimation", 1000);
|
||||
add_topic("gimbal_manager_set_attitude", 500);
|
||||
add_optional_topic("generator_status");
|
||||
add_optional_topic("gps_dump");
|
||||
|
||||
Reference in New Issue
Block a user