51 #define min(a,b) (((a) < (b)) ? (a) : (b)) 54 namespace rp {
namespace standalone{
namespace rplidar {
56 #define DEPRECATED_WARN(fn, replacement) do { \ 57 static bool __shown__ = false; \ 59 printDeprecationWarn(fn, replacement); \ 66 fprintf(stderr,
"*WARN* YOU ARE USING DEPRECATED API: %s, PLEASE MOVE TO %s\n", fn, replacement);
105 : _isConnected(false)
107 , _isSupportingMotorCtrl(false)
148 _u8 recvBuffer[
sizeof(rplidar_ans_header_t)];
149 _u8 *headerBuffer =
reinterpret_cast<_u8 *
>(header);
152 while ((waitTime=
getms() - startTs) <= timeout) {
153 size_t remainSize =
sizeof(rplidar_ans_header_t) - recvPos;
159 if(recvSize > remainSize) recvSize = remainSize;
163 for (
size_t pos = 0; pos < recvSize; ++pos) {
164 _u8 currentByte = recvBuffer[pos];
179 headerBuffer[recvPos++] = currentByte;
181 if (recvPos ==
sizeof(rplidar_ans_header_t)) {
206 rplidar_ans_header_t response_header;
217 if ( header_size <
sizeof(rplidar_response_device_health_t)) {
224 _chanDev->
recvdata(reinterpret_cast<_u8 *>(&healthinfo),
sizeof(healthinfo));
246 rplidar_ans_header_t response_header;
257 if (header_size <
sizeof(rplidar_response_device_info_t)) {
282 DEPRECATED_WARN(
"getFrequency(bool,size_t,float&,bool&)",
"getFrequency(const RplidarScanMode&,size_t,float&)");
285 frequency = 1000000.0f/(count * sample_duration);
287 if (sample_duration <= 277) {
299 frequency = 1000000.0f / (count * sample_duration);
307 _u8 recvBuffer[
sizeof(rplidar_response_measurement_node_t)];
308 _u8 *nodeBuffer = (
_u8*)node;
311 while ((waitTime=
getms() - startTs) <= timeout) {
312 size_t remainSize =
sizeof(rplidar_response_measurement_node_t) - recvPos;
318 if (recvSize > remainSize) recvSize = remainSize;
322 for (
size_t pos = 0; pos < recvSize; ++pos) {
323 _u8 currentByte = recvBuffer[pos];
327 _u8 tmp = (currentByte>>1);
328 if ( (tmp ^ currentByte) & 0x1 ) {
347 nodeBuffer[recvPos++] = currentByte;
349 if (recvPos ==
sizeof(rplidar_response_measurement_node_t)) {
365 size_t recvNodeCount = 0;
370 while ((waitTime =
getms() - startTs) <= timeout && recvNodeCount < count) {
371 rplidar_response_measurement_node_t node;
376 nodebuffer[recvNodeCount++] = node;
378 if (recvNodeCount == count)
return RESULT_OK;
380 count = recvNodeCount;
389 _u8 recvBuffer[
sizeof(rplidar_response_capsule_measurement_nodes_t)];
390 _u8 *nodeBuffer = (
_u8*)&node;
394 while ((waitTime=
getms() - startTs) <= timeout) {
395 size_t remainSize =
sizeof(rplidar_response_capsule_measurement_nodes_t) - recvPos;
403 if (recvSize > remainSize) recvSize = remainSize;
407 for (
size_t pos = 0; pos < recvSize; ++pos) {
408 _u8 currentByte = recvBuffer[pos];
413 _u8 tmp = (currentByte>>4);
425 _u8 tmp = (currentByte>>4);
436 nodeBuffer[recvPos++] = currentByte;
437 if (recvPos ==
sizeof(rplidar_response_capsule_measurement_nodes_t)) {
440 _u8 recvChecksum = ((node.s_checksum_1 & 0xF) | (node.s_checksum_2<<4));
442 cpos <
sizeof(rplidar_response_capsule_measurement_nodes_t); ++cpos)
444 checksum ^= nodeBuffer[cpos];
446 if (recvChecksum == checksum)
474 _u8 recvBuffer[
sizeof(rplidar_response_ultra_capsule_measurement_nodes_t)];
475 _u8 *nodeBuffer = (
_u8*)&node;
478 while ((waitTime=
getms() - startTs) <= timeout) {
479 size_t remainSize =
sizeof(rplidar_response_ultra_capsule_measurement_nodes_t) - recvPos;
487 if (recvSize > remainSize) recvSize = remainSize;
491 for (
size_t pos = 0; pos < recvSize; ++pos) {
492 _u8 currentByte = recvBuffer[pos];
496 _u8 tmp = (currentByte>>4);
508 _u8 tmp = (currentByte>>4);
520 nodeBuffer[recvPos++] = currentByte;
521 if (recvPos ==
sizeof(rplidar_response_ultra_capsule_measurement_nodes_t)) {
524 _u8 recvChecksum = ((node.s_checksum_1 & 0xF) | (node.s_checksum_2 << 4));
527 cpos <
sizeof(rplidar_response_ultra_capsule_measurement_nodes_t); ++cpos)
529 checksum ^= nodeBuffer[cpos];
532 if (recvChecksum == checksum)
554 rplidar_response_measurement_node_t local_buf[128];
557 size_t scan_count = 0;
559 memset(local_scan, 0,
sizeof(local_scan));
572 for (
size_t pos = 0; pos < count; ++pos)
578 if ((local_scan[0].
flag & RPLIDAR_RESP_MEASUREMENT_SYNCBIT)) {
589 convert(local_buf[pos], nodeHq);
590 local_scan[scan_count++] = nodeHq;
591 if (scan_count ==
_countof(local_scan)) scan_count-=1;
621 rplidar_ans_header_t response_header;
632 if (header_size <
sizeof(rplidar_response_measurement_node_t)) {
647 DEPRECATED_WARN(
"checkExpressScanSupported(bool&,_u32)",
"getAllSupportedScanModes()");
649 rplidar_response_device_info_t devinfo;
656 if (devinfo.firmware_version >= ((0x1<<8) | 17)) {
658 rplidar_response_sample_rate_t sample_rate;
669 rplidar_response_capsule_measurement_nodes_t capsule_node;
673 size_t scan_count = 0;
675 memset(local_scan, 0,
sizeof(local_scan));
704 for (
size_t pos = 0; pos < count; ++pos)
710 if ((local_scan[0].
flag & RPLIDAR_RESP_MEASUREMENT_SYNCBIT)) {
719 local_scan[scan_count++] = local_buf[pos];
720 if (scan_count ==
_countof(local_scan)) scan_count-=1;
737 rplidar_response_ultra_capsule_measurement_nodes_t ultra_capsule_node;
741 size_t scan_count = 0;
743 memset(local_scan, 0,
sizeof(local_scan));
761 for (
size_t pos = 0; pos < count; ++pos)
767 if ((local_scan[0].
flag & RPLIDAR_RESP_MEASUREMENT_SYNCBIT)) {
776 local_scan[scan_count++] = local_buf[pos];
777 if (scan_count ==
_countof(local_scan)) scan_count-=1;
798 int currentStartAngle_q8 = ((capsule.start_angle_sync_q6 & 0x7FFF)<< 2);
801 diffAngle_q8 = (currentStartAngle_q8) - (prevStartAngle_q8);
802 if (prevStartAngle_q8 > currentStartAngle_q8) {
803 diffAngle_q8 += (360<<8);
806 int angleInc_q16 = (diffAngle_q8 << 3);
807 int currentAngle_raw_q16 = (prevStartAngle_q8 << 8);
820 angle_q6[0] = ((currentAngle_raw_q16 - (angle_offset1_q3<<13))>>10);
821 syncBit[0] = (( (currentAngle_raw_q16 + angleInc_q16) % (360<<16)) < angleInc_q16 )?1:0;
822 currentAngle_raw_q16 += angleInc_q16;
825 angle_q6[1] = ((currentAngle_raw_q16 - (angle_offset2_q3<<13))>>10);
826 syncBit[1] = (( (currentAngle_raw_q16 + angleInc_q16) % (360<<16)) < angleInc_q16 )?1:0;
827 currentAngle_raw_q16 += angleInc_q16;
829 for (
int cpos = 0; cpos < 2; ++cpos) {
831 if (angle_q6[cpos] < 0) angle_q6[cpos] += (360<<6);
832 if (angle_q6[cpos] >= (360<<6)) angle_q6[cpos] -= (360<<6);
837 node.
flag = (syncBit[cpos] | ((!syncBit[cpos]) << 1));
841 nodebuffer[nodeCount++] = node;
853 const rplidar_response_dense_capsule_measurement_nodes_t *dense_capsule =
reinterpret_cast<const rplidar_response_dense_capsule_measurement_nodes_t*
>(&capsule);
857 int currentStartAngle_q8 = ((dense_capsule->start_angle_sync_q6 & 0x7FFF) << 2);
860 diffAngle_q8 = (currentStartAngle_q8)-(prevStartAngle_q8);
861 if (prevStartAngle_q8 > currentStartAngle_q8) {
862 diffAngle_q8 += (360 << 8);
865 int angleInc_q16 = (diffAngle_q8 << 8)/40;
866 int currentAngle_raw_q16 = (prevStartAngle_q8 << 8);
874 angle_q6 = (currentAngle_raw_q16 >> 10);
875 syncBit = (((currentAngle_raw_q16 + angleInc_q16) % (360 << 16)) < angleInc_q16) ? 1 : 0;
876 currentAngle_raw_q16 += angleInc_q16;
878 if (angle_q6 < 0) angle_q6 += (360 << 6);
879 if (angle_q6 >= (360 << 6)) angle_q6 -= (360 << 6);
886 node.
flag = (syncBit | ((!syncBit) << 1));
890 nodebuffer[nodeCount++] = node;
902 rplidar_response_hq_capsule_measurement_nodes_t hq_node;
906 size_t scan_count = 0;
908 memset(local_scan, 0,
sizeof(local_scan));
923 for (
size_t pos = 0; pos < count; ++pos)
928 if ((local_scan[0].
flag & RPLIDAR_RESP_MEASUREMENT_SYNCBIT)) {
937 local_scan[scan_count++] = local_buf[pos];
938 if (scan_count ==
_countof(local_scan)) scan_count -= 1;
960 for (i = 0; i<bw; i++){
963 var |= 1 << (bw - 1 - i);
978 for (i = 0; i<256; i++){
980 for (j = 0; j<8; j++){
995 pch = (
unsigned char*)input;
996 _u8 leftBytes = 4 - len & 0x3;
998 for (i = 0; i<len; i++){
999 index = (
unsigned char)(crc^*pch);
1000 crc = (crc >> 8) ^ table[index];
1004 for (i = 0; i < leftBytes; i++) {
1005 index = (
unsigned char)(crc^0);
1006 crc = (crc >> 8) ^ table[index];
1008 return crc^0xffffffff;
1030 _u8 recvBuffer[
sizeof(rplidar_response_hq_capsule_measurement_nodes_t)];
1031 _u8 *nodeBuffer = (
_u8*)&node;
1034 while ((waitTime=
getms() - startTs) <= timeout) {
1035 size_t remainSize =
sizeof(rplidar_response_hq_capsule_measurement_nodes_t) - recvPos;
1043 if (recvSize > remainSize) recvSize = remainSize;
1047 for (
size_t pos = 0; pos < recvSize; ++pos) {
1048 _u8 currentByte = recvBuffer[pos];
1052 _u8 tmp = (currentByte);
1063 case sizeof(rplidar_response_hq_capsule_measurement_nodes_t) - 1 - 4:
1068 case sizeof(rplidar_response_hq_capsule_measurement_nodes_t) - 1:
1074 nodeBuffer[recvPos++] = currentByte;
1075 if (recvPos ==
sizeof(rplidar_response_hq_capsule_measurement_nodes_t)) {
1076 _u32 crcCalc2 =
_crc32(nodeBuffer,
sizeof(rplidar_response_hq_capsule_measurement_nodes_t) - 4);
1078 if(crcCalc2 == node.crc32){
1100 nodebuffer[nodeCount++] = node_hq.node_hq[pos];
1111 static const _u32 VBS_SCALED_BASE[] = {
1119 static const _u32 VBS_SCALED_LVL[] = {
1127 static const _u32 VBS_TARGET_BASE[] = {
1135 for (
size_t i = 0; i <
_countof(VBS_SCALED_BASE); ++i)
1137 int remain = ((int)scaled - (
int)VBS_SCALED_BASE[i]);
1139 scaleLevel = VBS_SCALED_LVL[i];
1140 return VBS_TARGET_BASE[i] + (remain << scaleLevel);
1151 int currentStartAngle_q8 = ((capsule.start_angle_sync_q6 & 0x7FFF) << 2);
1154 diffAngle_q8 = (currentStartAngle_q8)-(prevStartAngle_q8);
1155 if (prevStartAngle_q8 > currentStartAngle_q8) {
1156 diffAngle_q8 += (360 << 8);
1159 int angleInc_q16 = (diffAngle_q8 << 3) / 3;
1160 int currentAngle_raw_q16 = (prevStartAngle_q8 << 8);
1171 int dist_major = (combined_x3 & 0xFFF);
1176 int dist_predict1 = (((int)(combined_x3 << 10)) >> 22);
1177 int dist_predict2 = (((int)combined_x3) >> 22);
1181 _u32 scalelvl1, scalelvl2;
1186 dist_major2 = (capsule.ultra_cabins[0].combined_x3 & 0xFFF);
1197 int dist_base1 = dist_major;
1198 int dist_base2 = dist_major2;
1200 if ((!dist_major) && dist_major2) {
1201 dist_base1 = dist_major2;
1202 scalelvl1 = scalelvl2;
1206 dist_q2[0] = (dist_major << 2);
1207 if ((dist_predict1 == 0xFFFFFE00) || (dist_predict1 == 0x1FF)) {
1210 dist_predict1 = (dist_predict1 << scalelvl1);
1211 dist_q2[1] = (dist_predict1 + dist_base1) << 2;
1215 if ((dist_predict2 == 0xFFFFFE00) || (dist_predict2 == 0x1FF)) {
1218 dist_predict2 = (dist_predict2 << scalelvl2);
1219 dist_q2[2] = (dist_predict2 + dist_base2) << 2;
1223 for (
int cpos = 0; cpos < 3; ++cpos)
1226 syncBit[cpos] = (((currentAngle_raw_q16 + angleInc_q16) % (360 << 16)) < angleInc_q16) ? 1 : 0;
1228 int offsetAngleMean_q16 = (int)(7.5 * 3.1415926535 * (1 << 16) / 180.0);
1230 if (dist_q2[cpos] >= (50 * 4))
1232 const int k1 = 98361;
1233 const int k2 = int(k1 / dist_q2[cpos]);
1235 offsetAngleMean_q16 = (int)(8 * 3.1415926535 * (1 << 16) / 180) - (k2 << 6) - (k2 * k2 * k2) / 98304;
1238 angle_q6[cpos] = ((currentAngle_raw_q16 - int(offsetAngleMean_q16 * 180 / 3.14159265)) >> 10);
1239 currentAngle_raw_q16 += angleInc_q16;
1241 if (angle_q6[cpos] < 0) angle_q6[cpos] += (360 << 6);
1242 if (angle_q6[cpos] >= (360 << 6)) angle_q6[cpos] -= (360 << 6);
1246 node.
flag = (syncBit[cpos] | ((!syncBit[cpos]) << 1));
1251 nodebuffer[nodeCount++] = node;
1265 rplidar_response_device_info_t devinfo;
1270 if (devinfo.firmware_version >= ((0x1 << 8) | 24)) {
1278 rplidar_payload_get_scan_conf_t query;
1279 memset(&query, 0,
sizeof(query));
1281 int sizeVec = reserve.size();
1283 int maxLen =
sizeof(query.reserved) /
sizeof(query.reserved[0]);
1284 if (sizeVec > maxLen) sizeVec = maxLen;
1287 memcpy(query.reserved, &reserve[0], reserve.size());
1297 rplidar_ans_header_t response_header;
1308 if (header_size <
sizeof(type)) {
1316 std::vector<_u8> dataBuf;
1317 dataBuf.resize(header_size);
1321 _u32 replyType = -1;
1322 memcpy(&replyType, &dataBuf[0],
sizeof(type));
1323 if (replyType != type) {
1328 int payLoadLen = header_size -
sizeof(
type);
1331 if (payLoadLen <= 0) {
1335 outputBuf.resize(payLoadLen);
1336 memcpy(&outputBuf[0], &dataBuf[0] +
sizeof(type), payLoadLen);
1344 std::vector<_u8> answer;
1345 bool lidarSupportConfigCmds =
false;
1349 if (lidarSupportConfigCmds)
1355 if (answer.size() <
sizeof(
_u16)) {
1359 const _u16 *p_answer =
reinterpret_cast<const _u16*
>(&answer[0]);
1360 outMode = *p_answer;
1375 std::vector<_u8> reserve(2);
1376 memcpy(&reserve[0], &scanModeID,
sizeof(scanModeID));
1378 std::vector<_u8> answer;
1384 if (answer.size() <
sizeof(
_u32))
1389 sampleDurationRes = (float)(*result >> 8);
1396 std::vector<_u8> reserve(2);
1397 memcpy(&reserve[0], &scanModeID,
sizeof(scanModeID));
1399 std::vector<_u8> answer;
1405 if (answer.size() <
sizeof(
_u32))
1410 maxDistance = (float)(*result >> 8);
1417 std::vector<_u8> reserve(2);
1418 memcpy(&reserve[0], &scanModeID,
sizeof(scanModeID));
1420 std::vector<_u8> answer;
1426 if (answer.size() <
sizeof(
_u8))
1430 const _u8 *
result =
reinterpret_cast<const _u8*
>(&answer[0]);
1438 std::vector<_u8> reserve(2);
1439 memcpy(&reserve[0], &scanModeID,
sizeof(scanModeID));
1441 std::vector<_u8> answer;
1447 int len = answer.size();
1449 memcpy(modeName, &answer[0], len);
1456 bool confProtocolSupported =
false;
1460 if (confProtocolSupported)
1470 for (
_u16 i = 0; i < modeCount; i++)
1473 memset(&scanModeInfoTmp, 0,
sizeof(scanModeInfoTmp));
1474 scanModeInfoTmp.
id = i;
1495 outModes.push_back(scanModeInfoTmp);
1501 rplidar_response_sample_rate_t sampleRateTmp;
1505 bool ifSupportExpScan =
false;
1511 stdScanModeInfo.
us_per_sample = sampleRateTmp.std_sample_duration_us;
1514 strcpy(stdScanModeInfo.
scan_mode,
"Standard");
1515 outModes.push_back(stdScanModeInfo);
1516 if (ifSupportExpScan)
1520 expScanModeInfo.
us_per_sample = sampleRateTmp.express_sample_duration_us;
1523 strcpy(expScanModeInfo.
scan_mode,
"Express");
1524 outModes.push_back(expScanModeInfo);
1534 std::vector<_u8> answer;
1540 if (answer.size() <
sizeof(
_u16)) {
1543 const _u16 *p_answer =
reinterpret_cast<const _u16*
>(&answer[0]);
1544 modeCount = *p_answer;
1555 bool ifSupportLidarConf =
false;
1562 if (ifSupportLidarConf)
1574 bool isExpScanSupported =
false;
1579 if (isExpScanSupported)
1587 if(ifSupportLidarConf)
1621 rplidar_response_sample_rate_t sampleRateTmp;
1624 outUsedScanMode->
us_per_sample = sampleRateTmp.std_sample_duration_us;
1627 strcpy(outUsedScanMode->
scan_mode,
"Standard");
1644 return startScan(force,
false, 0, outUsedScanMode);
1648 bool ifSupportLidarConf =
false;
1652 if (outUsedScanMode)
1654 outUsedScanMode->
id = scanMode;
1655 if (ifSupportLidarConf)
1685 rplidar_response_sample_rate_t sampleRateTmp;
1689 outUsedScanMode->
us_per_sample = sampleRateTmp.express_sample_duration_us;
1692 strcpy(outUsedScanMode->
scan_mode,
"Express");
1698 if (ifSupportLidarConf)
1710 rplidar_payload_express_scan_t scanReq;
1711 memset(&scanReq, 0,
sizeof(scanReq));
1713 scanReq.working_mode =
_u8(scanMode);
1714 scanReq.working_flags = options;
1721 rplidar_ans_header_t response_header;
1727 if (response_header.type != scanAnsType) {
1735 if (header_size <
sizeof(rplidar_response_capsule_measurement_nodes_t)) {
1744 if (header_size <
sizeof(rplidar_response_capsule_measurement_nodes_t)) {
1752 if (header_size <
sizeof(rplidar_response_hq_capsule_measurement_nodes_t)) {
1760 if (header_size <
sizeof(rplidar_response_ultra_capsule_measurement_nodes_t)) {
1806 for (
size_t i = 0; i < size_to_copy; i++)
1809 count = size_to_copy;
1836 count = size_to_copy;
1849 DEPRECATED_WARN(
"getScanDataWithInterval(rplidar_response_measurement_node_t*, size_t&)",
"getScanDataWithInterval(rplidar_response_measurement_node_hq_t*, size_t&)");
1851 size_t size_to_copy = 0;
1860 for (
size_t i = 0; i < size_to_copy; i++)
1866 count = size_to_copy;
1873 size_t size_to_copy = 0;
1890 count = size_to_copy;
1898 static inline float getAngle(
const rplidar_response_measurement_node_t& node)
1903 static inline void setAngle(rplidar_response_measurement_node_t& node,
float v)
1921 return node.distance_q2;
1929 template <
class TNode>
1935 template <
class TNode >
1938 float inc_origin_angle = 360.f/count;
1942 for (i = 0; i < count; i++) {
1948 float expect_angle =
getAngle(nodebuffer[i+1]) - inc_origin_angle;
1949 if (expect_angle < 0.0
f) expect_angle = 0.0f;
1950 setAngle(nodebuffer[i], expect_angle);
1960 for (i = count - 1; i >= 0; i--) {
1964 while(i != (count - 1)) {
1966 float expect_angle =
getAngle(nodebuffer[i-1]) + inc_origin_angle;
1967 if (expect_angle > 360.0
f) expect_angle -= 360.0f;
1968 setAngle(nodebuffer[i], expect_angle);
1975 float frontAngle =
getAngle(nodebuffer[0]);
1976 for (i = 1; i < count; i++) {
1978 float expect_angle = frontAngle + i * inc_origin_angle;
1979 if (expect_angle > 360.0
f) expect_angle -= 360.0f;
1980 setAngle(nodebuffer[i], expect_angle);
1985 std::sort(nodebuffer, nodebuffer + count, &angleLessThan<TNode>);
1992 DEPRECATED_WARN(
"ascendScanData(rplidar_response_measurement_node_t*, size_t)",
"ascendScanData(rplidar_response_measurement_node_hq_t*, size_t)");
1994 return ascendScanData_<rplidar_response_measurement_node_t>(nodebuffer, count);
1999 return ascendScanData_<rplidar_response_measurement_node_hq_t>(nodebuffer, count);
2005 rplidar_cmd_packet_t *
header =
reinterpret_cast<rplidar_cmd_packet_t *
>(pkt_header);
2010 if (payloadsize && payload) {
2015 header->cmd_flag = cmd;
2023 checksum ^= (payloadsize & 0xFF);
2026 for (
size_t pos = 0; pos < payloadsize; ++pos) {
2027 checksum ^= ((
_u8 *)payload)[pos];
2031 _u8 sizebyte = payloadsize;
2046 DEPRECATED_WARN(
"getSampleDuration_uS",
"RplidarScanMode::us_per_sample");
2052 rplidar_response_device_info_t devinfo;
2059 if (devinfo.firmware_version < ((0x1<<8) | 17)) {
2073 rplidar_ans_header_t response_header;
2084 if ( header_size <
sizeof(rplidar_response_sample_rate_t)) {
2108 rplidar_payload_acc_board_flag_t
flag;
2115 rplidar_ans_header_t response_header;
2126 if ( header_size <
sizeof(rplidar_response_acc_board_flag_t)) {
2133 rplidar_response_acc_board_flag_t acc_board_flag;
2134 _chanDev->
recvdata(reinterpret_cast<_u8 *>(&acc_board_flag),
sizeof(acc_board_flag));
2147 rplidar_payload_motor_pwm_t motor_pwm;
2148 motor_pwm.pwm_value = pwm;
2167 rplidar_payload_hq_spd_ctrl_t speedReq;
#define offsetof(_structure, _field)
#define RPLIDAR_RESP_MEASUREMENT_CHECKBIT
virtual u_result connect(const char *ipStr, _u32 port, _u32 flag=0)
#define CLASS_THREAD(c, x)
#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNCBIT
static bool angleLessThan(const TNode &a, const TNode &b)
#define RPLIDAR_ANS_TYPE_MEASUREMENT_HQ
#define RPLIDAR_CMD_FORCE_SCAN
#define RPLIDAR_CONF_SCAN_COMMAND_EXPRESS
rplidar_response_measurement_node_hq_t node_hq[16]
rp::hal::Thread _cachethread
#define RPLIDAR_CONF_SCAN_MODE_MAX_DISTANCE
#define RPLIDAR_CMD_GET_LIDAR_CONF
virtual void _capsuleToNormal(const rplidar_response_capsule_measurement_nodes_t &capsule, rplidar_response_measurement_node_hq_t *nodebuffer, size_t &nodeCount)
#define RPLIDAR_ANS_TYPE_MEASUREMENT_DENSE_CAPSULED
rplidar_response_dense_capsule_measurement_nodes_t _cached_previous_dense_capsuledata
#define RPLIDAR_RESP_MEASUREMENT_ANGLE_SHIFT
#define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED
virtual u_result setLidarSpinSpeed(_u16 rpm, _u32 timeout=DEFAULT_TIMEOUT)
virtual u_result checkSupportConfigCommands(bool &outSupport, _u32 timeoutInMs=DEFAULT_TIMEOUT)
#define RPLIDAR_ANS_TYPE_GET_LIDAR_CONF
bool _is_previous_capsuledataRdy
virtual u_result _waitCapsuledNode(rplidar_response_capsule_measurement_nodes_t &node, _u32 timeout=DEFAULT_TIMEOUT)
#define RPLIDAR_CMD_HQ_MOTOR_SPEED_CTRL
virtual void disconnect()
Disconnect with the RPLIDAR and close the serial port.
#define RPLIDAR_VARBITSCALE_X4_DEST_VAL
virtual void disconnect()
Disconnect with the RPLIDAR and close the serial port.
#define RPLIDAR_ANS_TYPE_SAMPLE_RATE
virtual u_result startScanNormal(bool force, _u32 timeout=DEFAULT_TIMEOUT)
bool _isSupportingMotorCtrl
size_t _cached_scan_node_hq_count_for_interval_retrieve
virtual u_result _waitResponseHeader(rplidar_ans_header_t *header, _u32 timeout=DEFAULT_TIMEOUT)
virtual void _dense_capsuleToNormal(const rplidar_response_capsule_measurement_nodes_t &capsule, rplidar_response_measurement_node_hq_t *nodebuffer, size_t &nodeCount)
bool _is_previous_HqdataRdy
virtual u_result grabScanData(rplidar_response_measurement_node_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT)
virtual u_result reset(_u32 timeout=DEFAULT_TIMEOUT)
virtual u_result _cacheCapsuledScanData()
static void DisposeDriver(RPlidarDriver *drv)
#define RPLIDAR_VARBITSCALE_X8_SRC_BIT
virtual void _ultraCapsuleToNormal(const rplidar_response_ultra_capsule_measurement_nodes_t &capsule, rplidar_response_measurement_node_hq_t *nodebuffer, size_t &nodeCount)
virtual u_result _waitUltraCapsuledNode(rplidar_response_ultra_capsule_measurement_nodes_t &node, _u32 timeout=DEFAULT_TIMEOUT)
#define RPLIDAR_VARBITSCALE_X2_SRC_BIT
virtual u_result startScan(bool force, bool useTypicalScan, _u32 options=0, RplidarScanMode *outUsedScanMode=NULL)
static void printDeprecationWarn(const char *fn, const char *replacement)
rplidar_response_capsule_measurement_nodes_t _cached_previous_capsuledata
virtual u_result startScanExpress(bool force, _u16 scanMode, _u32 options=0, RplidarScanMode *outUsedScanMode=NULL, _u32 timeout=DEFAULT_TIMEOUT)
virtual void disconnect()=0
Disconnect with the RPLIDAR and close the serial port.
#define RPLIDAR_ANS_HEADER_SIZE_MASK
virtual u_result connect(const char *port_path, _u32 baudrate, _u32 flag=0)
_u16 _cached_sampleduration_std
std_msgs::Header * header(M &m)
#define RPLIDAR_CMD_GET_DEVICE_INFO
#define RPLIDAR_ANS_TYPE_DEVHEALTH
#define RPLIDAR_CMD_SYNC_BYTE
virtual u_result clearNetSerialRxCache()
#define RPLIDAR_RESP_MEASUREMENT_SYNCBIT
virtual u_result getLidarConf(_u32 type, std::vector< _u8 > &outputBuf, const std::vector< _u8 > &reserve=std::vector< _u8 >(), _u32 timeout=DEFAULT_TIMEOUT)
virtual bool waitfordata(size_t data_count, _u32 timeout=-1, size_t *returned_size=NULL)=0
virtual u_result grabScanDataHq(rplidar_response_measurement_node_hq_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT)
virtual bool bind(const char *, uint32_t)=0
virtual u_result getSampleDuration_uS(rplidar_response_sample_rate_t &rateInfo, _u32 timeout=DEFAULT_TIMEOUT)
static _u32 _varbitscale_decode(_u32 scaled, _u32 &scaleLevel)
#define RPLIDAR_VARBITSCALE_X16_SRC_BIT
#define RPLIDAR_CONF_SCAN_MODE_US_PER_SAMPLE
static void _crc32_init(_u32 poly)
#define RESULT_INSUFFICIENT_MEMORY
#define RPLIDAR_ANS_SYNC_BYTE1
virtual u_result _cacheHqScanData()
virtual u_result getScanDataWithIntervalHq(rplidar_response_measurement_node_hq_t *nodebuffer, size_t &count)
virtual u_result _sendCommand(_u8 cmd, const void *payload=NULL, size_t payloadsize=0)
#define RPLIDAR_RESP_MEASUREMENT_HQ_SYNC
#define RPLIDAR_CMD_GET_SAMPLERATE
virtual u_result getHealth(rplidar_response_device_health_t &health, _u32 timeout=DEFAULT_TIMEOUT)
virtual int senddata(const _u8 *data, size_t size)=0
#define RESULT_REMAINING_DATA
virtual void ReleaseRxTx()
_u16 _cached_sampleduration_express
virtual ~RPlidarDriverSerial()
virtual u_result getScanModeName(char *modeName, _u16 scanModeID, _u32 timeoutInMs=DEFAULT_TIMEOUT)
virtual u_result startMotor()
Start RPLIDAR's motor when using accessory board.
#define RPLIDAR_CMD_RESET
virtual u_result setMotorPWM(_u16 pwm)
virtual u_result _cacheUltraCapsuledScanData()
#define RPLIDAR_RESP_ACC_BOARD_FLAG_MOTOR_CTRL_SUPPORT_MASK
static _u32 _crc32cal(_u32 crc, void *input, _u16 len)
virtual u_result stop(_u32 timeout=DEFAULT_TIMEOUT)
#define RPLIDAR_CMDFLAG_HAS_PAYLOAD
rplidar_response_measurement_node_hq_t _cached_scan_node_hq_buf[8192]
#define RPLIDAR_ANS_TYPE_ACC_BOARD_FLAG
virtual u_result getTypicalScanMode(_u16 &outMode, _u32 timeoutInMs=DEFAULT_TIMEOUT)
Get typical scan mode of lidar.
virtual u_result getFrequency(bool inExpressMode, size_t count, float &frequency, bool &is4kmode)
virtual u_result _waitNode(rplidar_response_measurement_node_t *node, _u32 timeout=DEFAULT_TIMEOUT)
size_t _cached_scan_node_hq_count
static u_result ascendScanData_(TNode *nodebuffer, size_t count)
#define RPLIDAR_CMD_SET_MOTOR_PWM
static void setAngle(rplidar_response_measurement_node_t &node, float v)
#define RPLIDAR_CMD_EXPRESS_SCAN
void set(bool isSignal=true)
#define RPLIDAR_CONF_SCAN_MODE_ANS_TYPE
RPlidarDriverImplCommon()
#define RESULT_OPERATION_TIMEOUT
#define RPLIDAR_ANS_TYPE_MEASUREMENT
u_result join(unsigned long timeout=-1)
#define RPLIDAR_CMD_GET_ACC_BOARD_FLAG
#define RPLIDAR_CONF_SCAN_COMMAND_STD
void _disableDataGrabbing()
virtual bool isConnected()
Returns TRUE when the connection has been established.
virtual u_result ascendScanData(rplidar_response_measurement_node_t *nodebuffer, size_t count)
static void convert(const rplidar_response_measurement_node_t &from, rplidar_response_measurement_node_hq_t &to)
rplidar_response_hq_capsule_measurement_nodes_t _cached_previous_Hqdata
virtual u_result getDeviceInfo(rplidar_response_device_info_t &info, _u32 timeout=DEFAULT_TIMEOUT)
#define RPLIDAR_RESP_MEASUREMENT_QUALITY_SHIFT
Locker::LOCK_STATUS lock(unsigned long timeout=0xFFFFFFFF)
virtual u_result getScanModeCount(_u16 &modeCount, _u32 timeoutInMs=DEFAULT_TIMEOUT)
static _u32 _bitrev(_u32 input, _u16 bw)
virtual void _HqToNormal(const rplidar_response_hq_capsule_measurement_nodes_t &node_hq, rplidar_response_measurement_node_hq_t *nodebuffer, size_t &nodeCount)
unsigned long wait(unsigned long timeout=0xFFFFFFFF)
#define RPLIDAR_CONF_SCAN_MODE_NAME
#define RPLIDAR_CONF_SCAN_MODE_COUNT
static float getAngle(const rplidar_response_measurement_node_t &node)
virtual u_result getAllSupportedScanModes(std::vector< RplidarScanMode > &outModes, _u32 timeoutInMs=DEFAULT_TIMEOUT)
Get all scan modes that supported by lidar.
#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_1
#define DEFAULT_MOTOR_PWM
static RPlidarDriver * CreateDriver(_u32 drivertype=DRIVER_TYPE_SERIALPORT)
virtual u_result getScanDataWithInterval(rplidar_response_measurement_node_t *nodebuffer, size_t &count)
#define RESULT_OPERATION_NOT_SUPPORT
#define RPLIDAR_VARBITSCALE_X8_DEST_VAL
#define RPLIDAR_CONF_SCAN_MODE_TYPICAL
virtual u_result checkExpressScanSupported(bool &support, _u32 timeout=DEFAULT_TIMEOUT)
virtual u_result _waitHqNode(rplidar_response_hq_capsule_measurement_nodes_t &node, _u32 timeout=DEFAULT_TIMEOUT)
#define RESULT_OPERATION_FAIL
#define RPLIDAR_VARBITSCALE_X2_DEST_VAL
virtual u_result getScanModeAnsType(_u8 &ansType, _u16 scanModeID, _u32 timeoutInMs=DEFAULT_TIMEOUT)
virtual u_result stopMotor()
Stop RPLIDAR's motor when using accessory board.
#define RESULT_ALREADY_DONE
virtual u_result getLidarSampleDuration(float &sampleDurationRes, _u16 scanModeID, _u32 timeoutInMs=DEFAULT_TIMEOUT)
#define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_2
#define RPLIDAR_CMD_GET_DEVICE_HEALTH
#define RPLIDAR_VARBITSCALE_X16_DEST_VAL
#define DEPRECATED_WARN(fn, replacement)
rplidar_response_measurement_node_hq_t _cached_scan_node_hq_buf_for_interval_retrieve[8192]
#define RPLIDAR_ANS_SYNC_BYTE2
static u_result _crc32(_u8 *ptr, _u32 len)
static _u16 getDistanceQ2(const rplidar_response_measurement_node_t &node)
rplidar_response_ultra_capsule_measurement_nodes_t _cached_previous_ultracapsuledata
virtual u_result getMaxDistance(float &maxDistance, _u16 scanModeID, _u32 timeoutInMs=DEFAULT_TIMEOUT)
virtual u_result _cacheScanData()
#define RESULT_INVALID_DATA
virtual u_result _waitScanData(rplidar_response_measurement_node_t *nodebuffer, size_t &count, _u32 timeout=DEFAULT_TIMEOUT)
#define RPLIDAR_ANS_TYPE_DEVINFO
virtual u_result checkMotorCtrlSupport(bool &support, _u32 timeout=DEFAULT_TIMEOUT)
virtual ~RPlidarDriverTCP()
virtual u_result checkIfTofLidar(bool &isTofLidar, _u32 timeout=DEFAULT_TIMEOUT)
virtual int recvdata(unsigned char *data, size_t size)=0
#define RPLIDAR_VARBITSCALE_X4_SRC_BIT