YARP
Yet Another Robot Platform
rpLidar2.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 RPLIDAR2_H
7 #define RPLIDAR2_H
8 
9 
10 #include <yarp/os/PeriodicThread.h>
11 #include <yarp/os/Semaphore.h>
14 #include <yarp/dev/PolyDriver.h>
15 #include <yarp/sig/Vector.h>
16 #include <yarp/dev/ISerialDevice.h>
18 
19 #include <mutex>
20 #include <string>
21 #include <vector>
22 
23 #include <rplidar.h>
24 
25 using namespace yarp::os;
26 using namespace yarp::dev;
27 
28 typedef unsigned char byte;
29 
30 //---------------------------------------------------------------------------------------------------------------
47 {
48  typedef rp::standalone::rplidar::RPlidarDriver rplidardrv;
49 
50  void handleError(u_result error);
51  std::string deviceinfo();
52 protected:
55  int m_pwm_val;
56  std::string m_serialPort;
57  rplidardrv* m_drv;
58 
59 public:
60  RpLidar2(double period = 0) : PeriodicThread(period), //period=0 allows to run the thead as fast as possibile, but it is not a busy loop since yield() is called internally
61  m_buffer_life(0),
62  m_inExpressMode(false),
63  m_pwm_val(0),
64  m_drv(nullptr)
65  {}
66 
67 
69  {
70  }
71 
72  bool open(yarp::os::Searchable& config) override;
73  bool close() override;
74  bool threadInit() override;
75  void threadRelease() override;
76  void run() override;
77 
78 public:
79  //IRangefinder2D interface
80  bool setDistanceRange (double min, double max) override;
81  bool setScanLimits (double min, double max) override;
82  bool setHorizontalResolution (double step) override;
83  bool setScanRate (double rate) override;
84 
85 public:
86  //Lidar2DDeviceBase
87  bool acquireDataFromHW() override final;
88 };
89 
90 #endif
define control board standard interfaces
contains the definition of a Vector type
rpLidar2: The device driver for the RP2 lidar
Definition: rpLidar2.h:47
rplidardrv * m_drv
Definition: rpLidar2.h:57
int m_buffer_life
Definition: rpLidar2.h:53
RpLidar2(double period=0)
Definition: rpLidar2.h:60
bool m_inExpressMode
Definition: rpLidar2.h:54
std::string m_serialPort
Definition: rpLidar2.h:56
~RpLidar2()
Definition: rpLidar2.h:68
int m_pwm_val
Definition: rpLidar2.h:55
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
The Lidar2DDeviceBase class.
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An interface for the device drivers.
An interface to the operating system, including Port based communication.
unsigned char byte
Definition: rpLidar2.h:28