YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Rangefinder2D_nws_ros.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef YARP_DEV_RANGEFINDER2D_NWS_ROS_H
7#define YARP_DEV_RANGEFINDER2D_NWS_ROS_H
8
9 //#include <list>
10#include <vector>
11#include <iostream>
12#include <string>
13#include <sstream>
14
15#include <yarp/os/Network.h>
16#include <yarp/os/Port.h>
18#include <yarp/os/Bottle.h>
19#include <yarp/os/Time.h>
20#include <yarp/os/Property.h>
21
24#include <yarp/os/Stamp.h>
25
26#include <yarp/sig/Vector.h>
27
29#include <yarp/dev/PolyDriver.h>
32#include <yarp/dev/api.h>
33
34// ROS state publisher
35#include <yarp/os/Node.h>
36#include <yarp/os/Publisher.h>
37#include <yarp/rosmsg/sensor_msgs/LaserScan.h>
38#include <yarp/rosmsg/impl/yarpRosHelper.h>
39
40
41#define DEFAULT_THREAD_PERIOD 0.02 //s
42
43
77{
78public:
81
82 bool open(yarp::os::Searchable &params) override;
83 bool close() override;
84
86 bool attach(yarp::dev::PolyDriver* driver) override;
87 bool detach() override;
88
89 bool threadInit() override;
90 void threadRelease() override;
91 void run() override;
92
93private:
94 // ROS streaming data
95 std::string frame_id; // name of the frame measures are referred to
96 std::string nodeName; // name of the rosNode
97 std::string topicName; // name of the rosTopic
98 yarp::os::Node* node; // add a ROS node
99 yarp::os::NetUint32 msgCounter; // incremental counter in the ROS message
100 yarp::os::Publisher<yarp::rosmsg::sensor_msgs::LaserScan> publisherPort; // Dedicated ROS topic publisher
101
102private:
103 //interfaces
104 yarp::dev::PolyDriver m_driver;
106
107private:
108 //device data
109 yarp::os::Stamp lastStateStamp;
110 double _period;
111 double minAngle, maxAngle;
112 double minDistance, maxDistance;
113 double resolution;
114
115private:
116 //private methods
117 bool checkROSParams(yarp::os::Searchable &config);
118 bool initialize_ROS();
119};
120
121#endif //YARP_DEV_RANGEFINDER2D_NWS_ROS_H
contains the definition of a Vector type
rangefinder2D_nws_ros: A Network grabber for 2D Rangefinder devices. This device will publish data on...
bool close() override
Close the DeviceDriver.
Rangefinder2D_nws_ros()
It reads the data from a rangefinder sensor and sends them on one port.
void threadRelease() override
Release method.
bool detach() override
Detach the object (you must have first called attach).
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
void attach(yarp::dev::IRangefinder2D *s)
bool threadInit() override
Initialization method.
void run() override
Loop function.
Interface implemented by all device drivers.
A generic interface for planar laser range finders.
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
A mini-server for performing network communication in the background.
The Node class.
Definition Node.h:23
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
std::uint32_t NetUint32
Definition of the NetUint32 type.
Definition NetUint32.h:29