YARP
Yet Another Robot Platform
Rangefinder2DClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef YARP_DEV_RANGEFINDER2DCLIENT_RANGEFINDER2DCLIENT_H
20 #define YARP_DEV_RANGEFINDER2DCLIENT_RANGEFINDER2DCLIENT_H
21 
22 
23 #include <yarp/os/Network.h>
24 #include <yarp/os/BufferedPort.h>
29 #include <yarp/sig/Vector.h>
30 #include <yarp/os/Time.h>
31 #include <yarp/dev/PolyDriver.h>
32 
33 #include <mutex>
34 
35 
36 #define DEFAULT_THREAD_PERIOD 20 //ms
37 const int LASER_TIMEOUT=100; //ms
38 
40  public yarp::os::BufferedPort<yarp::os::Bottle>
41 {
42  yarp::os::Bottle lastBottle;
43  std::mutex mutex;
44  yarp::os::Stamp lastStamp;
45  double deltaT;
46  double deltaTMax;
47  double deltaTMin;
48  double prev;
49  double now;
50 
51  int state;
52  int count;
53 
54 public:
55 
56  inline void resetStat();
57 
59 
61  void onRead(yarp::os::Bottle &v) override;
62 
63  inline int getLast(yarp::os::Bottle &data, yarp::os::Stamp &stmp);
64 
65  inline int getIterations();
66 
67  // time is in ms
68  void getEstFrequency(int &ite, double &av, double &min, double &max);
69 
70  bool getData(yarp::sig::Vector &data);
72 
73 };
74 
85 {
86 protected:
89  std::string local;
90  std::string remote;
91  yarp::os::Stamp lastTs; //used by IPreciselyTimed
92  std::string deviceId;
93 
99  std::string laser_frame_name;
100  std::string robot_frame_name;
101 
102 public:
103 
104  /* DevideDriver methods */
105  bool open(yarp::os::Searchable& config) override;
106  bool close() override;
107 
108 
109  /* IPreciselyTimed methods */
114  yarp::os::Stamp getLastInputStamp() override;
115 
121  bool getLaserMeasurement(std::vector<yarp::dev::LaserMeasurementData> &data) override;
122 
128  bool getRawData(yarp::sig::Vector &data) override;
129 
135  bool getDeviceStatus(Device_status &status) override;
136 
143  bool getDistanceRange(double& min, double& max) override;
144 
151  bool setDistanceRange(double min, double max) override;
152 
159  bool getScanLimits(double& min, double& max) override;
160 
167  bool setScanLimits(double min, double max) override;
168 
174  bool getHorizontalResolution(double& step) override;
175 
181  bool setHorizontalResolution(double step) override;
182 
188  bool getScanRate(double& rate) override;
189 
195  bool setScanRate(double rate) override;
196 
202  bool getDeviceInfo(std::string &device_info) override;
203 
204 };
205 
206 #endif // YARP_DEV_RANGEFINDER2DCLIENT_RANGEFINDER2DCLIENT_H
int getLast(yarp::os::Bottle &data, yarp::os::Stamp &stmp)
Interface implemented by all device drivers.
Definition: DeviceDriver.h:37
const int LASER_TIMEOUT
A generic interface for planar laser range finders.
void getEstFrequency(int &ite, double &av, double &min, double &max)
A base class for nested structures that can be searched.
Definition: Searchable.h:68
bool getData(yarp::sig::Vector &data)
A mini-server for network communication.
Definition: Port.h:49
Rangefinder2DInputPortProcessor inputPort
The client side of any ILaserRangefinder2D capable device.
void onRead(yarp::os::Bottle &v) override
Callback method.
Provides:
Definition: Vector.h:32
A simple collection of objects that can be described and transmitted in a portable way...
Definition: Bottle.h:72
yarp::dev::IRangefinder2D::Device_status getStatus()
bool open(const std::string &name) override
define control board standard interfaces
contains the definition of a Vector type
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:24
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:63
yarp::os::Stamp lastTs