rplidar_cmd.h
Go to the documentation of this file.
1 /*
2  * RPLIDAR SDK
3  *
4  * Copyright (c) 2009 - 2014 RoboPeak Team
5  * http://www.robopeak.com
6  * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd.
7  * http://www.slamtec.com
8  *
9  */
10 /*
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #pragma once
36 
37 #include "rplidar_protocol.h"
38 
39 // Commands
40 //-----------------------------------------
41 
42 // Commands without payload and response
43 #define RPLIDAR_CMD_STOP 0x25
44 #define RPLIDAR_CMD_SCAN 0x20
45 #define RPLIDAR_CMD_FORCE_SCAN 0x21
46 #define RPLIDAR_CMD_RESET 0x40
47 
48 
49 // Commands without payload but have response
50 #define RPLIDAR_CMD_GET_DEVICE_INFO 0x50
51 #define RPLIDAR_CMD_GET_DEVICE_HEALTH 0x52
52 
53 #define RPLIDAR_CMD_GET_SAMPLERATE 0x59 //added in fw 1.17
54 
55 #define RPLIDAR_CMD_HQ_MOTOR_SPEED_CTRL 0xA8
56 
57 // Commands with payload and have response
58 #define RPLIDAR_CMD_EXPRESS_SCAN 0x82 //added in fw 1.17
59 #define RPLIDAR_CMD_HQ_SCAN 0x83 //added in fw 1.24
60 #define RPLIDAR_CMD_GET_LIDAR_CONF 0x84 //added in fw 1.24
61 #define RPLIDAR_CMD_SET_LIDAR_CONF 0x85 //added in fw 1.24
62 //add for A2 to set RPLIDAR motor pwm when using accessory board
63 #define RPLIDAR_CMD_SET_MOTOR_PWM 0xF0
64 #define RPLIDAR_CMD_GET_ACC_BOARD_FLAG 0xFF
65 
66 #if defined(_WIN32)
67 #pragma pack(1)
68 #endif
69 
70 
71 // Payloads
72 // ------------------------------------------
73 #define RPLIDAR_EXPRESS_SCAN_MODE_NORMAL 0
74 #define RPLIDAR_EXPRESS_SCAN_MODE_FIXANGLE 0 // won't been supported but keep to prevent build fail
75 //for express working flag(extending express scan protocol)
76 #define RPLIDAR_EXPRESS_SCAN_FLAG_BOOST 0x0001
77 #define RPLIDAR_EXPRESS_SCAN_FLAG_SUNLIGHT_REJECTION 0x0002
78 
79 //for ultra express working flag
80 #define RPLIDAR_ULTRAEXPRESS_SCAN_FLAG_STD 0x0001
81 #define RPLIDAR_ULTRAEXPRESS_SCAN_FLAG_HIGH_SENSITIVITY 0x0002
82 
83 #define RPLIDAR_HQ_SCAN_FLAG_CCW (0x1<<0)
84 #define RPLIDAR_HQ_SCAN_FLAG_RAW_ENCODER (0x1<<1)
85 #define RPLIDAR_HQ_SCAN_FLAG_RAW_DISTANCE (0x1<<2)
86 
91 } __attribute__((packed)) rplidar_payload_express_scan_t;
92 
96 } __attribute__((packed)) rplidar_payload_hq_scan_t;
97 
101 } __attribute__((packed)) rplidar_payload_get_scan_conf_t;
102 #define MAX_MOTOR_PWM 1023
103 #define DEFAULT_MOTOR_PWM 660
106 } __attribute__((packed)) rplidar_payload_motor_pwm_t;
107 
110 } __attribute__((packed)) rplidar_payload_acc_board_flag_t;
111 
112 // Response
113 // ------------------------------------------
114 #define RPLIDAR_ANS_TYPE_DEVINFO 0x4
115 #define RPLIDAR_ANS_TYPE_DEVHEALTH 0x6
116 
117 #define RPLIDAR_ANS_TYPE_MEASUREMENT 0x81
118 // Added in FW ver 1.17
119 #define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED 0x82
120 #define RPLIDAR_ANS_TYPE_MEASUREMENT_HQ 0x83
121 
122 
123 // Added in FW ver 1.17
124 #define RPLIDAR_ANS_TYPE_SAMPLE_RATE 0x15
125 //added in FW ver 1.23alpha
126 #define RPLIDAR_ANS_TYPE_MEASUREMENT_CAPSULED_ULTRA 0x84
127 //added in FW ver 1.24
128 #define RPLIDAR_ANS_TYPE_GET_LIDAR_CONF 0x20
129 #define RPLIDAR_ANS_TYPE_SET_LIDAR_CONF 0x21
130 #define RPLIDAR_ANS_TYPE_MEASUREMENT_DENSE_CAPSULED 0x85
131 #define RPLIDAR_ANS_TYPE_ACC_BOARD_FLAG 0xFF
132 
133 #define RPLIDAR_RESP_ACC_BOARD_FLAG_MOTOR_CTRL_SUPPORT_MASK (0x1)
136 } __attribute__((packed)) rplidar_response_acc_board_flag_t;
137 
138 
139 #define RPLIDAR_STATUS_OK 0x0
140 #define RPLIDAR_STATUS_WARNING 0x1
141 #define RPLIDAR_STATUS_ERROR 0x2
142 
143 #define RPLIDAR_RESP_MEASUREMENT_SYNCBIT (0x1<<0)
144 #define RPLIDAR_RESP_MEASUREMENT_QUALITY_SHIFT 2
145 
146 #define RPLIDAR_RESP_HQ_FLAG_SYNCBIT (0x1<<0)
147 
148 #define RPLIDAR_RESP_MEASUREMENT_CHECKBIT (0x1<<0)
149 #define RPLIDAR_RESP_MEASUREMENT_ANGLE_SHIFT 1
150 
154 } __attribute__((packed)) rplidar_response_sample_rate_t;
155 
157  _u8 sync_quality; // syncbit:1;syncbit_inverse:1;quality:6;
158  _u16 angle_q6_checkbit; // check_bit:1;angle_q6:15;
160 } __attribute__((packed)) rplidar_response_measurement_node_t;
161 
162 //[distance_sync flags]
163 #define RPLIDAR_RESP_MEASUREMENT_EXP_ANGLE_MASK (0x3)
164 #define RPLIDAR_RESP_MEASUREMENT_EXP_DISTANCE_MASK (0xFC)
165 
167  _u16 distance_angle_1; // see [distance_sync flags]
168  _u16 distance_angle_2; // see [distance_sync flags]
170 } __attribute__((packed)) rplidar_response_cabin_nodes_t;
171 
172 
173 #define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_1 0xA
174 #define RPLIDAR_RESP_MEASUREMENT_EXP_SYNC_2 0x5
175 
176 #define RPLIDAR_RESP_MEASUREMENT_HQ_SYNC 0xA5
177 
178 #define RPLIDAR_RESP_MEASUREMENT_EXP_SYNCBIT (0x1<<15)
179 
181  _u8 s_checksum_1; // see [s_checksum_1]
182  _u8 s_checksum_2; // see [s_checksum_1]
184  rplidar_response_cabin_nodes_t cabins[16];
185 } __attribute__((packed)) rplidar_response_capsule_measurement_nodes_t;
186 
189 } __attribute__((packed)) rplidar_response_dense_cabin_nodes_t;
190 
192  _u8 s_checksum_1; // see [s_checksum_1]
193  _u8 s_checksum_2; // see [s_checksum_1]
195  rplidar_response_dense_cabin_nodes_t cabins[40];
196 } __attribute__((packed)) rplidar_response_dense_capsule_measurement_nodes_t;
197 
198 // ext1 : x2 boost mode
199 
200 #define RPLIDAR_RESP_MEASUREMENT_EXP_ULTRA_MAJOR_BITS 12
201 #define RPLIDAR_RESP_MEASUREMENT_EXP_ULTRA_PREDICT_BITS 10
202 
204  // 31 0
205  // | predict2 10bit | predict1 10bit | major 12bit |
207 } __attribute__((packed)) rplidar_response_ultra_cabin_nodes_t;
208 
210  _u8 s_checksum_1; // see [s_checksum_1]
211  _u8 s_checksum_2; // see [s_checksum_1]
213  rplidar_response_ultra_cabin_nodes_t ultra_cabins[32];
214 } __attribute__((packed)) rplidar_response_ultra_capsule_measurement_nodes_t;
215 
222 
226  rplidar_response_measurement_node_hq_t node_hq[16];
228 }__attribute__((packed)) rplidar_response_hq_capsule_measurement_nodes_t;
229 
230 
231 # define RPLIDAR_CONF_SCAN_COMMAND_STD 0
232 # define RPLIDAR_CONF_SCAN_COMMAND_EXPRESS 1
233 # define RPLIDAR_CONF_SCAN_COMMAND_HQ 2
234 # define RPLIDAR_CONF_SCAN_COMMAND_BOOST 3
235 # define RPLIDAR_CONF_SCAN_COMMAND_STABILITY 4
236 # define RPLIDAR_CONF_SCAN_COMMAND_SENSITIVITY 5
237 
238 #define RPLIDAR_CONF_ANGLE_RANGE 0x00000000
239 #define RPLIDAR_CONF_DESIRED_ROT_FREQ 0x00000001
240 #define RPLIDAR_CONF_SCAN_COMMAND_BITMAP 0x00000002
241 #define RPLIDAR_CONF_MIN_ROT_FREQ 0x00000004
242 #define RPLIDAR_CONF_MAX_ROT_FREQ 0x00000005
243 #define RPLIDAR_CONF_MAX_DISTANCE 0x00000060
244 
245 #define RPLIDAR_CONF_SCAN_MODE_COUNT 0x00000070
246 #define RPLIDAR_CONF_SCAN_MODE_US_PER_SAMPLE 0x00000071
247 #define RPLIDAR_CONF_SCAN_MODE_MAX_DISTANCE 0x00000074
248 #define RPLIDAR_CONF_SCAN_MODE_ANS_TYPE 0x00000075
249 #define RPLIDAR_CONF_SCAN_MODE_TYPICAL 0x0000007C
250 #define RPLIDAR_CONF_SCAN_MODE_NAME 0x0000007F
251 #define RPLIDAR_EXPRESS_SCAN_STABILITY_BITMAP 4
252 #define RPLIDAR_EXPRESS_SCAN_SENSITIVITY_BITMAP 5
253 
257 }__attribute__((packed)) rplidar_response_get_lidar_conf_t;
258 
261 }__attribute__((packed)) rplidar_response_set_lidar_conf_t;
262 
263 
269 } __attribute__((packed)) rplidar_response_device_info_t;
270 
274 } __attribute__((packed)) rplidar_response_device_health_t;
275 
276 // Definition of the variable bit scale encoding mechanism
277 #define RPLIDAR_VARBITSCALE_X2_SRC_BIT 9
278 #define RPLIDAR_VARBITSCALE_X4_SRC_BIT 11
279 #define RPLIDAR_VARBITSCALE_X8_SRC_BIT 12
280 #define RPLIDAR_VARBITSCALE_X16_SRC_BIT 14
281 
282 #define RPLIDAR_VARBITSCALE_X2_DEST_VAL 512
283 #define RPLIDAR_VARBITSCALE_X4_DEST_VAL 1280
284 #define RPLIDAR_VARBITSCALE_X8_DEST_VAL 1792
285 #define RPLIDAR_VARBITSCALE_X16_DEST_VAL 3328
286 
287 #define RPLIDAR_VARBITSCALE_GET_SRC_MAX_VAL_BY_BITS(_BITS_) \
288  ( (((0x1<<(_BITS_)) - RPLIDAR_VARBITSCALE_X16_DEST_VAL)<<4) + \
289  ((RPLIDAR_VARBITSCALE_X16_DEST_VAL - RPLIDAR_VARBITSCALE_X8_DEST_VAL)<<3) + \
290  ((RPLIDAR_VARBITSCALE_X8_DEST_VAL - RPLIDAR_VARBITSCALE_X4_DEST_VAL)<<2) + \
291  ((RPLIDAR_VARBITSCALE_X4_DEST_VAL - RPLIDAR_VARBITSCALE_X2_DEST_VAL)<<1) + \
292  RPLIDAR_VARBITSCALE_X2_DEST_VAL - 1)
293 
294 
295 #if defined(_WIN32)
296 #pragma pack()
297 #endif
_u8 reserved[32]
Definition: rplidar_cmd.h:3
rplidar_response_measurement_node_hq_t node_hq[16]
Definition: rplidar_cmd.h:4
_u8 payload[0]
Definition: rplidar_cmd.h:3
_u8 serialnum[16]
Definition: rplidar_cmd.h:5
rplidar_response_ultra_cabin_nodes_t ultra_cabins[32]
Definition: rplidar_cmd.h:5
struct _rplidar_payload_express_scan_t __attribute__((packed)) rplidar_payload_express_scan_t
uint8_t _u8
Definition: rptypes.h:63
uint32_t _u32
Definition: rptypes.h:69
rplidar_response_cabin_nodes_t cabins[16]
Definition: rplidar_cmd.h:5
uint64_t _u64
Definition: rptypes.h:72
uint16_t _u16
Definition: rptypes.h:66


rplidar_ros
Author(s):
autogenerated on Wed Mar 20 2019 07:54:15