YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
rpLidar3.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 RPLIDAR3_H
7#define RPLIDAR3_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//---------------------------------------------------------------------------------------------------------------
50{
51 typedef rp::standalone::rplidar::RPlidarDriver rplidardrv;
52
53 void handleError(u_result error);
54
55protected:
57 bool m_inExpressMode = false;
58 bool m_force_scan = false;
59 std::string m_scan_mode ="Boost";
60 int m_pwm_val = 600;
61 std::string m_serialPort;
62 rplidardrv* m_drv = nullptr;
63 const size_t m_nodes_num = 8192;
65
66public:
67 RpLidar3(double period = 0) : PeriodicThread(period) //period=0 allows to run the thread as fast as possible, but it is not a busy loop since yield() is called internally
68 {
70 }
71
73 {
74 delete [] m_nodes;
75 }
76
77 bool open(yarp::os::Searchable& config) override;
78 bool close() override;
79 bool threadInit() override;
80 void threadRelease() override;
81 void run() override;
82
83private:
84 bool startMotor();
85 bool startScan();
86 bool deviceinfo();
87
88public:
89 //IRangefinder2D interface
90 yarp::dev::ReturnValue setDistanceRange (double min, double max) override;
91 yarp::dev::ReturnValue setScanLimits (double min, double max) override;
93 yarp::dev::ReturnValue setScanRate (double rate) override;
94
95public:
96 //Lidar2DDeviceBase
98};
99
100#endif
define control board standard interfaces
contains the definition of a Vector type
rpLidar3: The device driver for the RP2 lidar
Definition rpLidar3.h:50
const size_t m_nodes_num
Definition rpLidar3.h:63
rplidar_response_measurement_node_hq_t * m_nodes
Definition rpLidar3.h:64
std::string m_serialPort
Definition rpLidar3.h:61
bool acquireDataFromHW() override final
This method should be implemented by the user, and contain the logic to grab data from the hardware.
Definition rpLidar3.cpp:276
void run() override
Loop function.
Definition rpLidar3.cpp:262
bool m_force_scan
Definition rpLidar3.h:58
int m_pwm_val
Definition rpLidar3.h:60
yarp::dev::ReturnValue setScanLimits(double min, double max) override
set the scan angular range.
Definition rpLidar3.cpp:230
std::string m_scan_mode
Definition rpLidar3.h:59
void threadRelease() override
Release method.
Definition rpLidar3.cpp:350
bool m_inExpressMode
Definition rpLidar3.h:57
yarp::dev::ReturnValue setScanRate(double rate) override
set the scan rate (scans per seconds)
Definition rpLidar3.cpp:245
bool threadInit() override
Initialization method.
Definition rpLidar3.cpp:252
yarp::dev::ReturnValue setDistanceRange(double min, double max) override
set the device detection range.
Definition rpLidar3.cpp:222
bool close() override
Close the DeviceDriver.
Definition rpLidar3.cpp:210
~RpLidar3()
Definition rpLidar3.h:72
int m_buffer_life
Definition rpLidar3.h:56
RpLidar3(double period=0)
Definition rpLidar3.h:67
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition rpLidar3.cpp:122
yarp::dev::ReturnValue setHorizontalResolution(double step) override
get the angular step between two measurements (if available)
Definition rpLidar3.cpp:238
rplidardrv * m_drv
Definition rpLidar3.h:62
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.
Definition jointData.cpp:13
An interface to the operating system, including Port based communication.
unsigned char byte
Definition rpLidar3.h:28