|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
10 #ifndef YARP_DEV_GENERICSENSORSROSPUBLISHER_H
11 #define YARP_DEV_GENERICSENSORSROSPUBLISHER_H
45 template <
class ROS_MSG>
84 template <
class ROS_MSG>
94 template <
class ROS_MSG>
97 template <
class ROS_MSG>
100 if (!config.
check(
"topic")) {
105 if (!config.
check(
"period")) {
117 if (m_periodInS <= 0) {
127 m_rosNodeName = name+
"_node";
128 m_publisherName = name;
130 if (config.
check(
"node_name"))
135 if (m_rosNodeName ==
"")
143 if (m_rosNode ==
nullptr) {
148 if (!m_publisher.topic(m_publisherName)) {
153 if (config.
check(
"subdevice"))
160 if (!m_subdevicedriver.open(p) || !m_subdevicedriver.isValid())
166 driverlist.
push(&m_subdevicedriver,
"1");
167 if (!attachAll(driverlist))
177 template <
class ROS_MSG>
180 return this->detachAll();
190 template <
class ROS_MSG>
197 "single MultipleAnalogSensors device on YARP ports, but %d devices have been passed in attachAll.",
219 bool ok = viewInterfaces();
222 ok &= this->setPeriod(m_periodInS);
228 template <
class ROS_MSG>
232 if (this->isRunning()) {
238 template <
class ROS_MSG>
243 template <
class ROS_MSG>
bool detachAll() override
Detach the object (you must have first called attach).
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
yarp::os::Publisher< ROS_MSG > m_publisher
#define YARP_DECLARE_LOG_COMPONENT(name)
std::string m_publisherName
A base class for nested structures that can be searched.
bool close() override
Close the DeviceDriver.
virtual ~GenericSensorRosPublisher()
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
virtual bool isFloat32() const
Checks if value is a 32-bit floating point number.
Interface implemented by all device drivers.
yarp::os::Node * m_rosNode
virtual bool viewInterfaces()=0
yarp::dev::PolyDriver m_subdevicedriver
This abstract template needs to be specialized in a ROS Publisher, for a specific ROS mesagge/sensor ...
void push(PolyDriver *p, const char *k)
GenericSensorRosPublisher()
const size_t m_sens_index
const yarp::os::LogComponent & GENERICSENSORROSPUBLISHER()
yarp::dev::PolyDriver * m_poly
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
virtual std::string asString() const
Get string value.
A container for a device driver.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
std::string m_rosNodeName
An abstraction for a periodic thread.
#define yCError(component,...)
Interface for an object that can wrap/attach to to another.
void run() override
Loop function.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
void threadRelease() override
Release method.
A class for storing options and configuration information.