Browse Source

Style refactoring related to safety button

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

4
msg/vehicle_status.msg

@ -117,5 +117,5 @@ uint64 armed_time # Arming timestamp (microseconds) @@ -117,5 +117,5 @@ uint64 armed_time # Arming timestamp (microseconds)
uint64 takeoff_time # Takeoff timestamp (microseconds)
bool safety_button_available # Set to true if a safety button is connected
bool safety_off # Set to true if safety is off
bool safety_button_available # Set to true if a safety button is connected
bool safety_off # Set to true if safety is off

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;
}

15
src/modules/commander/Safety.hpp

@ -43,23 +43,20 @@ @@ -43,23 +43,20 @@
class Safety
{
public:
Safety();
~Safety() = default;
bool safetyButtonHandler();
void activateSafety();
bool isButtonAvailable() { return _button_available;}
bool isSafetyOff() { return _safety_off;}
bool isButtonAvailable() { return _button_available; }
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