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 //---------------------------------------------------------------------------------------------------------------
50 {
51  typedef rp::standalone::rplidar::RPlidarDriver rplidardrv;
52 
53  void handleError(u_result error);
54  std::string deviceinfo();
55 protected:
58  int m_pwm_val;
59  std::string m_serialPort;
60  rplidardrv* m_drv;
61 
62 public:
63  RpLidar2(double period = 0.01) : PeriodicThread(period),
64  m_buffer_life(0),
65  m_inExpressMode(false),
66  m_pwm_val(0),
67  m_drv(nullptr)
68  {}
69 
70 
72  {
73  }
74 
75  bool open(yarp::os::Searchable& config) override;
76  bool close() override;
77  bool threadInit() override;
78  void threadRelease() override;
79  void run() override;
80 
81 public:
82  //IRangefinder2D interface
83  bool setDistanceRange (double min, double max) override;
84  bool setScanLimits (double min, double max) override;
85  bool setHorizontalResolution (double step) override;
86  bool setScanRate (double rate) override;
87 };
88 
89 #endif
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
Vector.h
contains the definition of a Vector type
Lidar2DDeviceBase.h
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
RpLidar2::m_inExpressMode
bool m_inExpressMode
Definition: rpLidar2.h:57
ControlBoardInterfaces.h
define control board standard interfaces
yarp::dev
An interface for the device drivers.
Definition: audioBufferSizeData.cpp:17
yarp::dev::Lidar2DDeviceBase
The DLidarDeviceTemplate class.
Definition: Lidar2DDeviceBase.h:33
RpLidar2::~RpLidar2
~RpLidar2()
Definition: rpLidar2.h:71
byte
unsigned char byte
Definition: rpLidar2.h:41
RpLidar2::m_serialPort
std::string m_serialPort
Definition: rpLidar2.h:59
RpLidar2
rpLidar2: Documentation to be added
Definition: rpLidar2.h:50
RpLidar2::m_pwm_val
int m_pwm_val
Definition: rpLidar2.h:58
PolyDriver.h
ISerialDevice.h
Semaphore.h
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
PeriodicThread.h
RpLidar2::m_buffer_life
int m_buffer_life
Definition: rpLidar2.h:56
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
RpLidar2::RpLidar2
RpLidar2(double period=0.01)
Definition: rpLidar2.h:63
RpLidar2::m_drv
rplidardrv * m_drv
Definition: rpLidar2.h:60