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/Stamp.h>
12 #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 
59 
60 };
61 
79 {
80 protected:
83  std::string local;
84  std::string remote;
85  std::string m_carrier;
87  std::string deviceId;
88 
94  std::string laser_frame_name;
95  std::string robot_frame_name;
96 
97 public:
98 
99  /* DevideDriver methods */
100  bool open(yarp::os::Searchable& config) override;
101  bool close() override;
102 
108  bool getLaserMeasurement(std::vector<yarp::dev::LaserMeasurementData> &data, double* timestamp = nullptr) override;
109 
115  bool getRawData(yarp::sig::Vector &data, double* timestamp = nullptr) override;
116 
122  bool getDeviceStatus(Device_status &status) override;
123 
130  bool getDistanceRange(double& min, double& max) override;
131 
138  bool setDistanceRange(double min, double max) override;
139 
146  bool getScanLimits(double& min, double& max) override;
147 
154  bool setScanLimits(double min, double max) override;
155 
161  bool getHorizontalResolution(double& step) override;
162 
168  bool setHorizontalResolution(double step) override;
169 
175  bool getScanRate(double& rate) override;
176 
182  bool setScanRate(double rate) override;
183 
189  bool getDeviceInfo(std::string &device_info) override;
190 
191 };
192 
193 #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)
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 getRawData(yarp::sig::Vector &data, double *timestamp=nullptr) override
Get the device measurements.
bool getLaserMeasurement(std::vector< yarp::dev::LaserMeasurementData > &data, double *timestamp=nullptr) override
Get the device measurements.
bool getDeviceStatus(Device_status &status) override
get the device status
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.
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:30
A generic interface for planar laser range finders.
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:60
A mini-server for network communication.
Definition: Port.h:46
A base class for nested structures that can be searched.
Definition: Searchable.h:63
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:21