YARP
Yet Another Robot Platform
WrenchStampedRosPublisher.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 
11 YARP_LOG_COMPONENT(GENERICSENSORROSPUBLISHER, "yarp.device.WrenchStampedRosPublisher")
12 
13 bool WrenchStampedRosPublisher::viewInterfaces()
14 {
15  // View all the interfaces
16  bool ok = m_poly->view(m_iFTsens);
17  m_iFTsens->getSixAxisForceTorqueSensorFrameName(m_sens_index, m_framename);
18  return ok;
19 }
20 
22 {
23  if (m_publisher.asPort().isOpen())
24  {
25  yarp::sig::Vector vecwrench(6);
28  wrench_ros_data.clear();
29  wrench_ros_data.header.frame_id = m_framename;
30  wrench_ros_data.header.seq = m_msg_counter++;
31  wrench_ros_data.header.stamp = m_timestamp;
32  wrench_ros_data.wrench.force.x = vecwrench[0];
33  wrench_ros_data.wrench.force.y = vecwrench[1];
34  wrench_ros_data.wrench.force.z = vecwrench[2];
35  wrench_ros_data.wrench.torque.x = vecwrench[4];
36  wrench_ros_data.wrench.torque.y = vecwrench[5];
37  wrench_ros_data.wrench.torque.z = vecwrench[6];
39  }
40 }
yarp::rosmsg::geometry_msgs::Vector3::z
yarp::conf::float64_t z
Definition: Vector3.h:42
GenericSensorRosPublisher< yarp::rosmsg::geometry_msgs::WrenchStamped >::m_framename
std::string m_framename
Definition: GenericSensorRosPublisher.h:60
GenericSensorRosPublisher< yarp::rosmsg::geometry_msgs::WrenchStamped >::m_publisher
yarp::os::Publisher< yarp::rosmsg::geometry_msgs::WrenchStamped > m_publisher
Definition: GenericSensorRosPublisher.h:56
GENERICSENSORROSPUBLISHER
const yarp::os::LogComponent & GENERICSENSORROSPUBLISHER()
Definition: WrenchStampedRosPublisher.cpp:11
yarp::rosmsg::geometry_msgs::Wrench::force
yarp::rosmsg::geometry_msgs::Vector3 force
Definition: Wrench.h:36
yarp::rosmsg::geometry_msgs::WrenchStamped
Definition: WrenchStamped.h:34
yarp::rosmsg::geometry_msgs::WrenchStamped::clear
void clear()
Definition: WrenchStamped.h:45
YARP_LOG_COMPONENT
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
yarp::rosmsg::geometry_msgs::Vector3::y
yarp::conf::float64_t y
Definition: Vector3.h:41
yarp::rosmsg::std_msgs::Header::frame_id
std::string frame_id
Definition: Header.h:49
yarp::rosmsg::geometry_msgs::Vector3::x
yarp::conf::float64_t x
Definition: Vector3.h:40
yarp::dev::DeviceDriver::view
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:77
yarp::rosmsg::geometry_msgs::Wrench::torque
yarp::rosmsg::geometry_msgs::Vector3 torque
Definition: Wrench.h:37
yarp::sig::VectorOf< double >
yarp::rosmsg::std_msgs::Header::seq
std::uint32_t seq
Definition: Header.h:47
yarp::dev::ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorMeasure
virtual bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
GenericSensorRosPublisher< yarp::rosmsg::geometry_msgs::WrenchStamped >::m_sens_index
const size_t m_sens_index
Definition: GenericSensorRosPublisher.h:61
yarp::os::Publisher::write
void write(bool forceStrict=false)
Write the current object being returned by Publisher::prepare.
Definition: Publisher.h:152
GenericSensorRosPublisher< yarp::rosmsg::geometry_msgs::WrenchStamped >::m_timestamp
double m_timestamp
Definition: GenericSensorRosPublisher.h:59
yarp::rosmsg::geometry_msgs::WrenchStamped::wrench
yarp::rosmsg::geometry_msgs::Wrench wrench
Definition: WrenchStamped.h:37
yarp::os::Publisher::asPort
Port & asPort() override
Get the concrete Port being used for communication.
Definition: Publisher.h:172
WrenchStampedRosPublisher.h
WrenchStampedRosPublisher::run
void run() override
Loop function.
Definition: WrenchStampedRosPublisher.cpp:21
WrenchStampedRosPublisher
WrenchStampedRosPublisher: This wrapper connects to a device and publishes a ROS topic of type geomet...
Definition: WrenchStampedRosPublisher.h:33
yarp::rosmsg::geometry_msgs::WrenchStamped::header
yarp::rosmsg::std_msgs::Header header
Definition: WrenchStamped.h:36
yarp::rosmsg::std_msgs::Header::stamp
yarp::rosmsg::TickTime stamp
Definition: Header.h:48
GenericSensorRosPublisher< yarp::rosmsg::geometry_msgs::WrenchStamped >::m_msg_counter
size_t m_msg_counter
Definition: GenericSensorRosPublisher.h:58
yarp::os::Publisher::prepare
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::Publisher::write.
Definition: Publisher.h:127
yarp::os::Port::isOpen
bool isOpen() const
Check if the port has been opened.
Definition: Port.cpp:671