ros2_control - rolling
hardware_info.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__HARDWARE_INFO_HPP_
16 #define HARDWARE_INTERFACE__HARDWARE_INFO_HPP_
17 
18 #include <string>
19 #include <unordered_map>
20 #include <vector>
21 
22 #include "joint_limits/joint_limits.hpp"
23 
24 namespace hardware_interface
25 {
31 {
36  std::string name;
38  std::string min;
40  std::string max;
42  std::string initial_value;
44  std::string data_type;
46  int size;
52  std::unordered_map<std::string, std::string> parameters;
53 };
54 
56 struct MimicJoint
57 {
58  std::size_t joint_index;
59  std::size_t mimicked_joint_index;
60  double multiplier = 1.0;
61  double offset = 0.0;
62 };
63 
65 enum class MimicAttribute
66 {
67  NOT_SET,
68  TRUE,
69  FALSE
70 };
71 
77 {
79  std::string name;
81  std::string type;
82 
84  MimicAttribute is_mimic = MimicAttribute::NOT_SET;
85 
90  std::vector<InterfaceInfo> command_interfaces;
95  std::vector<InterfaceInfo> state_interfaces;
97  std::unordered_map<std::string, std::string> parameters;
98 };
99 
101 struct JointInfo
102 {
103  std::string name;
104  std::vector<std::string> state_interfaces;
105  std::vector<std::string> command_interfaces;
106  std::string role;
107  double mechanical_reduction = 1.0;
108  double offset = 0.0;
109 };
110 
113 {
114  std::string name;
115  std::vector<std::string> state_interfaces;
116  std::vector<std::string> command_interfaces;
117  std::string role;
118  double mechanical_reduction = 1.0;
119  double offset = 0.0;
120 };
121 
124 {
125  std::string name;
126  std::string type;
127  std::vector<JointInfo> joints;
128  std::vector<ActuatorInfo> actuators;
130  std::unordered_map<std::string, std::string> parameters;
131 };
132 
138 {
139  InterfaceDescription(const std::string & prefix_name_in, const InterfaceInfo & interface_info_in)
140  : prefix_name(prefix_name_in),
141  interface_info(interface_info_in),
143  {
144  }
145 
149  std::string prefix_name;
150 
155 
159  std::string interface_name;
160 
161  std::string get_prefix_name() const { return prefix_name; }
162 
163  std::string get_interface_name() const { return interface_info.name; }
164 
165  std::string get_name() const { return interface_name; }
166 };
167 
170 {
172  std::string name;
174  std::string type;
176  std::string group;
178  unsigned int rw_rate;
180  bool is_async;
184  std::string hardware_plugin_name;
186  std::unordered_map<std::string, std::string> hardware_parameters;
191  std::vector<ComponentInfo> joints;
195  std::vector<MimicJoint> mimic_joints;
200  std::vector<ComponentInfo> sensors;
205  std::vector<ComponentInfo> gpios;
210  std::vector<TransmissionInfo> transmissions;
214  std::string original_xml;
218  std::unordered_map<std::string, joint_limits::JointLimits> limits;
219 
225  std::unordered_map<std::string, joint_limits::SoftJointLimits> soft_limits;
226 };
227 
228 } // namespace hardware_interface
229 #endif // HARDWARE_INTERFACE__HARDWARE_INFO_HPP_
Definition: actuator.hpp:34
MimicAttribute
This enum is used to store the mimic attribute of a joint.
Definition: hardware_info.hpp:66
Contains semantic info about a given actuator loaded from URDF for a transmission.
Definition: hardware_info.hpp:113
Definition: hardware_info.hpp:77
std::vector< InterfaceInfo > command_interfaces
Definition: hardware_info.hpp:90
std::unordered_map< std::string, std::string > parameters
(Optional) Key-value pairs of component parameters, e.g. min/max values or serial number.
Definition: hardware_info.hpp:97
std::vector< InterfaceInfo > state_interfaces
Definition: hardware_info.hpp:95
std::string name
Name of the component.
Definition: hardware_info.hpp:79
MimicAttribute is_mimic
Hold the value of the mimic attribute if given, NOT_SET otherwise.
Definition: hardware_info.hpp:84
std::string type
Type of the component: sensor, joint, or GPIO.
Definition: hardware_info.hpp:81
This structure stores information about hardware defined in a robot's URDF.
Definition: hardware_info.hpp:170
std::string type
Type of the hardware: actuator, sensor or system.
Definition: hardware_info.hpp:174
int thread_priority
Async thread priority.
Definition: hardware_info.hpp:182
std::vector< MimicJoint > mimic_joints
Definition: hardware_info.hpp:195
std::string hardware_plugin_name
Name of the pluginlib plugin of the hardware that will be loaded.
Definition: hardware_info.hpp:184
std::unordered_map< std::string, joint_limits::JointLimits > limits
Definition: hardware_info.hpp:218
std::unordered_map< std::string, std::string > hardware_parameters
(Optional) Key-value pairs for hardware parameters.
Definition: hardware_info.hpp:186
std::string group
Hardware group to which the hardware belongs.
Definition: hardware_info.hpp:176
bool is_async
Component is async.
Definition: hardware_info.hpp:180
std::unordered_map< std::string, joint_limits::SoftJointLimits > soft_limits
Definition: hardware_info.hpp:225
std::vector< ComponentInfo > gpios
Definition: hardware_info.hpp:205
std::vector< ComponentInfo > joints
Definition: hardware_info.hpp:191
std::string original_xml
Definition: hardware_info.hpp:214
std::string name
Name of the hardware.
Definition: hardware_info.hpp:172
std::vector< ComponentInfo > sensors
Definition: hardware_info.hpp:200
std::vector< TransmissionInfo > transmissions
Definition: hardware_info.hpp:210
unsigned int rw_rate
Component's read and write rates in Hz.
Definition: hardware_info.hpp:178
Definition: hardware_info.hpp:138
InterfaceInfo interface_info
Definition: hardware_info.hpp:154
std::string interface_name
Definition: hardware_info.hpp:159
std::string prefix_name
Definition: hardware_info.hpp:149
Definition: hardware_info.hpp:31
std::string max
(Optional) Maximal allowed values of the interface.
Definition: hardware_info.hpp:40
std::string initial_value
(Optional) Initial value of the interface.
Definition: hardware_info.hpp:42
std::string name
Definition: hardware_info.hpp:36
int size
(Optional) If the handle is an array, the size of the array.
Definition: hardware_info.hpp:46
std::string min
(Optional) Minimal allowed values of the interface.
Definition: hardware_info.hpp:38
std::string data_type
(Optional) The datatype of the interface, e.g. "bool", "int".
Definition: hardware_info.hpp:44
std::unordered_map< std::string, std::string > parameters
Definition: hardware_info.hpp:52
bool enable_limits
(Optional) enable or disable the limits for the command interfaces
Definition: hardware_info.hpp:48
Contains semantic info about a given joint loaded from URDF for a transmission.
Definition: hardware_info.hpp:102
This structure stores information about a joint that is mimicking another joint.
Definition: hardware_info.hpp:57
Contains semantic info about a given transmission loaded from URDF.
Definition: hardware_info.hpp:124
std::unordered_map< std::string, std::string > parameters
(Optional) Key-value pairs of custom parameters
Definition: hardware_info.hpp:130