![]() |
YDLIDAR SDK
V1.3.2
|
Public Types | |
enum | { DEFAULT_TIMEOUT = 2000, DEFAULT_HEART_BEAT = 1000, MAX_SCAN_NODES = 2048 } |
enum | { YDLIDAR_F4 =1, YDLIDAR_T1 =2, YDLIDAR_F2 =3, YDLIDAR_S4 =4, YDLIDAR_G4 =5, YDLIDAR_X4 =6, YDLIDAR_F4PRO =6, YDLIDAR_G4C =9 } |
Public Member Functions | |
result_t | connect (const char *port_path, uint32_t baudrate) |
连接雷达 连接成功后,必须使用::disconnect函数关闭 More... | |
void | disconnect () |
断开雷达连接 | |
const bool | isscanning () const |
扫图状态 More... | |
const bool | isconnected () const |
连接雷达状态 More... | |
void | setIntensities (const bool isintensities) |
设置雷达是否带信号质量 连接成功后,必须使用::disconnect函数关闭 More... | |
const bool | getHeartBeat () const |
获取当前雷达掉电保护功能 More... | |
void | setHeartBeat (const bool enable) |
设置雷达掉电保护使能 More... | |
result_t | sendHeartBeat () |
发送掉电保护命令 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 | setRotationPositive (scan_rotation &rotation, uint32_t timeout=DEFAULT_TIMEOUT) |
设置电机顺时针旋转 More... | |
result_t | setRotationInversion (scan_rotation &rotation, uint32_t timeout=DEFAULT_TIMEOUT) |
设置电机逆顺时针旋转 More... | |
result_t | enableLowerPower (function_state &state, uint32_t timeout=DEFAULT_TIMEOUT) |
低功耗使能 More... | |
result_t | disableLowerPower (function_state &state, uint32_t timeout=DEFAULT_TIMEOUT) |
关闭低功耗 More... | |
result_t | getMotorState (function_state &state, uint32_t timeout=DEFAULT_TIMEOUT) |
获取电机状态 More... | |
result_t | enableConstFreq (function_state &state, uint32_t timeout=DEFAULT_TIMEOUT) |
开启恒频功能 More... | |
result_t | disableConstFreq (function_state &state, uint32_t timeout=DEFAULT_TIMEOUT) |
关闭恒频功能 More... | |
result_t | setSaveLowExposure (scan_exposure &low_exposure, uint32_t timeout=DEFAULT_TIMEOUT) |
保存当前激光曝光值 More... | |
result_t | setLowExposure (scan_exposure &low_exposure, uint32_t timeout=DEFAULT_TIMEOUT) |
设置低光功率模式 More... | |
result_t | setLowExposureAdd (scan_exposure &exposure, uint32_t timeout=DEFAULT_TIMEOUT) |
增加激光曝光值 More... | |
result_t | setLowExposurerDis (scan_exposure &exposure, uint32_t timeout=DEFAULT_TIMEOUT) |
减小激光曝光值 More... | |
result_t | setScanHeartbeat (scan_heart_beat &beat, uint32_t timeout=DEFAULT_TIMEOUT) |
设置雷达掉电保护状态 More... | |
result_t | setPointsForOneRingFlag (scan_points &points, uint32_t timeout=DEFAULT_TIMEOUT) |
设置扫描一圈固定激光点数 More... | |
void | simpleScanData (std::vector< scanDot > *scan_data, node_info *buffer, size_t count) |
解析激光信息数据到scanDot数据类型 More... | |
Static Public Member Functions | |
static YDlidarDriver * | singleton () |
static void | initDriver () |
static void | done () |
static std::string | getSDKVersion () |
获取当前SDK版本号 静态函数 More... | |
Public Attributes | |
std::atomic< bool > | isConnected |
串口连接状体 | |
std::atomic< bool > | isScanning |
扫图状态 | |
std::atomic< bool > | isHeartbeat |
掉电保护状态 | |
node_info | scan_node_buf [2048] |
激光点信息 | |
size_t | scan_node_count |
激光点数 | |
Event | _dataEvent |
数据同步事件 | |
Locker | _lock |
线程锁 | |
Thread | _thread |
线程id | |
Protected Member Functions | |
YDlidarDriver () | |
virtual | ~YDlidarDriver () |
result_t | createThread () |
创建解析雷达数据线程 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 | disableDataGrabbing () |
关闭数据获取通道 | |
void | setDTR () |
设置串口DTR | |
void | clearDTR () |
清除串口DTR | |
anonymous enum |
anonymous enum |
|
protected |
A constructor. A more elaborate description of the constructor.
|
protectedvirtual |
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 | 失败 |
result_t ydlidar::YDlidarDriver::connect | ( | const char * | port_path, |
uint32_t | baudrate | ||
) |
连接雷达
连接成功后,必须使用::disconnect函数关闭
[in] | port_path | 串口号 |
[in] | fileMode | 波特率,YDLIDAR雷达有以下几个波特率: 115200 F4, G4C, S4A 128000 X4 153600 S4B 230600 F4PRO, G4 |
0 | 成功 |
< | 0 失败 |
|
protected |
创建解析雷达数据线程
result_t ydlidar::YDlidarDriver::disableConstFreq | ( | function_state & | state, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
关闭恒频功能
[in] | state | 恒频状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::disableLowerPower | ( | function_state & | state, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
关闭低功耗
[in] | state | 低功耗状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::enableConstFreq | ( | function_state & | state, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
开启恒频功能
[in] | state | 恒频状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::enableLowerPower | ( | function_state & | state, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
低功耗使能
[in] | state | 低功耗状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
|
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 获取失败 |
const bool ydlidar::YDlidarDriver::getHeartBeat | ( | ) | const |
获取当前雷达掉电保护功能
true | 掉电保护开启 |
false | 掉电保护关闭 |
result_t ydlidar::YDlidarDriver::getMotorState | ( | function_state & | state, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取电机状态
[in] | state | 电机状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
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::grabScanData | ( | node_info * | nodebuffer, |
size_t & | count, | ||
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
获取激光数据
[in] | nodebuffer | 激光点信息 |
[in] | count | 一圈激光点数 |
[in] | timeout | 超时时间 |
RESULT_OK | 获取成功 |
RESULT_FAILE | 获取失败 |
const bool ydlidar::YDlidarDriver::isconnected | ( | ) | const |
连接雷达状态
true | 成功 |
false | 失败 |
const bool ydlidar::YDlidarDriver::isscanning | ( | ) | const |
扫图状态
true | 正在扫图 |
false | 扫图关闭 |
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 | 发送失败 |
result_t ydlidar::YDlidarDriver::sendHeartBeat | ( | ) |
发送掉电保护命令
RESULT_OK | 发送成功 |
RESULT_FAILE | 发送失败 |
void ydlidar::YDlidarDriver::setHeartBeat | ( | const bool | enable | ) |
设置雷达掉电保护使能
[in] | enable | 是否开启掉电保护: true 开启 false 关闭 |
void ydlidar::YDlidarDriver::setIntensities | ( | const bool | isintensities | ) |
设置雷达是否带信号质量
连接成功后,必须使用::disconnect函数关闭
[in] | isintensities | 是否带信号质量: true 带信号质量 false 无信号质量 |
result_t ydlidar::YDlidarDriver::setLowExposure | ( | scan_exposure & | low_exposure, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置低光功率模式
[in] | low_exposure | 扫描频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setLowExposureAdd | ( | scan_exposure & | exposure, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
增加激光曝光值
[in] | exposure | 曝光值 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setLowExposurerDis | ( | scan_exposure & | exposure, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
减小激光曝光值
[in] | exposure | 曝光值 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setPointsForOneRingFlag | ( | scan_points & | points, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置扫描一圈固定激光点数
[in] | points | 固定点数状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setRotationInversion | ( | scan_rotation & | rotation, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置电机逆顺时针旋转
[in] | rotation | 旋转方向 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setRotationPositive | ( | scan_rotation & | rotation, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置电机顺时针旋转
[in] | rotation | 旋转方向 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setSamplingRate | ( | sampling_rate & | rate, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置激光雷达当前采样频率
[in] | frequency | 采样频率 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
result_t ydlidar::YDlidarDriver::setSaveLowExposure | ( | scan_exposure & | low_exposure, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
保存当前激光曝光值
[in] | low_exposure | 低光功能状态 |
[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 | 失败 |
result_t ydlidar::YDlidarDriver::setScanHeartbeat | ( | scan_heart_beat & | beat, |
uint32_t | timeout = DEFAULT_TIMEOUT |
||
) |
设置雷达掉电保护状态
[in] | beat | 掉电保护状态 |
[in] | timeout | 超时时间 |
RESULT_OK | 成功 |
RESULT_FAILE | 失败 |
void ydlidar::YDlidarDriver::simpleScanData | ( | std::vector< scanDot > * | scan_data, |
node_info * | buffer, | ||
size_t | count | ||
) |
解析激光信息数据到scanDot数据类型
[in] | scan_data | 解析后激光数据 |
[in] | buffer | 解析前激光信息数据 |
[in] | count | 一圈激光点数 |
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 |
等待固定数量串口数据
[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 | 失败 |