YDLIDAR TG Series User manual

Shenzhen EAI Technology Co.,Ltd.
DOC#:01.13.005301
www.ydlidar.com
TG SERIES
DEVELOPMENT
MANUAL

Copyright 2019 EAI All Rights Reserved
CONTENTS
1WORKING MECHANISM.........................................................................1
1.1 System Workflow....................................................................................... 1
2SYSTEM COMMUNICATION ..................................................................2
2.1 Communication Mechanism................................................................... 2
2.2 System Command ..................................................................................... 2
2.3 System Messages ...................................................................................... 3
3DATA PROTOCOL ....................................................................................4
3.1 Scan Command [A5 60]............................................................................ 4
3.2 Stop Command [A5 65] ............................................................................ 6
3.3 Device Information [A5 90] ..................................................................... 6
3.4 Health Status [A5 91]................................................................................ 7
3.5 Zero Angle Deviation [A5 93].................................................................. 8
3.6 Scan Frequency Setting [A5 09/0A/0B/0C]......................................... 8
3.7 Scan Frequency Acquisition [A5 0D] .................................................... 9
3.8 Power-down Protection Switching [A5 D9]......................................... 9
3.9 Restart Command [A5 80] ....................................................................... 9
3.10Motor Speed Control...............................................................................10
4ATTENTION............................................................................................ 10
5REVISE..................................................................................................... 11

Copyright 2019 EAI All Rights Reserved 1 / 11
1WORKING MECHANISM
The YDLIDAR TG Series (including TG5, TG15, TG30, TG50 etc) system has 4 working
modes: idle mode, scan mode, stop mode, Power-down protection mode.
➢Idle mode: When TG Series is powered on, the default mode is idle mode. In idle mode, the TG
Series's ranging unit does not work and the laser is not light.
➢Scan mode: When TG Series is in scanning mode, the ranging unit turns on the laser. When the
TG Series starts to work, it continuously uses lasers to measure the external environment and
outputs it in real time after background processing.
➢Stop mode: When TG Series runs with an error, such as turning on the scanner, the laser is off,
the motor does not rotate, etc.TG Series will automatically turn off the distance measuring unit
and feedback the error code.
➢Power-down protection mode: In this mode, lidar needs to continuously receive the scan
commands with a less than 3 second’s transmission interval so that it will keep working. If the
lidar does not receive a continuous scan command, the system will automatically stop. This
mode is not enabled by default.
1.1 System Workflow
FIG 1 YDLIDAR TG SERIES WORKFLOW

Copyright 2019 EAI All Rights Reserved 2 / 11
2SYSTEM COMMUNICATION
2.1 Communication Mechanism
TG Series communicates commands and data with external devices through the serial port.
When an external device sends a system command to TG Series, TG Series resolves the system
command and returns a corresponding reply message. According to the command content, TG Series
switches the corresponding working status. According to the content of the message, the external
system can parse the message and obtain the response data.
FIG 2 YDLIDAR TG SERIES SYSTEM COMMUNICATION
2.2 System Command
The external system can set the corresponding working status of TG Series and send
corresponding data by sending related system commands. The TG Series system command is unified
to 2 bytes, where the start byte is 0xA5 and the second byte is the command content. The system
commands issued by TG Series are as follows:
CHART 1 YDLIDAR TG SERIES SYSTEM COMMAND
System Command
Description
Mode
Switching
Answer
Mode
0×A5
(Start)
0×60
Start scanning and export point cloud data
Scan mode
Sustained
response
0×65
Stop and stop scanning
Stop mode
No answer
0×90
Get device information (model, firmware, hardware
version)
No
Single
response
0×91
Get device health state
No
Single
response
0×09
Increase the current scan frequency of 0.1Hz
No
Single
response
0×0A
Reduce the current scan frequency of 0.1Hz
No
Single
response
0×0B
Increase the current scan frequency of 1Hz
No
Single
response
0×0C
Reduce the current scan frequency of 1Hz
No
Single
response
0×0D
Get the currently set scan frequency
No
Single
response
0×D9
Power-down protection mode switch (off by default)
No
Single
response
0×80
Soft restart
/
No response
0×93
Zero angle deviation
No
Single
response
Parse messages
Retrieve data
Parsing command
External device
System command
Reply message
TG series
Switch mode

