6 #define _USE_MATH_DEFINES
58 if (
nullptr == sens_p)
65 if(!sens_p->getDistanceRange(minDistance, maxDistance))
71 if(!sens_p->getScanLimits(minAngle, maxAngle))
77 if (!sens_p->getHorizontalResolution(resolution))
83 PeriodicThread::setPeriod(_period);
84 return PeriodicThread::start();
94 if (PeriodicThread::isRunning())
96 PeriodicThread::stop();
106 bool ok = in.
read(connection);
126 if (sens_p->getDeviceInfo(info))
145 if (sens_p->getDistanceRange(min, max))
165 if (sens_p->getScanLimits(min, max))
184 if (sens_p->getHorizontalResolution(step))
202 if (sens_p->getScanRate(rate))
229 sens_p->setDistanceRange(min, max);
239 sens_p->setScanLimits(min, max);
248 sens_p->setScanRate(rate);
257 sens_p->setHorizontalResolution(step);
283 if (returnToSender !=
nullptr) {
284 out.
write(*returnToSender);
299 if (!config.
check(
"period"))
307 if (!config.
check(
"name"))
316 rpcPortName = streamingPortName +
"/rpc:i";
319 if (config.
check(
"frame_id"))
324 if(!initialize_YARP(config) )
330 if(config.
check(
"subdevice"))
336 if(!m_driver.open(p) || !m_driver.isValid())
342 if(!attach(&m_driver))
347 isDeviceOwned =
true;
354 if (!streamingPort.open(streamingPortName))
359 if (!rpcPort.open(rpcPortName))
364 rpcPort.setReader(*
this);
370 streamingPort.interrupt();
371 streamingPort.close();
383 ret &= sens_p->getRawData(ranges);
384 ret &= sens_p->getDeviceStatus(status);
389 lastStateStamp = iTimed->getLastInputStamp();
394 int ranges_size = ranges.
size();
405 streamingPort.setEnvelope(lastStateStamp);
406 streamingPort.write();
419 if (PeriodicThread::isRunning())
421 PeriodicThread::stop();
define control board standard interfaces
constexpr yarp::conf::vocab32_t VOCAB_IS
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_SET
constexpr yarp::conf::vocab32_t VOCAB_LASER_ANGULAR_RANGE
constexpr yarp::conf::vocab32_t VOCAB_LASER_SCAN_RATE
constexpr yarp::conf::vocab32_t VOCAB_ILASER2D
constexpr yarp::conf::vocab32_t VOCAB_LASER_DISTANCE_RANGE
constexpr yarp::conf::vocab32_t VOCAB_DEVICE_INFO
constexpr yarp::conf::vocab32_t VOCAB_LASER_ANGULAR_STEP
constexpr double DEFAULT_THREAD_PERIOD
const yarp::os::LogComponent & RANGEFINDER2D_NWS_YARP()
rangefinder2D_nws_yarp: A Network grabber for 2D Rangefinder devices. This device will stream data on...
void run() override
Loop function.
void threadRelease() override
Release method.
~Rangefinder2D_nws_yarp()
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
void attach(yarp::dev::IRangefinder2D *s)
bool threadInit() override
Initialization method.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool close() override
Close the DeviceDriver.
bool view(T *&x)
Get an interface to the device driver.
A generic interface for planar laser range finders.
yarp::sig::Vector scans
the scan data, measured in [m].
double angle_min
first angle of the scan [deg]
double angle_max
last angle of the scan [deg]
double range_min
the minimum distance of the scan [m]
double range_max
the maximum distance of the scan [m]
A container for a device driver.
bool isValid() const
Check if device is valid.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
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 yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define yCTrace(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.