7#ifndef YARP_DEV_GENERICSENSORSROSPUBLISHER_H
8#define YARP_DEV_GENERICSENSORSROSPUBLISHER_H
42template <
class ROS_MSG>
80template <
class ROS_MSG>
90template <
class ROS_MSG>
93template <
class ROS_MSG>
96 if (!config.
check(
"topic")) {
101 if (!config.
check(
"period")) {
106 if (config.
find(
"period").isFloat32()==
false && config.
find(
"period").isFloat64()==
false) {
111 m_periodInS = config.
find(
"period").asFloat64();
113 if (m_periodInS <= 0) {
118 std::string name = config.
find(
"topic").asString();
123 m_rosNodeName = name+
"_node";
124 m_publisherName = name;
126 if (config.
check(
"node_name"))
128 m_rosNodeName = config.
find(
"node_name").asString();
131 if (m_rosNodeName ==
"")
139 if (m_rosNode ==
nullptr) {
144 if (!m_publisher.topic(m_publisherName)) {
152template <
class ROS_MSG>
155 return this->detachAll();
165template <
class ROS_MSG>
172 "single MultipleAnalogSensors device on YARP ports, but %d devices have been passed in attachAll.",
194 bool ok = viewInterfaces();
202 ok &= this->setPeriod(m_periodInS);
208template <
class ROS_MSG>
212 if (this->isRunning()) {
218template <
class ROS_MSG>
223template <
class ROS_MSG>
const yarp::os::LogComponent & GENERICSENSORROSPUBLISHER()
This abstract template needs to be specialized in a ROS Publisher, for a specific ROS mesagge/sensor ...
yarp::dev::PolyDriver * m_poly
virtual ~GenericSensorRosPublisher()
void run() override
Loop function.
bool detachAll() override
Detach the object (you must have first called attach).
virtual bool viewInterfaces()=0
std::string m_publisherName
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
yarp::os::Publisher< ROS_MSG > m_publisher
void threadRelease() override
Release method.
std::string m_rosNodeName
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
yarp::os::Node * m_rosNode
const size_t m_sens_index
GenericSensorRosPublisher()
Interface implemented by all device drivers.
Interface for an object that can wrap/attach to to another.
A container for a device driver.
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
#define yCError(component,...)
#define YARP_DECLARE_LOG_COMPONENT(name)