forked from Archive/PX4-Autopilot
Style refactoring related to safety button
This commit is contained in:
parent
ce70b6f4ac
commit
44c4b8fa85
|
@ -2298,12 +2298,11 @@ Commander::run()
|
|||
}
|
||||
|
||||
/* safety button */
|
||||
bool safety_updated = _safety.safetyButtonHandler();
|
||||
const bool safety_changed = _safety.safetyButtonHandler();
|
||||
_vehicle_status.safety_button_available = _safety.isButtonAvailable();
|
||||
_vehicle_status.safety_off = _safety.isSafetyOff();
|
||||
|
||||
if (safety_updated) {
|
||||
|
||||
if (safety_changed) {
|
||||
set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_MOTORCONTROL, _safety.isButtonAvailable(), _safety.isSafetyOff(),
|
||||
_safety.isButtonAvailable(), _vehicle_status);
|
||||
|
||||
|
|
|
@ -402,7 +402,7 @@ private:
|
|||
vehicle_status_s _vehicle_status{};
|
||||
vehicle_status_flags_s _vehicle_status_flags{};
|
||||
|
||||
Safety _safety{};
|
||||
Safety _safety;
|
||||
|
||||
WorkerThread _worker_thread;
|
||||
|
||||
|
|
|
@ -42,9 +42,7 @@ using namespace time_literals;
|
|||
|
||||
Safety::Safety()
|
||||
{
|
||||
/*
|
||||
* Safety can be turned off with the CBRK_IO_SAFETY parameter.
|
||||
*/
|
||||
// Safety can be turned off with the CBRK_IO_SAFETY parameter.
|
||||
_safety_disabled = circuit_breaker_enabled("CBRK_IO_SAFETY", CBRK_IO_SAFETY_KEY);
|
||||
}
|
||||
|
||||
|
@ -67,10 +65,8 @@ bool Safety::safetyButtonHandler()
|
|||
}
|
||||
}
|
||||
|
||||
bool safety_changed = _previous_safety_off != _safety_off;
|
||||
|
||||
const bool safety_changed = _previous_safety_off != _safety_off;
|
||||
_previous_safety_off = _safety_off;
|
||||
|
||||
return safety_changed;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@
|
|||
|
||||
class Safety
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Safety();
|
||||
~Safety() = default;
|
||||
|
||||
|
@ -55,11 +53,10 @@ public:
|
|||
bool isSafetyOff() { return _safety_off; }
|
||||
|
||||
private:
|
||||
|
||||
uORB::Subscription _safety_button_sub{ORB_ID::safety_button};
|
||||
|
||||
bool _button_available{false}; //<! Set to true if a safety button is connected
|
||||
bool _safety_off{false}; //<! Set to true if safety is off
|
||||
bool _previous_safety_off{false}; //<! Previous safety value
|
||||
bool _safety_disabled{false}; //<! Set to true if safety is disabled
|
||||
bool _button_available{false};///< Set to true if a safety button is connected
|
||||
bool _safety_off{false}; ///< Set to true if safety is off
|
||||
bool _previous_safety_off{false}; ///< Previous safety value
|
||||
bool _safety_disabled{false}; ///< Set to true if safety is disabled
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue