Browse Source

Style refactoring related to safety button

main
Matthias Grob 3 years ago committed by Igor Mišić
parent
commit
44c4b8fa85
  1. 5
      src/modules/commander/Commander.cpp
  2. 2
      src/modules/commander/Commander.hpp
  3. 8
      src/modules/commander/Safety.cpp
  4. 11
      src/modules/commander/Safety.hpp

5
src/modules/commander/Commander.cpp

@ -2298,12 +2298,11 @@ Commander::run() @@ -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);

2
src/modules/commander/Commander.hpp

@ -402,7 +402,7 @@ private: @@ -402,7 +402,7 @@ private:
vehicle_status_s _vehicle_status{};
vehicle_status_flags_s _vehicle_status_flags{};
Safety _safety{};
Safety _safety;
WorkerThread _worker_thread;

8
src/modules/commander/Safety.cpp

@ -42,9 +42,7 @@ using namespace time_literals; @@ -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() @@ -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;
}

11
src/modules/commander/Safety.hpp

@ -43,9 +43,7 @@ @@ -43,9 +43,7 @@
class Safety
{
public:
Safety();
~Safety() = default;
@ -55,11 +53,10 @@ public: @@ -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…
Cancel
Save