ROS2 Control
system_interface.hpp
1 // Copyright 2020 ros2_control Development Team
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef HARDWARE_INTERFACE__SYSTEM_INTERFACE_HPP_
16 #define HARDWARE_INTERFACE__SYSTEM_INTERFACE_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "hardware_interface/handle.hpp"
23 #include "hardware_interface/hardware_info.hpp"
24 #include "hardware_interface/types/hardware_interface_return_values.hpp"
25 #include "hardware_interface/types/hardware_interface_status_values.hpp"
26 #include "hardware_interface/visibility_control.h"
27 
28 namespace hardware_interface
29 {
31 
36 {
37 public:
38  SystemInterface() = default;
39 
40  virtual ~SystemInterface() = default;
41 
43 
48  virtual return_type configure(const HardwareInfo & system_info) = 0;
49 
51 
60  virtual std::vector<StateInterface> export_state_interfaces() = 0;
61 
63 
71  virtual std::vector<CommandInterface> export_command_interfaces() = 0;
72 
74 
86  virtual return_type prepare_command_mode_switch(
87  const std::vector<std::string> & /*start_interfaces*/,
88  const std::vector<std::string> & /*stop_interfaces*/)
89  {
90  return return_type::OK;
91  }
92 
93  // Perform switching to the new command interface.
105  virtual return_type perform_command_mode_switch(
106  const std::vector<std::string> & /*start_interfaces*/,
107  const std::vector<std::string> & /*stop_interfaces*/)
108  {
109  return return_type::OK;
110  }
111 
113 
116  virtual return_type start() = 0;
117 
119 
122  virtual return_type stop() = 0;
123 
125 
128  virtual std::string get_name() const = 0;
129 
131 
134  virtual status get_status() const = 0;
135 
137 
144  virtual return_type read() = 0;
145 
147 
153  virtual return_type write() = 0;
154 };
155 
156 } // namespace hardware_interface
157 #endif // HARDWARE_INTERFACE__SYSTEM_INTERFACE_HPP_
virtual return_type perform_command_mode_switch(const std::vector< std::string > &, const std::vector< std::string > &)
Definition: system_interface.hpp:105
virtual std::vector< StateInterface > export_state_interfaces()=0
Exports all state interfaces for this system.
virtual status get_status() const =0
Get current state of the system hardware.
Definition: actuator.hpp:28
virtual return_type configure(const HardwareInfo &system_info)=0
Configuration of the system from data parsed from the robot&#39;s URDF.
Virtual Class to implement when integrating a complex system into ros2_control.
Definition: system_interface.hpp:35
virtual std::string get_name() const =0
Get name of the system hardware.
virtual std::vector< CommandInterface > export_command_interfaces()=0
Exports all command interfaces for this system.
This structure stores information about hardware defined in a robot&#39;s URDF.
Definition: hardware_info.hpp:100
virtual return_type prepare_command_mode_switch(const std::vector< std::string > &, const std::vector< std::string > &)
Prepare for a new command interface switch.
Definition: system_interface.hpp:86
virtual return_type stop()=0
Stop exchange data with the hardware.
virtual return_type read()=0
Read the current state values from the actuators and sensors within the system.
virtual return_type start()=0
Start exchange data with the hardware.
virtual return_type write()=0
Write the current command values to the actuator within the system.