YARP
Yet Another Robot Platform
Lidar2DDeviceBase.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #include <vector>
7 
8 #include <yarp/os/Stamp.h>
9 #include <yarp/os/Searchable.h>
11 #include <yarp/dev/api.h>
12 #include <mutex>
13 
14 #ifndef YARP_DEV_2DLIDARDEVICETEMPLATE_H
15 #define YARP_DEV_2DLIDARDEVICETEMPLATE_H
16 
17 namespace yarp::dev {
18 
19 struct Range_t
20 {
21  double min;
22  double max;
23 };
24 
30 {
31 protected:
32  //internal data
36  std::mutex m_mutex;
37 
38 protected:
39  //internal parameters
40  std::string m_info;
41  double m_scan_rate;
42  size_t m_sensorsNum;
43  double m_min_angle;
44  double m_max_angle;
47  double m_resolution;
51  std::vector <Range_t> m_range_skip_vector;
52 
53 public:
54  // the main parse function
55  bool parseConfiguration(yarp::os::Searchable& config);
56 
57 public:
58  //constructor
60 
61 protected:
62  //This section contains utility methods called by laser devices
63 
70  virtual bool updateLidarData();
71 
77  virtual bool updateTimestamp();
78 
83  virtual bool applyLimitsOnLaserData();
84 
89  virtual bool acquireDataFromHW() = 0;
90 
91 public:
92  //IRangefinder2D interface
93  bool getRawData(yarp::sig::Vector& data, double* timestamp = nullptr) override;
94  bool getLaserMeasurement(std::vector<LaserMeasurementData>& data, double* timestamp = nullptr) override;
95  bool getDeviceStatus(Device_status& status) override;
96  bool getDeviceInfo(std::string& device_info) override;
97  bool getDistanceRange(double& min, double& max) override;
98  bool getScanLimits(double& min, double& max) override;
99  bool getHorizontalResolution(double& step) override;
100  bool getScanRate(double& rate) override;
101 
102 private:
103  //utility methods called internally by Lidar2DDeviceBase
104  virtual bool checkSkipAngle(const double& angle, double& distance);
105 };
106 
107 } // namespace yarp::dev
108 
109 #endif
A generic interface for planar laser range finders.
The Lidar2DDeviceBase class.
virtual bool acquireDataFromHW()=0
This method should be implemented by the user, and contain the logic to grab data from the hardware.
std::vector< Range_t > m_range_skip_vector
yarp::dev::IRangefinder2D::Device_status m_device_status
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
For streams capable of holding different kinds of content, check what they actually have.
#define YARP_dev_API
Definition: api.h:18