6 #define _USE_MATH_DEFINES
50 if (!config.
check(
"node_name"))
56 if(nodeName[0] !=
'/'){
63 if (!config.
check(
"topic_name"))
69 if(topicName[0] !=
'/'){
76 if (!config.
check(
"frame_id"))
87 bool Rangefinder2D_nws_ros::initialize_ROS()
95 if (!publisherPort.topic(topicName))
111 driver->
view(sens_p);
114 if (
nullptr == sens_p)
121 if(!sens_p->getDistanceRange(minDistance, maxDistance))
127 if(!sens_p->getScanLimits(minAngle, maxAngle))
133 if (!sens_p->getHorizontalResolution(resolution))
139 PeriodicThread::setPeriod(_period);
140 return PeriodicThread::start();
150 if (PeriodicThread::isRunning())
152 PeriodicThread::stop();
168 if (!config.
check(
"period"))
175 checkROSParams(config);
178 if (!initialize_ROS())
183 if(config.
check(
"subdevice"))
189 if(!m_driver.open(p) || !m_driver.isValid())
195 if(!attach(&m_driver))
200 isDeviceOwned =
true;
208 publisherPort.close();
218 double synchronized_timestamp=0;
219 ret &= sens_p->getRawData(ranges, &synchronized_timestamp);
220 ret &= sens_p->getDeviceStatus(status);
224 if (std::isnan(synchronized_timestamp) ==
false)
226 lastStateStamp.update(synchronized_timestamp);
233 int ranges_size = ranges.
size();
248 rosData.
ranges.resize(ranges_size);
251 for (
int i = 0; i < ranges_size; i++)
255 if (std::isnan(ranges[i]))
257 rosData.
ranges[i] = std::numeric_limits<double>::infinity();
262 rosData.
ranges[i] = ranges[i];
266 publisherPort.write();
278 if (PeriodicThread::isRunning())
280 PeriodicThread::stop();
define control board standard interfaces
constexpr double DEFAULT_THREAD_PERIOD
const yarp::os::LogComponent & RANGEFINDER2D_NWS_ROS()
rangefinder2D_nws_ros: A Network grabber for 2D Rangefinder devices. This device will publish data on...
bool close() override
Close the DeviceDriver.
void threadRelease() override
Release method.
bool detach() override
Detach the object (you must have first called attach).
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
void attach(yarp::dev::IRangefinder2D *s)
bool threadInit() override
Initialization method.
void run() override
Loop function.
bool view(T *&x)
Get an interface to the device driver.
A generic interface for planar laser range finders.
A container for a device driver.
bool isValid() const
Check if device is valid.
An abstraction for a periodic thread.
A class for storing options and configuration information.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::string asString() const
Get string value.
yarp::conf::float32_t range_min
yarp::conf::float32_t scan_time
yarp::conf::float32_t angle_min
yarp::conf::float32_t angle_increment
std::vector< yarp::conf::float32_t > intensities
std::vector< yarp::conf::float32_t > ranges
yarp::rosmsg::std_msgs::Header header
yarp::conf::float32_t time_increment
yarp::conf::float32_t range_max
yarp::conf::float32_t angle_max
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.