Copyright 2019 EAI All Rights Reserved 3 / 11
2.3 System Messages
The system message is a response message that the system feeds back based on the received
system command. According to different system commands, the reply mode and response content of
the system message are also different. There are three kinds of response modes: no response, single
response, continuous response.
No response means that the system does not return any messages. A single reply indicates that
the system's message length is limited, and the response ends once. Continuous response means that
the system's message length is infinite and needs to send data continuously, such as when entering
the scan mode.
The one-time response and continuous response messages use the same data protocol. The
contents of the protocol are: start sign, response length, response mode, type code and response
content, and are output through the serial port hexadecimal system.
CHART 2 YDLIDAR TG SERIES SYSTEM MESSAGE DATA PROTOCOL
Start Sign
Response
Length
Response Mode
Type Code
Content
16bits
30bits
2bits
8bits
/
FIG 3 YDLIDAR TG SERIES SYSTEM MESSAGE DATA PROTOCOL
➢Start sign: TG Series's message sign is unified as 0xA55A.
➢Response length: Means the length of the response content, when the answer mode is
continuous, the length should be infinite, so this value is invalid.
➢Response mode: This bit is only 2 bits, which means this time it is a single response or
continuous response. Its value and corresponding mode are as follows:
CHART 3 YDLIDAR TG SERIES RESPONSE VALUE AND CORRESPONDING
RESPONSE MODE
Mode Value
0x0
0x1
0x2 0x3
Response mode
Single response
continuous response
Undefined
➢Type code: Different system commands correspond to different types codes.
➢Content: Different system commands, feedback different data content, and their data protocols
are also different.
Note 1: The TG Series data communication adopts the little-endian mode and the low-order mode.
Note 2: In the reply message, the lower 6 bits of the 6th byte belong to the response length and the upper 2 bits
MSB
LSB
MSB
LSB
MSB
LSB
LSB
‥‥
Start sign
Length
Mode
Type code
Content
Bite offset:
0
2
4
6
7

Copyright 2019 EAI All Rights Reserved 4 / 11
belong to the response mode.
3DATA 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, users need to parse
the data in the response content according to the corresponding data protocol, such as point cloud
data, device information, etc.
3.1 Scan Command [A5 60]
When an external device sends a scan command to TG Series, TG Series goes into scan mode
and feeds back point cloud data. The reply message is:
FIG 4 YDLIDAR TG SERIES SCAN COMMAND
The 6th byte high 2 is 01, so the response mode takes 0x1, which is a continuous response,
ignoring the response length, and the 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.
Byte offset:
FIG 5 SCAN COMMAND RESPONSE CONTENT DATA STRUCTURE
40
A5
5A
05
00
00
81
‥‥
Start sign
Length
Mode
Type code
Content
LSB
MSB
LSB
MSB
LSB
MSB
LSB
MSB
LSB
MSB
LSB
MSB
LSB
MSB
‥‥
PH
CT
FSA
LSA
CS
S1
S2
‥‥
LSN
0
2
4
6
8
10
12

Copyright 2019 EAI All Rights Reserved 5 / 11
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
CT&0x01 is the type information of the point cloud:
CT&0x01 = 0x00: Point Cloud Packet CTt&0x01 = 0x01: Start Packet.
CT&0xFE denotes other information:
When CT&0x01 = 0x01, that is, the current data is zero packet data:
CT&0xFE represents the frequency information calculated by lidar, which can
be 3.0Hz~15.7Hz
The specific algorithm Freq = ((CTt&0xFE)>> 1) + 30)/10 Hz
For example, CT= 0XB7, the current packet is the starting packet and the
rotating speed is 12.1Hz
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)
Start 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
CS(2B)
Check code
The check code of the current data packet uses a two-byte exclusive OR to
check the current data packet.
Si(2B)
Sample data
The system test sampling data is the distance data of the sampling point.
➢Start bit resolution:
When CT&0x01 =1 is detected, it indicates that the packet data is the initial packet,
representing the beginning of a cycle of data. In this packet, LSN=1, that is, the number of Si is 1;
When CT&0x01 = 0 is detected, it indicates that the packet data is an intermediate packet in a
data circle, not the starting point of a data circle.
See the following for the detailed value analysis of the distance and Angle.
➢Distance analysis:
Distance solution formula:
= The unit is mm.
Among then, is the first- and second-byte data of the sampled data . Set the sampling data
as E8 03. Since the system is in small-terminal mode, the sampling point D = 0x03E8 is substituted
into the Distance solution formula to obtain the Distance=1000mm.
➢Angle analysis:
Angle data is stored in FSA and LSA, and each Angle data has the following data structure,
where C is the check bit and its value is fixed to 1. The specific process is as follows:
FIG 6 S node data

