mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 11:06:04 +08:00
commander: try to fix arm authorization spamming
Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
@@ -594,7 +594,7 @@ transition_result_t Commander::arm(arm_disarm_reason_t calling_reason, bool run_
|
|||||||
return TRANSITION_DENIED;
|
return TRANSITION_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
_health_and_arming_checks.update();
|
_health_and_arming_checks.update(false, true);
|
||||||
|
|
||||||
if (!_health_and_arming_checks.canArm(_vehicle_status.nav_state)) {
|
if (!_health_and_arming_checks.canArm(_vehicle_status.nav_state)) {
|
||||||
tune_negative(true);
|
tune_negative(true);
|
||||||
|
|||||||
@@ -128,10 +128,15 @@ public:
|
|||||||
|
|
||||||
bool isArmed() const { return _status.arming_state == vehicle_status_s::ARMING_STATE_ARMED; }
|
bool isArmed() const { return _status.arming_state == vehicle_status_s::ARMING_STATE_ARMED; }
|
||||||
|
|
||||||
|
bool isArmingRequest() const { return _is_arming_request; }
|
||||||
|
|
||||||
|
void setIsArmingRequest(bool is_arming_request) { _is_arming_request = is_arming_request; }
|
||||||
|
|
||||||
const vehicle_status_s &status() const { return _status; }
|
const vehicle_status_s &status() const { return _status; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const vehicle_status_s &_status;
|
const vehicle_status_s &_status;
|
||||||
|
bool _is_arming_request{false}; // true if we currently have an arming request
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,12 +50,14 @@ HealthAndArmingChecks::HealthAndArmingChecks(ModuleParams *parent, vehicle_statu
|
|||||||
_failsafe_flags.home_position_invalid = true;
|
_failsafe_flags.home_position_invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HealthAndArmingChecks::update(bool force_reporting)
|
bool HealthAndArmingChecks::update(bool force_reporting, bool is_arming_request)
|
||||||
{
|
{
|
||||||
_reporter.reset();
|
_reporter.reset();
|
||||||
|
|
||||||
_reporter.prepare(_context.status().vehicle_type);
|
_reporter.prepare(_context.status().vehicle_type);
|
||||||
|
|
||||||
|
_context.setIsArmingRequest(is_arming_request);
|
||||||
|
|
||||||
for (unsigned i = 0; i < sizeof(_checks) / sizeof(_checks[0]); ++i) {
|
for (unsigned i = 0; i < sizeof(_checks) / sizeof(_checks[0]); ++i) {
|
||||||
if (!_checks[i]) {
|
if (!_checks[i]) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -83,9 +83,10 @@ public:
|
|||||||
* Run arming checks and report if necessary.
|
* Run arming checks and report if necessary.
|
||||||
* This should be called regularly (e.g. 1Hz).
|
* This should be called regularly (e.g. 1Hz).
|
||||||
* @param force_reporting if true, force reporting even if nothing changed
|
* @param force_reporting if true, force reporting even if nothing changed
|
||||||
|
* @param is_arming_request if true, then we are running the checks based on an actual arming request
|
||||||
* @return true if there was a report (also when force_reporting=true)
|
* @return true if there was a report (also when force_reporting=true)
|
||||||
*/
|
*/
|
||||||
bool update(bool force_reporting = false);
|
bool update(bool force_reporting = false, bool is_arming_request = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether arming is possible for a given navigation mode
|
* Whether arming is possible for a given navigation mode
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ void SystemChecks::checkAndReport(const Context &context, Report &reporter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Arm Requirements: authorization
|
// Arm Requirements: authorization
|
||||||
if (_param_com_arm_auth_req.get() != 0 && !context.isArmed()) {
|
if (_param_com_arm_auth_req.get() != 0 && !context.isArmed() && context.isArmingRequest()) {
|
||||||
if (arm_auth_check() != vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED) {
|
if (arm_auth_check() != vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED) {
|
||||||
/* EVENT
|
/* EVENT
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user