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
35 interface_names_.emplace_back(name_ +
"/" +
"force.x");
36 interface_names_.emplace_back(name_ +
"/" +
"force.y");
37 interface_names_.emplace_back(name_ +
"/" +
"force.z");
38 interface_names_.emplace_back(name_ +
"/" +
"torque.x");
39 interface_names_.emplace_back(name_ +
"/" +
"torque.y");
40 interface_names_.emplace_back(name_ +
"/" +
"torque.z");
46 std::fill(forces_.begin(), forces_.end(), std::numeric_limits<double>::quiet_NaN());
47 std::fill(torques_.begin(), torques_.end(), std::numeric_limits<double>::quiet_NaN());
60 const std::string & interface_force_x,
const std::string & interface_force_y,
61 const std::string & interface_force_z,
const std::string & interface_torque_x,
62 const std::string & interface_torque_y,
const std::string & interface_torque_z)
65 auto check_and_add_interface = [
this](
const std::string & interface_name,
const int index)
67 if (!interface_name.empty())
69 interface_names_.emplace_back(interface_name);
78 check_and_add_interface(interface_force_x, 0);
79 check_and_add_interface(interface_force_y, 1);
80 check_and_add_interface(interface_force_z, 2);
81 check_and_add_interface(interface_torque_x, 3);
82 check_and_add_interface(interface_torque_y, 4);
83 check_and_add_interface(interface_torque_z, 5);
86 std::fill(forces_.begin(), forces_.end(), std::numeric_limits<double>::quiet_NaN());
87 std::fill(torques_.begin(), torques_.end(), std::numeric_limits<double>::quiet_NaN());
100 size_t interface_counter = 0;
101 for (
size_t i = 0; i < 3; ++i)
105 forces_[i] = state_interfaces_[interface_counter].get().get_value();
122 auto torque_interface_counter =
125 for (
size_t i = 3; i < 6; ++i)
129 torques_[i - 3] = state_interfaces_[torque_interface_counter].get().get_value();
130 ++torque_interface_counter;
151 message.force.x = forces_[0];
152 message.force.y = forces_[1];
153 message.force.z = forces_[2];
154 message.torque.x = torques_[0];
155 message.torque.y = torques_[1];
156 message.torque.z = torques_[2];
165 std::array<double, 3> forces_;
166 std::array<double, 3> torques_;
Definition: force_torque_sensor.hpp:29
std::array< bool, 6 > existing_axes_
Vector with existing axes for sensors with less then 6D axes.
Definition: force_torque_sensor.hpp:164
ForceTorqueSensor(const std::string &name)
Constructor for "standard" 6D FTS.
Definition: force_torque_sensor.hpp:32
std::array< double, 3 > get_forces()
Return forces.
Definition: force_torque_sensor.hpp:98
std::array< double, 3 > get_torques()
Return torque.
Definition: force_torque_sensor.hpp:118
bool get_values_as_message(geometry_msgs::msg::Wrench &message)
Return Wrench message with forces and torques.
Definition: force_torque_sensor.hpp:144
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:59
Definition: semantic_component_interface.hpp:28