15#ifndef HARDWARE_INTERFACE__HARDWARE_INFO_HPP_
16#define HARDWARE_INTERFACE__HARDWARE_INFO_HPP_
18#include <fmt/compile.h>
21#include <unordered_map>
25#include "joint_limits/joint_limits.hpp"
61 std::size_t joint_index;
62 std::size_t mimicked_joint_index;
63 double multiplier = 1.0;
107 std::vector<std::string> state_interfaces;
108 std::vector<std::string> command_interfaces;
110 double mechanical_reduction = 1.0;
118 std::vector<std::string> state_interfaces;
119 std::vector<std::string> command_interfaces;
121 double mechanical_reduction = 1.0;
130 std::vector<JointInfo> joints;
131 std::vector<ActuatorInfo> actuators;
141 std::monostate, double, float, bool, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t>;
163 if (data_type ==
"double")
167 else if (data_type ==
"bool")
171 else if (data_type ==
"float32")
175 else if (data_type ==
"uint8")
179 else if (data_type ==
"int8")
183 else if (data_type ==
"uint16")
187 else if (data_type ==
"int16")
191 else if (data_type ==
"uint32")
195 else if (data_type ==
"int32")
205 operator Value()
const {
return value_; }
207 explicit operator bool()
const =
delete;
209 constexpr bool operator==(
HandleDataType other)
const {
return value_ == other.value_; }
210 constexpr bool operator!=(
HandleDataType other)
const {
return value_ != other.value_; }
212 constexpr bool operator==(Value other)
const {
return value_ == other; }
213 constexpr bool operator!=(Value other)
const {
return value_ != other; }
215 std::string to_string()
const
278 return std::get<double>(value);
280 return static_cast<double>(std::get<float>(value));
282 return static_cast<double>(std::get<bool>(value));
284 return static_cast<double>(std::get<uint8_t>(value));
286 return static_cast<double>(std::get<int8_t>(value));
288 return static_cast<double>(std::get<uint16_t>(value));
290 return static_cast<double>(std::get<int16_t>(value));
292 return static_cast<double>(std::get<uint32_t>(value));
294 return static_cast<double>(std::get<int32_t>(value));
296 throw std::runtime_error(
297 fmt::format(FMT_COMPILE(
"Data type : '{}' cannot be casted to double."), to_string()));
304 Value value_ = UNKNOWN;
335 const std::string & get_prefix_name()
const {
return prefix_name; }
361#pragma warning(disable : 4996)
363#pragma GCC diagnostic push
364#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
417 std::unordered_map<std::string, joint_limits::JointLimits>
limits;
424 std::unordered_map<std::string, joint_limits::SoftJointLimits>
soft_limits;
429#pragma GCC diagnostic pop
Definition hardware_info.hpp:143
bool is_castable_to_double() const
Check if the HandleDataType can be casted to double.
Definition hardware_info.hpp:247
double cast_to_double(const HANDLE_DATATYPE &value) const
Cast the given value to double.
Definition hardware_info.hpp:273
Definition actuator.hpp:22
MimicAttribute
This enum is used to store the mimic attribute of a joint.
Definition hardware_info.hpp:69
std::variant< std::monostate, double, float, bool, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t > HANDLE_DATATYPE
Definition hardware_info.hpp:141
Contains semantic info about a given actuator loaded from URDF for a transmission.
Definition hardware_info.hpp:116
Definition hardware_info.hpp:80
std::vector< InterfaceInfo > command_interfaces
Definition hardware_info.hpp:93
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:100
std::vector< InterfaceInfo > state_interfaces
Definition hardware_info.hpp:98
std::string name
Name of the component.
Definition hardware_info.hpp:82
MimicAttribute is_mimic
Hold the value of the mimic attribute if given, NOT_SET otherwise.
Definition hardware_info.hpp:87
std::string type
Type of the component: sensor, joint, or GPIO.
Definition hardware_info.hpp:84
Definition hardware_info.hpp:347
bool print_warnings
Whether to print warnings when the async thread doesn't meet its deadline.
Definition hardware_info.hpp:355
std::string scheduling_policy
Scheduling policy for the async worker thread.
Definition hardware_info.hpp:351
int thread_priority
Thread priority for the async worker thread.
Definition hardware_info.hpp:349
std::vector< int > cpu_affinity_cores
CPU affinity cores for the async worker thread.
Definition hardware_info.hpp:353
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:367
std::string type
Type of the hardware: actuator, sensor or system.
Definition hardware_info.hpp:371
int thread_priority
Async thread priority.
Definition hardware_info.hpp:379
std::vector< MimicJoint > mimic_joints
Definition hardware_info.hpp:394
std::string hardware_plugin_name
Name of the pluginlib plugin of the hardware that will be loaded.
Definition hardware_info.hpp:383
std::unordered_map< std::string, joint_limits::JointLimits > limits
Definition hardware_info.hpp:417
HardwareAsyncParams async_params
Async Parameters.
Definition hardware_info.hpp:381
std::unordered_map< std::string, std::string > hardware_parameters
(Optional) Key-value pairs for hardware parameters.
Definition hardware_info.hpp:385
std::string group
Hardware group to which the hardware belongs.
Definition hardware_info.hpp:373
bool is_async
Component is async.
Definition hardware_info.hpp:377
std::unordered_map< std::string, joint_limits::SoftJointLimits > soft_limits
Definition hardware_info.hpp:424
std::vector< ComponentInfo > gpios
Definition hardware_info.hpp:404
std::vector< ComponentInfo > joints
Definition hardware_info.hpp:390
std::string original_xml
Definition hardware_info.hpp:413
std::string name
Name of the hardware.
Definition hardware_info.hpp:369
std::vector< ComponentInfo > sensors
Definition hardware_info.hpp:399
std::vector< TransmissionInfo > transmissions
Definition hardware_info.hpp:409
unsigned int rw_rate
Component's read and write rates in Hz.
Definition hardware_info.hpp:375
Definition hardware_info.hpp:312
InterfaceInfo interface_info
Definition hardware_info.hpp:328
std::string interface_name
Definition hardware_info.hpp:333
std::string prefix_name
Definition hardware_info.hpp:323
Definition hardware_info.hpp:34
std::string max
(Optional) Maximal allowed values of the interface.
Definition hardware_info.hpp:43
std::string initial_value
(Optional) Initial value of the interface.
Definition hardware_info.hpp:45
std::string name
Definition hardware_info.hpp:39
int size
(Optional) If the handle is an array, the size of the array.
Definition hardware_info.hpp:49
std::string min
(Optional) Minimal allowed values of the interface.
Definition hardware_info.hpp:41
std::string data_type
(Optional) The datatype of the interface, e.g. "bool", "int".
Definition hardware_info.hpp:47
std::unordered_map< std::string, std::string > parameters
Definition hardware_info.hpp:55
bool enable_limits
(Optional) enable or disable the limits for the command interfaces
Definition hardware_info.hpp:51
Contains semantic info about a given joint loaded from URDF for a transmission.
Definition hardware_info.hpp:105
This structure stores information about a joint that is mimicking another joint.
Definition hardware_info.hpp:60
Contains semantic info about a given transmission loaded from URDF.
Definition hardware_info.hpp:127
std::unordered_map< std::string, std::string > parameters
(Optional) Key-value pairs of custom parameters
Definition hardware_info.hpp:133