YARP
Yet Another Robot Platform
TemperatureRosPublisher.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.PoseStampedRosPublisher")
12 
13 bool TemperatureRosPublisher::viewInterfaces()
14 {
15  // View all the interfaces
16  bool ok = true;
17  ok &= m_poly->view(m_ITemperature);
18  m_ITemperature->getTemperatureSensorFrameName(0,m_framename);
19  return ok;
20 }
21 
23 {
24  if (m_publisher.asPort().isOpen())
25  {
26  size_t index = 0;
27  double temperature;
29  m_ITemperature->getTemperatureSensorMeasure(index, temperature, m_timestamp);
30  temp_ros_data.clear();
31  temp_ros_data.header.frame_id = m_framename;
32  temp_ros_data.header.seq = m_msg_counter++;
33  temp_ros_data.header.stamp = m_timestamp;
34  temp_ros_data.temperature = temperature;
35  temp_ros_data.variance = 0;
37  }
38  }
GenericSensorRosPublisher< yarp::rosmsg::sensor_msgs::Temperature >::m_framename
std::string m_framename
Definition: GenericSensorRosPublisher.h:60
GenericSensorRosPublisher< yarp::rosmsg::sensor_msgs::Temperature >::m_publisher
yarp::os::Publisher< yarp::rosmsg::sensor_msgs::Temperature > m_publisher
Definition: GenericSensorRosPublisher.h:56
TemperatureRosPublisher::run
void run() override
Loop function.
Definition: TemperatureRosPublisher.cpp:22
YARP_LOG_COMPONENT
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
yarp::rosmsg::std_msgs::Header::frame_id
std::string frame_id
Definition: Header.h:49
yarp::dev::DeviceDriver::view
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:77
yarp::rosmsg::std_msgs::Header::seq
std::uint32_t seq
Definition: Header.h:47
GENERICSENSORROSPUBLISHER
const yarp::os::LogComponent & GENERICSENSORROSPUBLISHER()
Definition: TemperatureRosPublisher.cpp:11
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::sensor_msgs::Temperature >::m_timestamp
double m_timestamp
Definition: GenericSensorRosPublisher.h:59
yarp::dev::ITemperatureSensors::getTemperatureSensorMeasure
virtual bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const =0
Get the last reading of the specified sensor.
yarp::os::Publisher::asPort
Port & asPort() override
Get the concrete Port being used for communication.
Definition: Publisher.h:172
yarp::rosmsg::sensor_msgs::Temperature::clear
void clear()
Definition: Temperature.h:50
TemperatureRosPublisher.h
yarp::rosmsg::sensor_msgs::Temperature
Definition: Temperature.h:37
yarp::rosmsg::sensor_msgs::Temperature::variance
yarp::conf::float64_t variance
Definition: Temperature.h:41
yarp::rosmsg::sensor_msgs::Temperature::temperature
yarp::conf::float64_t temperature
Definition: Temperature.h:40
yarp::rosmsg::sensor_msgs::Temperature::header
yarp::rosmsg::std_msgs::Header header
Definition: Temperature.h:39
TemperatureRosPublisher
TemperatureRosPublisher: This wrapper connects to a device and publishes a ROS topic of type sensor_m...
Definition: TemperatureRosPublisher.h:33
yarp::rosmsg::std_msgs::Header::stamp
yarp::rosmsg::TickTime stamp
Definition: Header.h:48
GenericSensorRosPublisher< yarp::rosmsg::sensor_msgs::Temperature >::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