Manual

www.ydlidar.com Copyright 2015-2018 Ydlidar Team
5 / 12
Note 1: The G4 data communication adopts the little-endian mode and the low-order mode.
Note 2: In the response message, the lower 6 bits of the 6th byte belong to the response length and the upper 2
bits belong to the response mode.
DATA PROTOCOL
Different system commands have different packet contents. In the packets of different types of codes,
the data protocol of the response content is also not the same. Therefore, the user needs to parse the
data in the response content according to the corresponding data protocol, such as point cloud data,
device information, and the like.
Scan command [A5 60]
When an external device sends a scan command to G4, G4 enters scan mode and feeds back point
cloud data. The reply message is:
FIG 4 YDLIDAR G4 SCAN COMMAND
The sixth byte of the sixth high is 01, so the answer mode value is 0x1, which is a continuous
response. Ignore response length, type code is 0x81.
The response content is the point cloud data scanned by the system. According to the following data
structure, the data is sent to the external device in hexadecimal to the serial port.
FIG 5 SCAN COMMAND RESPONSE CONTENT DATA STRUCTURE
CHART 4 SCAN COMMAND RESPONSE CONTENT DATA STRUCTURE DESCRIPTION
Content
Name
Description
PH(2B)
Packet header
2B in length, fixed at 0x55AA, low in front, high in back
CT(1B)
Package type
Indicates the current packet type. 0x00: Point cloud packet 0x01: Zero packet.
LSN(1B)
Sample quantity
Indicates the number of sampling points contained in the current packet. There is only one
zero point of data in the zero packet. The value is 1.
FSA(2B)
Starting angle
The angle data corresponding to the first sample point in the sampled data
LSA(2B)
End angle
The angle data corresponding to the last sample point in the sampled data
40
A5
5A
05
00
00
81
‥‥
Start sign
Response Length
Response mode
Type code
Content
LL
HH
LL
HH
LL
HH
LL
HH
LL
HH
LL
HH
LL
HH
‥‥
PH
CT
FSA
LSA
CS
S1
S2
‥‥
LSN
Byte offset:
0
2
4
6
8
10
12