15#ifndef SEMANTIC_COMPONENTS__FORCE_TORQUE_SENSOR_HPP_
16#define SEMANTIC_COMPONENTS__FORCE_TORQUE_SENSOR_HPP_
23#include "geometry_msgs/msg/wrench.hpp"
24#include "hardware_interface/loaned_state_interface.hpp"
25#include "semantic_components/semantic_component_interface.hpp"
27namespace semantic_components
39 {{name +
"/" +
"force.x"},
40 {name +
"/" +
"force.y"},
41 {name +
"/" +
"force.z"},
42 {name +
"/" +
"torque.x"},
43 {name +
"/" +
"torque.y"},
44 {name +
"/" +
"torque.z"}}),
47 data_.fill(std::numeric_limits<double>::quiet_NaN());
61 const std::string & interface_force_x,
const std::string & interface_force_y,
62 const std::string & interface_force_z,
const std::string & interface_torque_x,
63 const std::string & interface_torque_y,
const std::string & interface_torque_z)
66 data_.fill(std::numeric_limits<double>::quiet_NaN());
67 auto check_and_add_interface =
68 [
this](
const std::string & interface_name,
const std::size_t index)
70 if (!interface_name.empty())
72 interface_names_.emplace_back(interface_name);
81 check_and_add_interface(interface_force_x, 0);
82 check_and_add_interface(interface_force_y, 1);
83 check_and_add_interface(interface_force_z, 2);
84 check_and_add_interface(interface_torque_x, 3);
85 check_and_add_interface(interface_torque_y, 4);
86 check_and_add_interface(interface_torque_z, 5);
99 std::array<double, 3> forces;
100 std::copy(
data_.begin(),
data_.begin() + 3, forces.begin());
114 std::array<double, 3> torques;
115 std::copy(
data_.begin() + 3,
data_.end(), torques.begin());
132 message.force.x =
data_[0];
133 message.force.y =
data_[1];
134 message.force.z =
data_[2];
135 message.torque.x =
data_[3];
136 message.torque.y =
data_[4];
137 message.torque.z =
data_[5];
151 std::size_t interface_counter{0};
152 for (
auto i = 0u; i <
data_.size(); ++i)
156 const auto data = state_interfaces_[interface_counter].get().get_optional();
157 if (data.has_value())
159 data_[i] = data.value();
169 mutable std::array<double, 6>
data_;
Definition force_torque_sensor.hpp:30
std::array< bool, 6 > existing_axes_
Array with existing axes for sensors with less than 6D axes.
Definition force_torque_sensor.hpp:173
bool get_values_as_message(geometry_msgs::msg::Wrench &message) const
Return Wrench message with forces and torques.
Definition force_torque_sensor.hpp:129
ForceTorqueSensor(const std::string &name)
Constructor for "standard" 6D FTS.
Definition force_torque_sensor.hpp:35
std::array< double, 3 > get_forces() const
Return forces.
Definition force_torque_sensor.hpp:96
std::array< double, 3 > get_torques() const
Return torque.
Definition force_torque_sensor.hpp:111
std::array< double, 6 > data_
Array to store the data of the FT sensors.
Definition force_torque_sensor.hpp:169
void update_data_from_interfaces() const
Update the data from the state interfaces.
Definition force_torque_sensor.hpp:149
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:60
Definition semantic_component_interface.hpp:28