|
25 | 25 | #include "hardware_interface/component_parser.hpp"
|
26 | 26 | #include "hardware_interface/handle.hpp"
|
27 | 27 | #include "hardware_interface/hardware_info.hpp"
|
| 28 | +#include "hardware_interface/types/hardware_interface_emergency_stop_signal.hpp" |
| 29 | +#include "hardware_interface/types/hardware_interface_error_signals.hpp" |
28 | 30 | #include "hardware_interface/types/hardware_interface_return_values.hpp"
|
| 31 | +#include "hardware_interface/types/hardware_interface_warning_signals.hpp" |
29 | 32 | #include "hardware_interface/types/lifecycle_state_names.hpp"
|
30 | 33 | #include "lifecycle_msgs/msg/state.hpp"
|
31 | 34 | #include "rclcpp/duration.hpp"
|
@@ -103,6 +106,7 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
|
103 | 106 | info_ = hardware_info;
|
104 | 107 | import_state_interface_descriptions(info_);
|
105 | 108 | import_command_interface_descriptions(info_);
|
| 109 | + create_report_interfaces(); |
106 | 110 | return CallbackReturn::SUCCESS;
|
107 | 111 | };
|
108 | 112 |
|
@@ -134,6 +138,52 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
|
134 | 138 | }
|
135 | 139 | }
|
136 | 140 |
|
| 141 | + /** |
| 142 | + * Creates all interfaces used for reporting emergency stop, warning and error messages. |
| 143 | + * The available report interfaces are: EMERGENCY_STOP_SIGNAL, ERROR_SIGNAL, ERROR_SIGNAL_MESSAGE, |
| 144 | + * WARNING_SIGNAL and WARNING_SIGNAL_MESSAGE. Where the <report_type>_MESSAGE hold the message for |
| 145 | + * the corresponding report signal. |
| 146 | + * The interfaces are named like <hardware_name>/<report_interface_type>. E.g. if hardware is |
| 147 | + * called joint_1 -> interface for WARNING_SIGNAL is called: joint_1/WARNING_SIGNAL |
| 148 | + */ |
| 149 | + void create_report_interfaces() |
| 150 | + { |
| 151 | + // EMERGENCY STOP |
| 152 | + InterfaceInfo emergency_interface_info; |
| 153 | + emergency_interface_info.name = hardware_interface::EMERGENCY_STOP_SIGNAL; |
| 154 | + emergency_interface_info.data_type = "bool"; |
| 155 | + InterfaceDescription emergency_interface_descr(info_.name, emergency_interface_info); |
| 156 | + emergency_stop_ = std::make_shared<StateInterface>(emergency_interface_descr); |
| 157 | + |
| 158 | + // ERROR |
| 159 | + // create error signal interface |
| 160 | + InterfaceInfo error_interface_info; |
| 161 | + error_interface_info.name = hardware_interface::ERROR_SIGNAL_INTERFACE_NAME; |
| 162 | + error_interface_info.data_type = "std::array<uint8_t>"; |
| 163 | + InterfaceDescription error_interface_descr(info_.name, error_interface_info); |
| 164 | + error_signal_ = std::make_shared<StateInterface>(error_interface_descr); |
| 165 | + // create error signal report message interface |
| 166 | + InterfaceInfo error_msg_interface_info; |
| 167 | + error_msg_interface_info.name = hardware_interface::ERROR_SIGNAL_MESSAGE_INTERFACE_NAME; |
| 168 | + error_msg_interface_info.data_type = "std::array<std::string>"; |
| 169 | + InterfaceDescription error_msg_interface_descr(info_.name, error_msg_interface_info); |
| 170 | + error_signal_message_ = std::make_shared<StateInterface>(error_msg_interface_descr); |
| 171 | + |
| 172 | + // WARNING |
| 173 | + // create warning signal interface |
| 174 | + InterfaceInfo warning_interface_info; |
| 175 | + warning_interface_info.name = hardware_interface::WARNING_SIGNAL_INTERFACE_NAME; |
| 176 | + warning_interface_info.data_type = "std::array<uint8_t>"; |
| 177 | + InterfaceDescription warning_interface_descr(info_.name, warning_interface_info); |
| 178 | + warning_signal_ = std::make_shared<StateInterface>(warning_interface_descr); |
| 179 | + // create warning signal report message interface |
| 180 | + InterfaceInfo warning_msg_interface_info; |
| 181 | + warning_msg_interface_info.name = hardware_interface::WARNING_SIGNAL_MESSAGE_INTERFACE_NAME; |
| 182 | + warning_msg_interface_info.data_type = "std::array<std::string>"; |
| 183 | + InterfaceDescription warning_msg_interface_descr(info_.name, warning_msg_interface_info); |
| 184 | + warning_signal_message_ = std::make_shared<StateInterface>(warning_msg_interface_descr); |
| 185 | + } |
| 186 | + |
137 | 187 | /// Exports all state interfaces for this hardware interface.
|
138 | 188 | /**
|
139 | 189 | * Default implementation for exporting the StateInterfaces. The StateInterfaces are created
|
@@ -170,6 +220,14 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
|
170 | 220 | actuator_states_.insert(std::make_pair(name, std::make_shared<StateInterface>(descr)));
|
171 | 221 | state_interfaces.push_back(actuator_states_.at(name));
|
172 | 222 | }
|
| 223 | + |
| 224 | + // export warning signal interfaces |
| 225 | + state_interfaces.push_back(emergency_stop_); |
| 226 | + state_interfaces.push_back(error_signal_); |
| 227 | + state_interfaces.push_back(error_signal_message_); |
| 228 | + state_interfaces.push_back(warning_signal_); |
| 229 | + state_interfaces.push_back(warning_signal_message_); |
| 230 | + |
173 | 231 | return state_interfaces;
|
174 | 232 | }
|
175 | 233 | /// Exports all command interfaces for this hardware interface.
|
@@ -310,13 +368,48 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
|
310 | 368 | return actuator_commands_.at(interface_name)->get_value();
|
311 | 369 | }
|
312 | 370 |
|
| 371 | + void set_emergency_stop(const double & emergency_stop) |
| 372 | + { |
| 373 | + emergency_stop_->set_value(emergency_stop); |
| 374 | + } |
| 375 | + |
| 376 | + double get_emergency_stop() const { return emergency_stop_->get_value(); } |
| 377 | + |
| 378 | + void set_error_code(const double & error_code) { error_signal_->set_value(error_code); } |
| 379 | + |
| 380 | + double get_error_code() const { return error_signal_->get_value(); } |
| 381 | + |
| 382 | + void set_error_message(const double & error_message) |
| 383 | + { |
| 384 | + error_signal_message_->set_value(error_message); |
| 385 | + } |
| 386 | + |
| 387 | + double get_error_message() const { return error_signal_message_->get_value(); } |
| 388 | + |
| 389 | + void set_warning_code(const double & warning_codes) { warning_signal_->set_value(warning_codes); } |
| 390 | + |
| 391 | + double get_warning_code() const { return warning_signal_->get_value(); } |
| 392 | + |
| 393 | + void set_warning_message(const double & error_message) |
| 394 | + { |
| 395 | + warning_signal_message_->set_value(error_message); |
| 396 | + } |
| 397 | + |
| 398 | + double get_warning_message() const { return warning_signal_message_->get_value(); } |
| 399 | + |
313 | 400 | protected:
|
314 | 401 | HardwareInfo info_;
|
315 | 402 | std::map<std::string, InterfaceDescription> joint_state_interfaces_;
|
316 | 403 | std::map<std::string, InterfaceDescription> joint_command_interfaces_;
|
317 | 404 |
|
318 | 405 | private:
|
319 | 406 | std::map<std::string, std::shared_ptr<StateInterface>> actuator_states_;
|
| 407 | + std::shared_ptr<StateInterface> emergency_stop_; |
| 408 | + std::shared_ptr<StateInterface> error_signal_; |
| 409 | + std::shared_ptr<StateInterface> error_signal_message_; |
| 410 | + std::shared_ptr<StateInterface> warning_signal_; |
| 411 | + std::shared_ptr<StateInterface> warning_signal_message_; |
| 412 | + |
320 | 413 | std::map<std::string, std::shared_ptr<CommandInterface>> actuator_commands_;
|
321 | 414 |
|
322 | 415 | rclcpp_lifecycle::State lifecycle_state_;
|
|
0 commit comments