YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
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 yarp::dev::ReturnValue setDistanceRange (double min, double max) override;
81 yarp::dev::ReturnValue setScanLimits (double min, double max) override;
83 yarp::dev::ReturnValue setScanRate (double rate) override;
84
85public:
86 //Lidar2DDeviceBase
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 open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition rpLidar2.cpp:38
yarp::dev::ReturnValue setDistanceRange(double min, double max) override
set the device detection range.
Definition rpLidar2.cpp:170
bool close() override
Close the DeviceDriver.
Definition rpLidar2.cpp:160
bool threadInit() override
Initialization method.
Definition rpLidar2.cpp:200
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:217
std::string m_serialPort
Definition rpLidar2.h:56
void threadRelease() override
Release method.
Definition rpLidar2.cpp:301
void run() override
Loop function.
Definition rpLidar2.cpp:210
~RpLidar2()
Definition rpLidar2.h:68
yarp::dev::ReturnValue setScanLimits(double min, double max) override
set the scan angular range.
Definition rpLidar2.cpp:178
int m_pwm_val
Definition rpLidar2.h:55
yarp::dev::ReturnValue setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
Definition rpLidar2.cpp:186
yarp::dev::ReturnValue setScanRate(double rate) override
set the scan rate (scans per seconds)
Definition rpLidar2.cpp:193
Interface implemented by all device drivers.
The Lidar2DDeviceBase class.
A mini-server for performing network communication in the background.
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:31
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