6#ifndef _USE_MATH_DEFINES
7#define _USE_MATH_DEFINES
21using namespace std::chrono_literals;
38 driver->
view(m_iDevice);
42 if (
nullptr == m_iDevice)
82 auto message = std_msgs::msg::String();
84 if (m_iDevice!=
nullptr)
97 sensor_msgs::msg::LaserScan
rosData;
114 rosData.angle_increment = m_resolution *
M_PI / 180.0;
117 rosData.range_min = m_minDistance;
118 rosData.range_max = m_maxDistance;
126 if (std::isnan(
ranges[i]))
128 rosData.ranges[i] = std::numeric_limits<double>::infinity();
151 m_publisher = m_node->create_publisher<sensor_msgs::msg::LaserScan>(
m_topic_name, 10);
const yarp::os::LogComponent & RANGEFINDER2D_NWS_ROS2()
const yarp::os::LogComponent & RANGEFINDER2D_NWS_ROS2()
static rclcpp::Node::SharedPtr createNode(std::string name)
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool close() override
Close the DeviceDriver.
void run() override
Loop function.
bool attach(yarp::dev::PolyDriver *driver) override
Attach to another object.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
bool view(T *&x)
Get an interface to the device driver.
virtual ReturnValue getRawData(yarp::sig::Vector &data, double *timestamp=nullptr)=0
Get the device measurements.
virtual ReturnValue getDistanceRange(double &min, double &max)=0
get the device detection range
virtual ReturnValue getScanLimits(double &min, double &max)=0
get the scan angular range.
virtual ReturnValue getHorizontalResolution(double &step)=0
get the angular step between two measurements.
virtual ReturnValue getDeviceStatus(Device_status &status)=0
get the device status
A container for a device driver.
bool isValid() const
Check if device is valid.
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
bool setPeriod(double period)
Set the (new) period of the thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
bool start()
Call this to start the thread.
double getPeriod() const
Return the current period of the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
#define yCInfo(component,...)
#define yCError(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.
The main, catch-all namespace for YARP.