15 #ifndef SEMANTIC_COMPONENTS__FORCE_TORQUE_SENSOR_HPP_
16 #define SEMANTIC_COMPONENTS__FORCE_TORQUE_SENSOR_HPP_
22 #include "geometry_msgs/msg/wrench.hpp"
23 #include "hardware_interface/loaned_state_interface.hpp"
24 #include "semantic_components/semantic_component_interface.hpp"
26 namespace semantic_components
28 constexpr std::size_t FORCES_SIZE = 3;
37 {{name +
"/" +
"force.x"},
38 {name +
"/" +
"force.y"},
39 {name +
"/" +
"force.z"},
40 {name +
"/" +
"torque.x"},
41 {name +
"/" +
"torque.y"},
42 {name +
"/" +
"torque.z"}}),
57 const std::string & interface_force_x,
const std::string & interface_force_y,
58 const std::string & interface_force_z,
const std::string & interface_torque_x,
59 const std::string & interface_torque_y,
const std::string & interface_torque_z)
62 auto check_and_add_interface =
63 [
this](
const std::string & interface_name,
const std::size_t index)
65 if (!interface_name.empty())
67 interface_names_.emplace_back(interface_name);
76 check_and_add_interface(interface_force_x, 0);
77 check_and_add_interface(interface_force_y, 1);
78 check_and_add_interface(interface_force_z, 2);
79 check_and_add_interface(interface_torque_x, 3);
80 check_and_add_interface(interface_torque_y, 4);
81 check_and_add_interface(interface_torque_z, 5);
92 std::array<double, 3> forces;
93 forces.fill(std::numeric_limits<double>::quiet_NaN());
94 std::size_t interface_counter{0};
95 for (
auto i = 0u; i < forces.size(); ++i)
99 forces[i] = state_interfaces_[interface_counter].get().get_value();
114 std::array<double, 3> torques;
115 torques.fill(std::numeric_limits<double>::quiet_NaN());
119 auto torque_interface_counter =
static_cast<std::size_t
>(
122 for (
auto i = 0u; i < torques.size(); ++i)
126 torques[i] = state_interfaces_[torque_interface_counter].get().get_value();
127 ++torque_interface_counter;
143 const auto [force_x, force_y, force_z] =
get_forces();
144 const auto [torque_x, torque_y, torque_z] =
get_torques();
146 message.force.x = force_x;
147 message.force.y = force_y;
148 message.force.z = force_z;
149 message.torque.x = torque_x;
150 message.torque.y = torque_y;
151 message.torque.z = torque_z;
Definition: force_torque_sensor.hpp:30
std::array< bool, 6 > existing_axes_
Vector with existing axes for sensors with less then 6D axes.
Definition: force_torque_sensor.hpp:158
bool get_values_as_message(geometry_msgs::msg::Wrench &message) const
Return Wrench message with forces and torques.
Definition: force_torque_sensor.hpp:141
ForceTorqueSensor(const std::string &name)
Constructor for "standard" 6D FTS.
Definition: force_torque_sensor.hpp:33
std::array< double, 3 > get_forces() const
Return forces.
Definition: force_torque_sensor.hpp:90
std::array< double, 3 > get_torques() const
Return torque.
Definition: force_torque_sensor.hpp:112
ForceTorqueSensor(const std::string &interface_force_x, const std::string &interface_force_y, const std::string &interface_force_z, const std::string &interface_torque_x, const std::string &interface_torque_y, const std::string &interface_torque_z)
Constructor for 6D FTS with custom interface names.
Definition: force_torque_sensor.hpp:56
Definition: semantic_component_interface.hpp:28