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/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 {
18 namespace dev {
19 
20 struct Range_t
21 {
22  double min;
23  double max;
24 };
25 
32 {
33 
34 protected:
35  //internal data
39  std::mutex m_mutex;
40 
41 protected:
42  //internal parameters
43  std::string m_info;
44  double m_scan_rate;
45  size_t m_sensorsNum;
46  double m_min_angle;
47  double m_max_angle;
50  double m_resolution;
54  std::vector <Range_t> m_range_skip_vector;
55 
56 public:
57  // the main parse function
58  bool parseConfiguration(yarp::os::Searchable& config);
59 
60 public:
61  //constructor
63 
64 protected:
65  //This section contains utility methods called by laser devices
66 
73  virtual bool updateLidarData();
74 
80  virtual bool updateTimestamp();
81 
86  virtual bool applyLimitsOnLaserData();
87 
92  virtual bool acquireDataFromHW() = 0;
93 
94 public:
95  //IRangefinder2D interface
96  bool getRawData(yarp::sig::Vector& data) override;
97  bool getLaserMeasurement(std::vector<LaserMeasurementData>& data) override;
98  bool getDeviceStatus(Device_status& status) override;
99  bool getDeviceInfo(std::string& device_info) override;
100  bool getDistanceRange(double& min, double& max) override;
101  bool getScanLimits(double& min, double& max) override;
102  bool getHorizontalResolution(double& step) override;
103  bool getScanRate(double& rate) override;
104 
105  //IPreciselyTimed interface
106  virtual yarp::os::Stamp getLastInputStamp() override;
107 
108 private:
109  //utility methods called internally by Lidar2DDeviceBase
110  virtual bool checkSkipAngle(const double& angle, double& distance);
111 };
112 
113 } // dev
114 } // yarp
115 
116 #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:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_dev_API
Definition: api.h:18