YARP
Yet Another Robot Platform
WrenchStampedRosPublisher.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
7 
8 YARP_LOG_COMPONENT(GENERICSENSORROSPUBLISHER, "yarp.device.WrenchStampedRosPublisher")
9 
10 bool WrenchStampedRosPublisher::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.asPort().isOpen())
21  {
22  yarp::sig::Vector vecwrench(6);
25  wrench_ros_data.clear();
26  wrench_ros_data.header.frame_id = m_framename;
27  wrench_ros_data.header.seq = m_msg_counter++;
28  wrench_ros_data.header.stamp = m_timestamp;
29  wrench_ros_data.wrench.force.x = vecwrench[0];
30  wrench_ros_data.wrench.force.y = vecwrench[1];
31  wrench_ros_data.wrench.force.z = vecwrench[2];
32  wrench_ros_data.wrench.torque.x = vecwrench[4];
33  wrench_ros_data.wrench.torque.y = vecwrench[5];
34  wrench_ros_data.wrench.torque.z = vecwrench[6];
36  }
37 }
const yarp::os::LogComponent & GENERICSENSORROSPUBLISHER()
yarp::os::Publisher< yarp::rosmsg::geometry_msgs::WrenchStamped > m_publisher
WrenchStampedRosPublisher: This wrapper connects to a device and publishes a ROS topic of type geomet...
void run() override
Loop function.
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:74
virtual bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
bool isOpen() const
Check if the port has been opened.
Definition: Port.cpp:668
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::Publisher::write.
Definition: Publisher.h:124
void write(bool forceStrict=false)
Write the current object being returned by Publisher::prepare.
Definition: Publisher.h:149
Port & asPort() override
Get the concrete Port being used for communication.
Definition: Publisher.h:170
yarp::conf::float64_t y
Definition: Vector3.h:38
yarp::conf::float64_t z
Definition: Vector3.h:39
yarp::conf::float64_t x
Definition: Vector3.h:37
yarp::rosmsg::geometry_msgs::Wrench wrench
Definition: WrenchStamped.h:34
yarp::rosmsg::std_msgs::Header header
Definition: WrenchStamped.h:33
yarp::rosmsg::geometry_msgs::Vector3 torque
Definition: Wrench.h:34
yarp::rosmsg::geometry_msgs::Vector3 force
Definition: Wrench.h:33
yarp::rosmsg::TickTime stamp
Definition: Header.h:45
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:77