YARP
Yet Another Robot Platform
Rangefinder2DClient.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: LGPL-2.1-or-later
4  */
5 
6 #ifndef YARP_DEV_RANGEFINDER2DCLIENT_RANGEFINDER2DCLIENT_H
7 #define YARP_DEV_RANGEFINDER2DCLIENT_RANGEFINDER2DCLIENT_H
8 
9 
10 #include <yarp/os/Network.h>
11 #include <yarp/os/BufferedPort.h>
16 #include <yarp/dev/LaserScan2D.h>
17 #include <yarp/sig/Vector.h>
18 #include <yarp/os/Time.h>
19 #include <yarp/dev/PolyDriver.h>
20 
21 #include <mutex>
22 
23 
24 #define DEFAULT_THREAD_PERIOD 20 //ms
25 const int LASER_TIMEOUT=100; //ms
26 
28  public yarp::os::BufferedPort<yarp::dev::LaserScan2D>
29 {
30  yarp::dev::LaserScan2D lastScan;
31  std::mutex mutex;
32  yarp::os::Stamp lastStamp;
33  double deltaT;
34  double deltaTMax;
35  double deltaTMin;
36  double prev;
37  double now;
38 
39  int state;
40  int count;
41 
42 public:
43 
44  inline void resetStat();
45 
47 
49  void onRead(yarp::dev::LaserScan2D&v) override;
50 
51  inline int getLast(yarp::dev::LaserScan2D &data, yarp::os::Stamp &stmp);
52 
53  inline int getIterations();
54 
55  // time is in ms
56  void getEstFrequency(int &ite, double &av, double &min, double &max);
57 
58  bool getData(yarp::sig::Vector &data);
60 
61 };
62 
73 {
74 protected:
77  std::string local;
78  std::string remote;
79  yarp::os::Stamp lastTs; //used by IPreciselyTimed
80  std::string deviceId;
81 
87  std::string laser_frame_name;
88  std::string robot_frame_name;
89 
90 public:
91 
92  /* DevideDriver methods */
93  bool open(yarp::os::Searchable& config) override;
94  bool close() override;
95 
96 
97  /* IPreciselyTimed methods */
103 
109  bool getLaserMeasurement(std::vector<yarp::dev::LaserMeasurementData> &data) override;
110 
116  bool getRawData(yarp::sig::Vector &data) override;
117 
123  bool getDeviceStatus(Device_status &status) override;
124 
131  bool getDistanceRange(double& min, double& max) override;
132 
139  bool setDistanceRange(double min, double max) override;
140 
147  bool getScanLimits(double& min, double& max) override;
148 
155  bool setScanLimits(double min, double max) override;
156 
162  bool getHorizontalResolution(double& step) override;
163 
169  bool setHorizontalResolution(double step) override;
170 
176  bool getScanRate(double& rate) override;
177 
183  bool setScanRate(double rate) override;
184 
190  bool getDeviceInfo(std::string &device_info) override;
191 
192 };
193 
194 #endif // YARP_DEV_RANGEFINDER2DCLIENT_RANGEFINDER2DCLIENT_H
define control board standard interfaces
const int LASER_TIMEOUT
contains the definition of a Vector type
Rangefinder2DClient: The client side of any ILaserRangefinder2D capable device.
bool setDistanceRange(double min, double max) override
set the device detection range.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getHorizontalResolution(double &step) override
get the angular step between two measurments.
bool getScanRate(double &rate) override
get the scan rate (scans per seconds)
yarp::os::Stamp getLastInputStamp() override
Get the time stamp for the last read data.
bool setHorizontalResolution(double step) override
get the angular step between two measurments (if available)
bool close() override
Close the DeviceDriver.
yarp::os::Stamp lastTs
bool setScanRate(double rate) override
set the scan rate (scans per seconds)
bool setScanLimits(double min, double max) override
set the scan angular range.
bool getDistanceRange(double &min, double &max) override
get the device detection range
bool getLaserMeasurement(std::vector< yarp::dev::LaserMeasurementData > &data) override
Get the device measurements.
bool getDeviceStatus(Device_status &status) override
get the device status
bool getRawData(yarp::sig::Vector &data) override
Get the device measurements.
Rangefinder2DInputPortProcessor inputPort
bool getDeviceInfo(std::string &device_info) override
get the device hardware charactestics
bool getScanLimits(double &min, double &max) override
get the scan angular range.
bool getData(yarp::sig::Vector &data)
void getEstFrequency(int &ite, double &av, double &min, double &max)
int getLast(yarp::dev::LaserScan2D &data, yarp::os::Stamp &stmp)
void onRead(yarp::dev::LaserScan2D &v) override
yarp::dev::IRangefinder2D::Device_status getStatus()
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
A generic interface for planar laser range finders.
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:61
A mini-server for network communication.
Definition: Port.h:47
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22