Copyright 2019 EAI All Rights Reserved 6 / 11
Starting angle solution formula:AngleFSA =
End angle solution formula:AngleLSA =
Intermediate angle solution formula:
=
AngleFSA
Rshiftbit (data,1) means shifting the data to the right by one bit. means the
clockwise angle difference from the starting angle (uncorrected value) to the ending angle
(uncorrected value), and LSN represents the number of packet samples in this frame.
➢Check code parsing:
The check code uses a two-byte exclusive OR to verify the
current data packet. The check code itself does not participate in
XOR operations, and the XOR order is not strictly in byte order.
The XOR sequence is as shown in the figure. Therefore, the
check code solution formula is:
CS=
(Ci) =1,2,…,end
indicates the XOR of the element from subscript 1 to end. However, XOR satisfies the
exchange law, and the actual solution may not need to follow the XOR sequence.
3.2 Stop Command [A5 65]
When the system is in the scanning state, TG Series always sends point cloud data to the
outside. If you need to turn off scanning at this time, you can send this command to stop the system
from scanning. After the stop command is sent, the system will be in the standby state. At this time,
the ranging unit of the device is in the low power mode, and the laser is not lit.
The command is unresponsive, so the system will not respond to any messages after receiving
the command.
3.3 Device Information [A5 90]
When an external device sends a Get Device Information command to (A5 90), TG Series will
feedback the device's model, firmware version, and hardware version, and the device's factory serial
number. The reply message is:
FIG 9 YDLIDAR TG SERIES DEVICE INFORMATION
00
A5
5A
14
00
00
04
‥‥
Start sign
Length
Mode
Type code
Content
FIG 7 ANGLE DATA STRUCTURE
SCHEMATIC
Ang_q2[14:7]
C
Ang_q2[6:0]
LSB
MSB
FIG 8 CS XOR SEQUENCE

Copyright 2019 EAI All Rights Reserved 7 / 11
According to the protocol resolution: response length = 0x00000014, answer mode = 0x0, type
code = 0x04.
That is, the number of response content bytes is 20. The response is a single response and the
type code is 04. This type of response content satisfies the following data structure:
FIG 10 YDLIDAR TG SERIESDEVICE INFORMATION RESPONSE CONTENT DATA STRUCTURE
➢Model number:One byte device model, such as the TG15 is 100, the TG30 is 101
➢and the TG50 is 102.
➢Firmware Version:2 bytes. The low byte is the major version number, and the high byte is the
minor version number.
➢Hardware version:1 byte for hardware version.
➢Serial number:16 bytes, the only factory serial number.
3.4 Health Status [A5 91]
When an external device sends a health status command (A5 91) to TG Series, TG Series will
give back the status code of the device. The reply message is:
FIG 11 SCHEMATIC DIAGRAM OF YDLIDAR TG SERIES LIDAR EQUIPMENT HEALTH STATUS MESSAGE
According to the protocol resolution: response length = 0x00000003, answer mode = 0x0, type
code = 0x06.
That is, the number of response content bytes is 3. This response is a single response and the
type code is 06. The type of reply content satisfies the following data structure:
FIG 12 SCHEMATIC DIAGRAM OF DATA STRUCTURE OF HEALTH STATUS RESPONSE CONTENT OF YDLIDAR TG
SERIES EQUIPMENT
➢Status code: 1 byte, 0x0 means the device is running normally, 0x1 means the device is running
warning, 0x2 means the device is running incorrectly.
➢Error code: 2 bytes, when there is a warning or error state, the specific error code will
➢be recorded in the field 0x00 means that the device runs without any error.
00
A5
5A
03
00
00
06
‥‥
Start sign
Length
Mode
Type Code
Content
Byte offset
0
1
2
Status code
Erroe code

