mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 20:33:34 +08:00
safety and safety button: refactoring #19413
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2019 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012-2022 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -35,20 +35,10 @@
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include <circuit_breaker/circuit_breaker.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/getopt.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/actuator_armed.h>
|
||||
#include <uORB/topics/safety.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
#include <uORB/topics/led_control.h>
|
||||
#include <uORB/topics/tune_control.h>
|
||||
#include <button/ButtonPublisher.hpp>
|
||||
|
||||
class SafetyButton : public ModuleBase<SafetyButton>, public px4::ScheduledWorkItem
|
||||
{
|
||||
@@ -65,34 +55,25 @@ public:
|
||||
/** @see ModuleBase */
|
||||
static int print_usage(const char *reason = nullptr);
|
||||
|
||||
/** @see ModuleBase::print_status() */
|
||||
int print_status() override;
|
||||
|
||||
int Start();
|
||||
|
||||
private:
|
||||
void Run() override;
|
||||
|
||||
void CheckButton();
|
||||
void FlashButton();
|
||||
void CheckSafetyRequest(bool button_pressed);
|
||||
void CheckPairingRequest(bool button_pressed);
|
||||
void FlashButton();
|
||||
|
||||
uORB::Subscription _armed_sub{ORB_ID(actuator_armed)};
|
||||
uORB::Publication<safety_s> _to_safety{ORB_ID(safety)};
|
||||
uORB::Publication<vehicle_command_s> _to_command{ORB_ID(vehicle_command)};
|
||||
uORB::Publication<led_control_s> _to_led_control{ORB_ID(led_control)};
|
||||
uORB::Publication<tune_control_s> _to_tune_control{ORB_ID(tune_control)};
|
||||
|
||||
safety_s _safety{};
|
||||
|
||||
uint8_t _button_counter{0};
|
||||
uint8_t _blink_counter{0};
|
||||
bool _safety_disabled{false}; ///< circuit breaker to disable the safety button
|
||||
bool _safety_btn_off{false}; ///< State of the safety button read from the HW button
|
||||
bool _safety_btn_prev_sate{false}; ///< Previous state of the HW button
|
||||
bool _has_px4io{false};
|
||||
ButtonPublisher _button_publisher;
|
||||
uint8_t _button_counter{0};
|
||||
uint8_t _blink_counter{0};
|
||||
bool _button_prev_sate{false}; ///< Previous state of the HW button
|
||||
|
||||
// Pairing request
|
||||
hrt_abstime _pairing_start{0};
|
||||
int _pairing_button_counter{0};
|
||||
int _pairing_button_counter{0};
|
||||
|
||||
uORB::Subscription _armed_sub{ORB_ID(actuator_armed)};
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user