YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
WrenchStamped_nws_ros2.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7
8YARP_LOG_COMPONENT(GENERICSENSOR_NWS_ROS2, "yarp.device.WrenchStamped_nws_ros2")
9
10bool WrenchStamped_nws_ros2::viewInterfaces()
11{
12 // View all the interfaces
13 bool ok = m_poly->view(m_iFTsens);
14 m_iFTsens->getSixAxisForceTorqueSensorFrameName(m_sens_index, m_framename);
15 return ok;
16}
17
19{
20 if (m_publisher)
21 {
22 yarp::sig::Vector vecwrench(6);
23 geometry_msgs::msg::WrenchStamped wrench_ros_data;
25 wrench_ros_data.header.frame_id = m_framename;
26 wrench_ros_data.header.stamp = ros2TimeFromYarp(m_timestamp);
27 wrench_ros_data.wrench.force.x = vecwrench[0];
28 wrench_ros_data.wrench.force.y = vecwrench[1];
29 wrench_ros_data.wrench.force.z = vecwrench[2];
30 wrench_ros_data.wrench.torque.x = vecwrench[4];
31 wrench_ros_data.wrench.torque.y = vecwrench[5];
32 wrench_ros_data.wrench.torque.z = vecwrench[6];
33 m_publisher->publish(wrench_ros_data);
34 }
35}
builtin_interfaces::msg::Time ros2TimeFromYarp(double yarpTime)
Definition Ros2Utils.cpp:28
const yarp::os::LogComponent & GENERICSENSOR_NWS_ROS2()
rclcpp::Publisher< geometry_msgs::msg::WrenchStamped >::SharedPtr m_publisher
WrenchStamped_nws_ros2: This wrapper connects to a device and publishes a ROS topic of type geometry_...
void run() override
Loop function.
bool view(T *&x)
Get an interface to the device driver.
virtual bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
#define YARP_LOG_COMPONENT(name,...)