Skip to content

Commit

Permalink
add emergency stop
Browse files Browse the repository at this point in the history
  • Loading branch information
mamueluth committed Jan 11, 2024
1 parent ff092df commit ce485b2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hardware_interface/include/hardware_interface/handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ class StateInterface : public Handle

StateInterface(StateInterface && other) = default;

double emergency_stop() const
{
const double * emergency_stop = std::get_if<double>(&value_);
// This means the value does not store the expected datatype. How should we handle this
// properly?
THROW_ON_NOT_NULLPTR(emergency_stop);
return *emergency_stop;
}

void emergency_stop(const double & emergency_stop) { value_ = emergency_stop; }

double warning_code() const
{
const double * warning_code = std::get_if<double>(&value_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class LoanedStateInterface

double get_value() const { return state_interface_.get_value(); }

double has_emergency_stop() const { return state_interface_.emergency_stop(); }

double get_warning_code() const { return state_interface_.warning_code(); }

double get_error_code() const { return state_interface_.error_code(); }
Expand Down
10 changes: 10 additions & 0 deletions hardware_interface/include/hardware_interface/sensor_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
return sensor_states_.at(interface_name)->get_value();
}

void set_emergency_stop(const std::string & interface_name, const double & emergency_stop)
{
sensor_states_.at(interface_name)->emergency_stop(emergency_stop);
}

double get_emergency_stop(const std::string & interface_name) const
{
return sensor_states_.at(interface_name)->emergency_stop();
}

void set_warning_code(const std::string & interface_name, const double & warning_code)
{
sensor_states_.at(interface_name)->warning_code(warning_code);
Expand Down
10 changes: 10 additions & 0 deletions hardware_interface/include/hardware_interface/system_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
return system_commands_.at(interface_name)->get_value();
}

void set_emergency_stop(const std::string & interface_name, const double & emergency_stop)
{
system_states_.at(interface_name)->emergency_stop(emergency_stop);
}

double get_emergency_stop(const std::string & interface_name) const
{
return system_states_.at(interface_name)->emergency_stop();
}

void set_warning_code(const std::string & interface_name, const double & warning_code)
{
system_states_.at(interface_name)->warning_code(warning_code);
Expand Down

0 comments on commit ce485b2

Please sign in to comment.