YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
TemperatureRosPublisher.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7
8YARP_LOG_COMPONENT(GENERICSENSORROSPUBLISHER, "yarp.device.PoseStampedRosPublisher")
9
10bool TemperatureRosPublisher::viewInterfaces()
11{
12 // View all the interfaces
13 bool ok = true;
14 ok = m_poly->view(m_ITemperature);
15 if (!ok) {
16 yCError(GENERICSENSORROSPUBLISHER) << "ITemperatureSensors interface is not available";
17 return false;
18 }
19
20 ok = m_ITemperature->getTemperatureSensorFrameName(0,m_framename);
21 return ok;
22}
23
25{
27 {
28 size_t index = 0;
29 double temperature;
30 yarp::rosmsg::sensor_msgs::Temperature& temp_ros_data = m_publisher.prepare();
31 m_ITemperature->getTemperatureSensorMeasure(index, temperature, m_timestamp);
32 temp_ros_data.clear();
33 temp_ros_data.header.frame_id = m_framename;
34 temp_ros_data.header.seq = m_msg_counter++;
35 temp_ros_data.header.stamp = m_timestamp;
36 temp_ros_data.temperature = temperature;
37 temp_ros_data.variance = 0;
39 }
40 }
const yarp::os::LogComponent & GENERICSENSORROSPUBLISHER()
yarp::os::Publisher< yarp::rosmsg::sensor_msgs::Temperature > m_publisher
TemperatureRosPublisher: This wrapper connects to a device and publishes a ROS topic of type sensor_m...
void run() override
Loop function.
bool view(T *&x)
Get an interface to the device driver.
virtual bool getTemperatureSensorMeasure(size_t sens_index, double &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:677
Port & asPort() override
Get the concrete Port being used for communication.
Definition Publisher.h:169
void write(bool forceStrict=false)
Write the current object being returned by Publisher::prepare.
Definition Publisher.h:148
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::Publisher::write.
Definition Publisher.h:123
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)