mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
commander: use circuit breaker params directly in arming checks
This commit is contained in:
parent
4230eee24f
commit
13c93db11a
@ -120,9 +120,3 @@ bool avoidance_system_valid # Status of the obstacle avoid
|
||||
|
||||
bool battery_healthy # set if battery is available and not low
|
||||
|
||||
bool circuit_breaker_engaged_power_check
|
||||
bool circuit_breaker_engaged_airspd_check
|
||||
bool circuit_breaker_flight_termination_disabled
|
||||
bool circuit_breaker_engaged_usb_check
|
||||
bool circuit_breaker_vtol_fw_arming_check # set to true if for VTOLs arming in fixed-wing mode should be allowed
|
||||
|
||||
|
||||
@ -54,8 +54,3 @@ bool circuit_breaker_enabled(const char *breaker, int32_t magic)
|
||||
|
||||
return (param_get(param_find(breaker), &val) == 0) && (val == magic);
|
||||
}
|
||||
|
||||
bool circuit_breaker_enabled_by_val(int32_t breaker_val, int32_t magic)
|
||||
{
|
||||
return (breaker_val == magic);
|
||||
}
|
||||
|
||||
@ -63,7 +63,11 @@
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern "C" __EXPORT bool circuit_breaker_enabled(const char *breaker, int32_t magic);
|
||||
extern "C" __EXPORT bool circuit_breaker_enabled_by_val(int32_t breaker_val, int32_t magic);
|
||||
|
||||
static inline bool circuit_breaker_enabled_by_val(int32_t breaker_val, int32_t magic)
|
||||
{
|
||||
return breaker_val == magic;
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
@ -2607,7 +2607,7 @@ Commander::run()
|
||||
|
||||
/* Check for mission flight termination */
|
||||
if (_arm_state_machine.isArmed() && _mission_result_sub.get().flight_termination &&
|
||||
!_vehicle_status.circuit_breaker_flight_termination_disabled) {
|
||||
!_circuit_breaker_flight_termination_disabled) {
|
||||
|
||||
|
||||
if (!_flight_termination_triggered && !_lockdown_triggered) {
|
||||
@ -2717,7 +2717,7 @@ Commander::run()
|
||||
events::send(events::ID("commander_fd_lockdown"), {events::Log::Emergency, events::LogInternal::Warning},
|
||||
"Critical failure detected: lockdown");
|
||||
|
||||
} else if (!_vehicle_status.circuit_breaker_flight_termination_disabled &&
|
||||
} else if (!_circuit_breaker_flight_termination_disabled &&
|
||||
!_flight_termination_triggered && !_lockdown_triggered) {
|
||||
|
||||
_actuator_armed.force_failsafe = true;
|
||||
@ -3086,19 +3086,9 @@ Commander::run()
|
||||
void
|
||||
Commander::get_circuit_breaker_params()
|
||||
{
|
||||
_vehicle_status.circuit_breaker_engaged_power_check = circuit_breaker_enabled_by_val(_param_cbrk_supply_chk.get(),
|
||||
CBRK_SUPPLY_CHK_KEY);
|
||||
_vehicle_status.circuit_breaker_engaged_usb_check = circuit_breaker_enabled_by_val(_param_cbrk_usb_chk.get(),
|
||||
CBRK_USB_CHK_KEY);
|
||||
_vehicle_status.circuit_breaker_engaged_airspd_check = circuit_breaker_enabled_by_val(
|
||||
_param_cbrk_airspd_chk.get(),
|
||||
CBRK_AIRSPD_CHK_KEY);
|
||||
_vehicle_status.circuit_breaker_flight_termination_disabled = circuit_breaker_enabled_by_val(
|
||||
_circuit_breaker_flight_termination_disabled = circuit_breaker_enabled_by_val(
|
||||
_param_cbrk_flightterm.get(),
|
||||
CBRK_FLIGHTTERM_KEY);
|
||||
_vehicle_status.circuit_breaker_vtol_fw_arming_check = circuit_breaker_enabled_by_val(
|
||||
_param_cbrk_vtolarming.get(),
|
||||
CBRK_VTOLARMING_KEY);
|
||||
}
|
||||
|
||||
void Commander::check_and_inform_ready_for_takeoff()
|
||||
|
||||
@ -314,6 +314,7 @@ private:
|
||||
bool _geofence_warning_action_on{false};
|
||||
bool _geofence_violated_prev{false};
|
||||
|
||||
bool _circuit_breaker_flight_termination_disabled{false};
|
||||
|
||||
bool _rtl_time_actions_done{false};
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "airspeedCheck.hpp"
|
||||
#include <lib/circuit_breaker/circuit_breaker.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
@ -42,7 +43,7 @@ AirspeedChecks::AirspeedChecks()
|
||||
|
||||
void AirspeedChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
{
|
||||
if (context.status().circuit_breaker_engaged_airspd_check ||
|
||||
if (circuit_breaker_enabled_by_val(_param_cbrk_airspd_chk.get(), CBRK_AIRSPD_CHK_KEY) ||
|
||||
(context.status().vehicle_type != vehicle_status_s::VEHICLE_TYPE_FIXED_WING && !context.status().is_vtol)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ private:
|
||||
const param_t _param_fw_airspd_trim_handle;
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||
(ParamInt<px4::params::CBRK_AIRSPD_CHK>) _param_cbrk_airspd_chk,
|
||||
(ParamBool<px4::params::COM_ARM_ARSP_EN>) _param_com_arm_arsp_en
|
||||
)
|
||||
};
|
||||
|
||||
@ -32,12 +32,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "powerCheck.hpp"
|
||||
#include <lib/circuit_breaker/circuit_breaker.h>
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
void PowerChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
{
|
||||
if (context.status().circuit_breaker_engaged_power_check) {
|
||||
if (circuit_breaker_enabled_by_val(_param_cbrk_supply_chk.get(), CBRK_SUPPLY_CHK_KEY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ private:
|
||||
uORB::Subscription _system_power_sub{ORB_ID(system_power)};
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||
(ParamInt<px4::params::CBRK_SUPPLY_CHK>) _param_cbrk_supply_chk,
|
||||
(ParamInt<px4::params::COM_POWER_COUNT>) _param_com_power_count
|
||||
)
|
||||
};
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include "systemCheck.hpp"
|
||||
|
||||
#include "../../Arming/ArmAuthorization/ArmAuthorization.h"
|
||||
#include <lib/circuit_breaker/circuit_breaker.h>
|
||||
#include <uORB/topics/vehicle_command_ack.h>
|
||||
|
||||
void SystemChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
@ -54,7 +55,7 @@ void SystemChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
}
|
||||
|
||||
// USB not connected
|
||||
if (!context.status().circuit_breaker_engaged_usb_check && context.status().usb_connected) {
|
||||
if (!circuit_breaker_enabled_by_val(_param_cbrk_usb_chk.get(), CBRK_USB_CHK_KEY) && context.status().usb_connected) {
|
||||
/* EVENT
|
||||
* @description
|
||||
* Flying with USB is not safe. Disconnect it and reboot the FMU.
|
||||
@ -206,7 +207,7 @@ void SystemChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
}
|
||||
}
|
||||
|
||||
if (!context.status().circuit_breaker_vtol_fw_arming_check
|
||||
if (!circuit_breaker_enabled_by_val(_param_cbrk_vtolarming.get(), CBRK_VTOLARMING_KEY)
|
||||
&& context.status().vehicle_type != vehicle_status_s::VEHICLE_TYPE_ROTARY_WING) {
|
||||
/* EVENT
|
||||
* @description
|
||||
|
||||
@ -50,6 +50,8 @@ private:
|
||||
uORB::Subscription _actuator_armed_sub{ORB_ID(actuator_armed)};
|
||||
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||
(ParamInt<px4::params::CBRK_VTOLARMING>) _param_cbrk_vtolarming,
|
||||
(ParamInt<px4::params::CBRK_USB_CHK>) _param_cbrk_usb_chk,
|
||||
(ParamBool<px4::params::COM_ARM_MIS_REQ>) _param_com_arm_mis_req,
|
||||
(ParamBool<px4::params::COM_ARM_WO_GPS>) _param_com_arm_wo_gps,
|
||||
(ParamBool<px4::params::COM_ARM_CHK_ESCS>) _param_com_arm_chk_escs,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user