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
11#include <yarp/os/Semaphore.h>
14#include <yarp/dev/PolyDriver.h>
15#include <yarp/sig/Vector.h>
18
19#include <mutex>
20#include <string>
21#include <vector>
22
23#include <rplidar.h>
24
25using namespace yarp::os;
26using namespace yarp::dev;
27
28typedef unsigned char byte;
29
30//---------------------------------------------------------------------------------------------------------------
47{
48 typedef rp::standalone::rplidar::RPlidarDriver rplidardrv;
49
50 void handleError(u_result error);
51 std::string deviceinfo();
52protected:
56 std::string m_serialPort;
57 rplidardrv* m_drv;
58
59public:
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
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
78public:
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
85public:
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
bool setScanRate(double rate) override
set the scan rate (scans per seconds)
Definition: rpLidar2.cpp:192
RpLidar2(double period=0)
Definition: rpLidar2.h:60
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: rpLidar2.cpp:37
bool setScanLimits(double min, double max) override
set the scan angular range.
Definition: rpLidar2.cpp:177
bool close() override
Close the DeviceDriver.
Definition: rpLidar2.cpp:159
bool threadInit() override
Initialization method.
Definition: rpLidar2.cpp:199
bool m_inExpressMode
Definition: rpLidar2.h:54
bool acquireDataFromHW() override final
This method should be implemented by the user, and contain the logic to grab data from the hardware.
Definition: rpLidar2.cpp:216
bool setDistanceRange(double min, double max) override
set the device detection range.
Definition: rpLidar2.cpp:169
bool setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
Definition: rpLidar2.cpp:185
std::string m_serialPort
Definition: rpLidar2.h:56
void threadRelease() override
Release method.
Definition: rpLidar2.cpp:300
void run() override
Loop function.
Definition: rpLidar2.cpp:209
~RpLidar2()
Definition: rpLidar2.h:68
int m_pwm_val
Definition: rpLidar2.h:55
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
The Lidar2DDeviceBase class.
An abstraction for a periodic thread.
void step()
Call this to "step" the thread rather than starting it.
A base class for nested structures that can be searched.
Definition: Searchable.h:63
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
unsigned char byte
Definition: rpLidar2.h:28