![]() |
YDLIDAR SDK
V1.4.5
|
#include <ydlidar_driver.h>
Public Types | |
enum | { DEFAULT_TIMEOUT = 2000, DEFAULT_HEART_BEAT = 1000, MAX_SCAN_NODES = 3600, DEFAULT_TIMEOUT_COUNT = 1 } |
Public Member Functions | |
PropertyBuilderByName (bool, SingleChannel, private) PropertyBuilderByName(int | |
private | PropertyBuilderByName (uint32_t, PointTime, private) YDlidarDriver() |
< 雷达类型 More... | |
virtual | ~YDlidarDriver () |
result_t | connect (const char *port_path, uint32_t baudrate) |
连接雷达 连接成功后,必须使用::disconnect函数关闭 More... | |
void | disconnect () |
断开雷达连接 | |
bool | isscanning () const |
扫图状态 More... | |
bool | isconnected () const |
连接雷达状态 More... | |
void | setIntensities (const bool &isintensities) |
设置雷达是否带信号质量 连接成功后,必须使用::disconnect函数关闭 More... | |
void | setAutoReconnect (const bool &enable) |
设置雷达异常自动重新连接 More... | |
result_t | getHealth (device_health &health, uint32_t timeout=DEFAULT_TIMEOUT) |
获取雷达设备健康状态 More... | |
result_t | getDeviceInfo (device_info &info, uint32_t timeout=DEFAULT_TIMEOUT) |
获取雷达设备信息 More... | |
result_t | startScan (bool force=false, uint32_t timeout=DEFAULT_TIMEOUT) |
开启扫描 More... | |
result_t | stop () |
关闭扫描 More... | |
result_t | grabScanData (node_info *nodebuffer, size_t &count, uint32_t timeout=DEFAULT_TIMEOUT) |
获取激光数据 More... | |
result_t | ascendScanData (node_info *nodebuffer, size_t count) |
补偿激光角度 把角度限制在0到360度之间 More... | |
result_t | reset (uint32_t timeout=DEFAULT_TIMEOUT) |
重置激光雷达 More... | |
result_t | startMotor () |
打开电机 More... | |
result_t | stopMotor () |
关闭电机 More... | |
result_t | getScanFrequency (scan_frequency &frequency, uint32_t timeout=DEFAULT_TIMEOUT) |
获取激光雷达当前扫描频率 More... | |
result_t | setScanFrequencyAdd (scan_frequency &frequency, uint32_t timeout=DEFAULT_TIMEOUT) |
设置增加扫描频率1HZ More... | |
result_t | setScanFrequencyDis (scan_frequency &frequency, uint32_t timeout=DEFAULT_TIMEOUT) |
设置减小扫描频率1HZ More... | |
result_t | setScanFrequencyAddMic (scan_frequency &frequency, uint32_t timeout=DEFAULT_TIMEOUT) |
设置增加扫描频率0.1HZ More... | |
result_t | setScanFrequencyDisMic (scan_frequency &frequency, uint32_t timeout=DEFAULT_TIMEOUT) |
设置减小扫描频率0.1HZ More... | |
result_t | getSamplingRate (sampling_rate &rate, uint32_t timeout=DEFAULT_TIMEOUT) |
获取激光雷达当前采样频率 More... | |
result_t | setSamplingRate (sampling_rate &rate, uint32_t timeout=DEFAULT_TIMEOUT) |
设置激光雷达当前采样频率 More... | |
result_t | getZeroOffsetAngle (offset_angle &angle, uint32_t timeout=DEFAULT_TIMEOUT) |
获取激光雷达当前零位角 More... | |
Static Public Member Functions | |
static std::string | getSDKVersion () |
获取当前SDK版本号 静态函数 More... | |
static std::map< std::string, std::string > | lidarPortList () |
lidarPortList 获取雷达端口 More... | |
Public Attributes | |
LidarType | |
std::atomic< bool > | isConnected |
串口连接状体 | |
std::atomic< bool > | isScanning |
扫图状态 | |
std::atomic< bool > | isAutoReconnect |
异常自动从新连接 | |
std::atomic< bool > | isAutoconnting |
是否正在自动连接中 | |
node_info * | scan_node_buf |
激光点信息 | |
size_t | scan_node_count |
激光点数 | |
Event | _dataEvent |
数据同步事件 | |
Locker | _lock |
线程锁 | |
Locker | _serial_lock |
串口锁 | |
Thread | _thread |
线程id | |
Protected Member Functions | |
result_t | createThread () |
创建解析雷达数据线程 More... | |
result_t | startAutoScan (bool force=false, uint32_t timeout=DEFAULT_TIMEOUT) |
重新连接开启扫描 More... | |
result_t | stopScan (uint32_t timeout=DEFAULT_TIMEOUT) |
stopScan More... | |
result_t | checkDeviceInfo (uint8_t *recvBuffer, uint8_t byte, int recvPos, int recvSize, int pos) |
checkDeviceStatus More... | |
result_t | waitDevicePackage (uint32_t timeout=DEFAULT_TIMEOUT) |
waitDevicePackage More... | |
result_t | waitPackage (node_info *node, uint32_t timeout=DEFAULT_TIMEOUT) |
解包激光数据 More... | |
result_t | waitScanData (node_info *nodebuffer, size_t &count, uint32_t timeout=DEFAULT_TIMEOUT) |
发送数据到雷达 More... | |
int | cacheScanData () |
激光数据解析线程 | |
result_t | sendCommand (uint8_t cmd, const void *payload=NULL, size_t payloadsize=0) |
发送数据到雷达 More... | |
result_t | waitResponseHeader (lidar_ans_header *header, uint32_t timeout=DEFAULT_TIMEOUT) |
等待激光数据包头 More... | |
result_t | waitForData (size_t data_count, uint32_t timeout=DEFAULT_TIMEOUT, size_t *returned_size=NULL) |
等待固定数量串口数据 More... | |
result_t | getData (uint8_t *data, size_t size) |
获取串口数据 More... | |
result_t | sendData (const uint8_t *data, size_t size) |
串口发送数据 More... | |
void | checkTransDelay () |
checkTransDelay | |
void | disableDataGrabbing () |
关闭数据获取通道 | |
void | setDTR () |
设置串口DTR | |
void | clearDTR () |
清除串口DTR | |
void | flushSerial () |
flushSerial | |
result_t | checkAutoConnecting () |
checkAutoConnecting | |
Class that provides a lidar interface.
anonymous enum |
|
virtual |
A destructor. A more elaborate description of the destructor.
result_t ydlidar::YDlidarDriver::ascendScanData | ( | node_info * | nodebuffer, |
size_t | count | ||
) |
补偿激光角度
把角度限制在0到360度之间
[in] | nodebuffer | 激光点信息 |
[in] | count | 一圈激光点数 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
protected |
checkDeviceStatus
byte |
result_t ydlidar::YDlidarDriver::connect | ( | const char * | port_path, |
uint32_t | baudrate | ||
) |
连接雷达
连接成功后,必须使用::disconnect函数关闭
[in] | port_path | 串口号 |
[in] | baudrate | 波特率,YDLIDAR-SS雷达波特率: 230400 G2-SS-1 |
0 | 成功 |
< | 0 失败 |
|
protected |
创建解析雷达数据线程
|
protected |
获取串口数据
[in] | data | 数据指针 |
[in] | size | 数据大小 |
RESULT_OK | 获取成功 |
RESULT_FAILE | 获取失败 |
result_t ydlidar::YDlidarDriver::getDeviceInfo | ( | device_info & | info, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取雷达设备信息
[in] | info | 设备信息 |
[in] | timeout | 超时时间 |
RESULT_OK | 获取成功 |
RESULT_FAILE | or RESULT_TIMEOUT 获取失败 |
result_t ydlidar::YDlidarDriver::getHealth | ( | device_health & | health, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取雷达设备健康状态
RESULT_OK | 获取成功 |
RESULT_FAILE | or RESULT_TIMEOUT 获取失败 |
result_t ydlidar::YDlidarDriver::getSamplingRate | ( | sampling_rate & | rate, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取激光雷达当前采样频率
[in] | frequency | 采样频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::getScanFrequency | ( | scan_frequency & | frequency, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取激光雷达当前扫描频率
[in] | frequency | 扫描频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
static |
获取当前SDK版本号
静态函数
result_t ydlidar::YDlidarDriver::getZeroOffsetAngle | ( | offset_angle & | angle, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取激光雷达当前零位角
[in] | angle | 零位偏移角 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::grabScanData | ( | node_info * | nodebuffer, |
size_t & | count, | ||
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取激光数据
[in] | nodebuffer | 激光点信息 |
[in] | count | 一圈激光点数 |
[in] | timeout | 超时时间 |
RESULT_OK | 获取成功 |
RESULT_FAILE | 获取失败 |
bool ydlidar::YDlidarDriver::isconnected | ( | ) | const |
连接雷达状态
true | 成功 |
false | 失败 |
bool ydlidar::YDlidarDriver::isscanning | ( | ) | const |
扫图状态
true | 正在扫图 |
false | 扫图关闭 |
|
static |
lidarPortList 获取雷达端口
private ydlidar::YDlidarDriver::PropertyBuilderByName | ( | uint32_t | , |
PointTime | , | ||
private | |||
) |
< 雷达类型
A constructor. A more elaborate description of the constructor.
result_t ydlidar::YDlidarDriver::reset | ( | uint32_t | timeout = DEFAULT_TIMEOUT | ) |
重置激光雷达
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
protected |
发送数据到雷达
[in] | cmd | 命名码 |
[in] | payload | payload |
[in] | payloadsize | payloadsize |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
protected |
串口发送数据
[in] | data | 发送数据指针 |
[in] | size | 数据大小 |
RESULT_OK | 发送成功 |
RESULT_FAILE | 发送失败 |
void ydlidar::YDlidarDriver::setAutoReconnect | ( | const bool & | enable | ) |
设置雷达异常自动重新连接
[in] | enable | 是否开启自动重连: true 开启 false 关闭 |
void ydlidar::YDlidarDriver::setIntensities | ( | const bool & | isintensities | ) |
设置雷达是否带信号质量
连接成功后,必须使用::disconnect函数关闭
[in] | isintensities | 是否带信号质量: true 带信号质量 false 无信号质量 |
result_t ydlidar::YDlidarDriver::setSamplingRate | ( | sampling_rate & | rate, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置激光雷达当前采样频率
[in] | rate | 采样频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setScanFrequencyAdd | ( | scan_frequency & | frequency, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置增加扫描频率1HZ
[in] | frequency | 扫描频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setScanFrequencyAddMic | ( | scan_frequency & | frequency, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置增加扫描频率0.1HZ
[in] | frequency | 扫描频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setScanFrequencyDis | ( | scan_frequency & | frequency, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置减小扫描频率1HZ
[in] | frequency | 扫描频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setScanFrequencyDisMic | ( | scan_frequency & | frequency, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置减小扫描频率0.1HZ
[in] | frequency | 扫描频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
protected |
重新连接开启扫描
[in] | force | 扫描模式 |
[in] | timeout | 超时时间 |
RESULT_OK | 开启成功 |
RESULT_FAILE | 开启失败 |
result_t ydlidar::YDlidarDriver::startMotor | ( | ) |
打开电机
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::startScan | ( | bool | force = false , |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
开启扫描
[in] | force | 扫描模式 |
[in] | timeout | 超时时间 |
RESULT_OK | 开启成功 |
RESULT_FAILE | 开启失败 |
result_t ydlidar::YDlidarDriver::stop | ( | ) |
关闭扫描
RESULT_OK | 关闭成功 |
RESULT_FAILE | 关闭失败 |
result_t ydlidar::YDlidarDriver::stopMotor | ( | ) |
关闭电机
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
protected |
stopScan
timeout |
|
protected |
waitDevicePackage
timeout |
|
protected |
等待固定数量串口数据
[in] | data_count | 等待数据大小 |
[in] | timeout | 等待时间 |
[in] | returned_size | 实际数据大小 |
RESULT_OK | 获取成功 |
RESULT_TIMEOUT | 等待超时 |
RESULT_FAILE | 获取失败 |
|
protected |
解包激光数据
[in] | node | 解包后激光点信息 |
[in] | timeout | 超时时间 |
|
protected |
等待激光数据包头
[in] | header | 包头 |
[in] | timeout | 超时时间 |
RESULT_OK | 获取成功 |
RESULT_TIMEOUT | 等待超时 |
RESULT_FAILE | 获取失败 |
|
protected |
发送数据到雷达
[in] | nodebuffer | 激光信息指针 |
[in] | count | 激光点数大小 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_TIMEOUT | 等待超时 |
RESULT_FAILE | 失败 |