Copyright 2019 EAI All Rights Reserved 8 / 11
3.5 Zero Angle Deviation [A5 93]
When an external device sends the acquisition device zero Angle offset command (A5 93) to
the TG Series, the TG Series will feedback the zero Angle offset value. The reply message is:
FIG 13 SCHEMATIC DIAGRAM OF YDLIDAR TG SERIES LIDAR ZERO ANGLE OFFSET MESSAGE
According to the protocol resolution: response length = 0x00000004, answer mode = 0x0, type
code = 0x04.
That is, the number of response content bytes is 4. This response is a single response and the
type code is 04.
➢Zero Angle Offset: 4 bytes of reply content divided by 4, in degrees.
3.6 Scan Frequency Setting [A5 09/0A/0B/0C]
TG Series provides multiple command interfaces for scanning frequency settings to increase or
decrease the system scan frequency.
CHART 5 SCAN FREQUENCY SETTING COMMAND DESCRIPTION
Commands
Description
A509
Increase the current scan frequency of 0.1Hz
A50A
Reduce the current scan frequency of 0.1Hz
A50B
Increase the current scan frequency of 1Hz
A50C
Reduce the current scan frequency of 1Hz
The above commands are the same type of commands and have the same message structure.
The scan frequency setting command has the following message structure:
FIG 14 YDLIDAR TG SERIES SCAN FREQUENCY SETTING MESSAGE
According to the protocol resolution: response length = 0x00000004, answer mode = 0x0, type
code = 0x04.
That is, the number of response content bytes is 4; this response is a single response, and the
type code is 04. The response content represents the currently set scanning frequency (Unit: Hz), and
its solution formula is:
F =
00
A5
5A
04
00
00
04
‥‥
Start sign
Length
Mode
Type Code
Content
00
A5
5A
04
00
00
04
‥‥
Start sign
Length
Mode
Type code
Content

Copyright 2019 EAI All Rights Reserved 9 / 11
Among them, AnswerData is converted to decimal data for response content (small-endian
mode) in Hertz (Hz)
3.7 Scan Frequency Acquisition [A5 0D]
This command is used to get the scan frequency (note that it is not a real-time frequency). The
message structure and response content are consistent with the scan frequency setting command. The
user can refer to the scan frequency setting [A5 09/0A/0B/0C]. This section does not describe it.
3.8 Power-down Protection Switching [A5 D9]
If the lidar power supply and external equipment is not a shared power supply system, please
turn on the power-down protection mode to protect the lidar.
Under this model, the scan command needs to be sent continuously and the transmission
interval should be less than 3s. If the command is sent interrupted or the transmission interval is too
long, the system will judge that the control terminal has been powered down, which will trigger the
power failure protection and stop the lidar. This command is a switch command. The message of the
command is as follows:
FIG 15 YDLIDARTGSERIESPOWER-DOWNPROTECTIONMESSAGE
According to the protocol resolution: response length = 0x00000001, answer mode = 0x0, type
code = 0x04.
That is, the number of response content bytes is 1. This response is a single response and the
type code is 04.
The response content of the command corresponds to the power-on protection mode being
turned on and off, 00 means that the power-down protection is enabled, and 01 means that the
power-down protection is turned off.
Note: In the power-down protection mode, the message structure of the scan command changes slightly. Only
when the scan command is sent for the first time in the stop state, there will be a complete message
structure. There is no start flag in the subsequent scan command. The response length, response mode, and
type code are only the response content.
3.9 Restart Command [A5 80]
When an external device sends a Get Device command (A5 80) to TG Series, TG Series enters a
soft reboot and the system restarts. This command does not answer.
00
A5
5A
01
00
00
04
00/01
Start sign
Length
Mode
Type code
Content

Copyright 2019 EAI All Rights Reserved 10 / 11
3.10 Motor Speed Control
The TG Series integrates the system's speed control into the system's command interface, not
the hardware interface. The user can change the speed of the motor by adjusting the scan frequency.
See the section on Scan Frequency Setting [A5 09/0A/0B/0C] for details. This section does not
elaborate.
4ATTENTION
When interacting with the TG Series command, other than stopping the scan command (A5 65),
other commands cannot be interacted in the scan mode. This can easily result in packet parsing
errors.

Copyright 2019 EAI All Rights Reserved 11 / 11
5REVISE
Date
Version
Content
2019-05-26
1.0
Compose a first draft
2020-01-15
1.1
Modify the distance solution formula as SI, the protocol and the page
number information
2020-06-09
1.2
Add command of read zero Angle offset
2021-06-02
1.3
Delete motor rotation direction setting and constant frequency setting
This manual suits for next models
4
Table of contents
Other YDLIDAR Accessories manuals