YARP
Yet Another Robot Platform
rpLidar2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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 RPLIDAR2_H
20 #define RPLIDAR2_H
21 
22 
23 #include <yarp/os/PeriodicThread.h>
24 #include <yarp/os/Semaphore.h>
27 #include <yarp/dev/PolyDriver.h>
28 #include <yarp/sig/Vector.h>
29 #include <yarp/dev/ISerialDevice.h>
31 
32 #include <mutex>
33 #include <string>
34 #include <vector>
35 
36 #include <rplidar.h>
37 
38 using namespace yarp::os;
39 using namespace yarp::dev;
40 
41 typedef unsigned char byte;
42 
43 //---------------------------------------------------------------------------------------------------------------
44 
46 {
47  typedef rp::standalone::rplidar::RPlidarDriver rplidardrv;
48 
49  void handleError(u_result error);
50  std::string deviceinfo();
51 protected:
54  int m_pwm_val;
55  std::string m_serialPort;
56  rplidardrv* m_drv;
57 
58 public:
59  RpLidar2(double period = 0.01) : PeriodicThread(period),
60  m_buffer_life(0),
61  m_inExpressMode(false),
62  m_pwm_val(0),
63  m_drv(nullptr)
64  {}
65 
66 
68  {
69  }
70 
71  bool open(yarp::os::Searchable& config) override;
72  bool close() override;
73  bool threadInit() override;
74  void threadRelease() override;
75  void run() override;
76 
77 public:
78  //IRangefinder2D interface
79  bool setDistanceRange (double min, double max) override;
80  bool setScanLimits (double min, double max) override;
81  bool setHorizontalResolution (double step) override;
82  bool setScanRate (double rate) override;
83 };
84 
85 #endif
define control board standard interfaces
contains the definition of a Vector type
rplidardrv * m_drv
Definition: rpLidar2.h:56
int m_buffer_life
Definition: rpLidar2.h:52
bool m_inExpressMode
Definition: rpLidar2.h:53
RpLidar2(double period=0.01)
Definition: rpLidar2.h:59
std::string m_serialPort
Definition: rpLidar2.h:55
~RpLidar2()
Definition: rpLidar2.h:67
int m_pwm_val
Definition: rpLidar2.h:54
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
The DLidarDeviceTemplate class.
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition: Searchable.h:69
An interface for the device drivers.
An interface to the operating system, including Port based communication.
unsigned char byte
Definition: rpLidar2.h:41