YDLIDAR G6 Development Distance Sensor User Manual

June 9, 2024
YDLIDAR

YDLIDAR G6 Development Distance Sensor

YDLIDAR-G6-Development-Distance-Sensor-PRODACT-IMG

WORKING MECHANISM

The YDLIDAR G6(hereinafter referred to as G6) system has 4 working modes: idle mode, scan mode, stop mode, Power-down protection mode.

  • Idle mode: When G6 is powered on, the default mode is idle mode. In idle mode, the G6’s ranging unit does not work and the laser is not light.
  • Scan mode: When G6 is in scanning mode, the ranging unit turns on the laser. When the G6 starts to work, it continuously samples the external environment and outputs it in real time after background processing.
  • Stop mode: When G6 runs with an error, such as turning on the scanner, the laser is off, the motor does not rotate, etc. G6 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.

System Workflow

YDLIDAR-G6-Development-Distance-Sensor-FIG-1

SYSTEM COMMUNICATION

Communication Mechanism

G6 uses the serial port to interact with external devices for commands and data. When an external device sends a system command to G6, G6 resolves the system command and returns a corresponding reply message. According to the command content, G6 switches the corresponding working status. According to the content of the message, the external system can parse the message and obtain the response data.

YDLIDAR-G6-Development-Distance-Sensor-FIG-2

System Command

By sending relevant system commands, the external system can set the corresponding working status of G6 and obtain corresponding data. The system commands of G6 consist of two bytes. The first byte is 0xA5 and the second byte is the command content. The system commands issued by G6 are as follows

CHART 1 YDLIDAR G6 SYSTEM COMMAND

YDLIDAR-G6-Development-Distance-Sensor-FIG-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. Sustained 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 G6 SYSTEM MESSAGE DATA PROTOCOL

YDLIDAR-G6-Development-Distance-Sensor-FIG-4

  • Start sign: G6’s message sign is unified as 0xA55A.
  • Response length: The response length indicates 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 G6 RESPONSE VALUE AND MODE

YDLIDAR-G6-Development-Distance-Sensor-FIG-5

  • 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 G6 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 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, etc.

Scan Command [A5 60]
When an external device sends a scan command to G6, G6 goes into scan mode and feeds back point cloud data. The reply message is:

YDLIDAR-G6-Development-Distance-Sensor-FIG-6

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:

YDLIDAR-G6-Development-Distance-Sensor-FIG-7

CHART 4 SCAN COMMAND RESPONSE CONTENT DATA STRUCTURE DESCRIPTION

YDLIDAR-G6-Development-Distance-Sensor-FIG-8

Start bit analysis

  • When CT=1, 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; for the specific value analysis of the distance and angle, please refer to the following;

Distance analysis

  • Distance solution formula: Distance= 2
  • Among them, is sampled data. Set the sampling data as E5 6F. Since the system is in little-endian mode, the sampling point S = 0x6FE5 is substituted into the Distance solution formula to obtain the Distance=14322.50mm.

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. There are two levels of angle analysis: first-level analysis and second-level analysis. The first-level analysis obtains the initial value of the angle, and the second-level analysis corrects the initial value of the angle. The specific process is as follows:

First-level analysis

  • Starting angle solution formula: AngleFSA = Rshiftbit(FSA,1)64
  • End angle solution formula: AngleLSA =Rshiftbit(LSA,1)64

Intermediate angle solution formula

  • =diff(Angle)LSN−1∗( − 1 )+ ( = 2,3,…, − 1)
  • ℎ(,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.

Second-level analysis

  • Angle correction formula: = + AngCorrect (=1,2,…,)
  • Among them, AngCorrect is the angle correction value, and its calculation formula is as follows, tand−1 is the inverse trigonometric function, and the angle value is returned:
  • IF Distance==0 AngCorrect=0
  • ELSE AngCorrect = tand−1(21.8∗155.3−Distance155.3∗Distance)
  • Assuming that the 4th to 8th bytes in the data packet are 28 E5 6F BD 79, so LSN = 0x28 = 40(dec), FSA = 0x6FE5, LSA = 0x79BD, and the first-level solution formula is brought into:
  • =223.78°, =243.47°, ()=19.69°
  • = 19.69°39 ∗(−1)+223.78° (=2,3,…,39)
  • Assuming that in this frame of data, Distance1 = 1000, Distance=8000, and the second-level calculation formula is brought into it, we get:
  • AngCorrect1 = − 6.7622° ,AngCorrect = −7.8374°,so:
  • = 1+ AngCorrect1 = 217.0178°
  • = + AngCorrect = 235.6326°
  • In the same way, (=2,3,…,−1) can be obtained in turn.

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= 1(Ci) =1,2,…,end
  • XOR1 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.

Stop Command [A5 65]

When the system is in the scan status, G6 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.

Device Information [A5 90]
When an external device sends a Get Device Information command to (A5 90), G6 will feedback the device’s model, firmware version, and hardware version, and the device’s factory serial number. The reply message is

YDLIDAR-G6-Development-Distance-Sensor-FIG-19

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:YDLIDAR-G6-Development-Distance-Sensor-
FIG-20

  • Model number: One-byte device model, such as the model code of G6 is 13;
  • 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.

Health Status [A5 92]

  • When an external device sends a health status command (A5 92) to G6, G6 will give back the status code of the device. The reply message is:

YDLIDAR-G6-Development-Distance-Sensor-FIG-21

ccording 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:

  • Status code: 1 byte, each bit of this byte corresponds to the health information of different modules, details as follows:

CHART 5 HEALTH STATUS CODE BIT DESCRIPTION

YDLIDAR-G6-Development-Distance-Sensor-FIG-23

Error code: 2 bytes, when there is a warning or error state, error code will output the abnormal information of the corresponding module.

Note: When obtaining health information, users only need to pay attention to the status code, not the error code.

Scan Frequency Setting [A5 09/0A/0B/0C]

  • G6 provides multiple command interfaces for scanning frequency settings to increase or decrease the system scan frequency.

CHART 6 SCAN FREQUENCY SETTING COMMAND DESCRIPTION

YDLIDAR-G6-Development-Distance-Sensor-FIG-24

  • 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

YDLIDAR-G6-Development-Distance-Sensor-FIG-25

  • 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:
  • Among them, AnswerData is converted to decimal data for response content (small-endian mode) in Hertz (Hz).

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 users can refer to the scan frequency setting [A5 09/0A/0B/0C]. This section does not describe it.

Ranging Frequency Acquisition [A5 D1]

  • This command is used to obtain the ranging frequency of the system. The message structure and response content of this command are as follows:

YDLIDAR-G6-Development-Distance-Sensor-FIG-26

  • According to the protocol analysis: response length = 0x00000001, response mode = 0x0, type code = 0x04.
  • That is, the number of bytes in the response content is 1; this response is a single response, and the type code is 04. The response content of this command corresponds to the system ranging frequency, as follows:

CHART 7 RANGING FREQUENCY SETTING RESPONSE CONTENT DESCRIPTION

YDLIDAR-G6-Development-Distance-Sensor-FIG-27

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:

YDLIDAR-G6-Development-Distance-Sensor-FIG-28

  • 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.

Restart Command [A5 40]

  • When an external device sends a restart device command (A5 40) to G6, G6 enters a soft reboot and the system restarts. This command does not answer.

Motor Speed Control

  • The G6 integrates the system’s speed control into the system’s command interface, not the hardware interface. The users 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.

ATTENTION

  • During command interaction with G6, Except for the stop command (A5 65), other commands cannot be interacted in the scan mode, which may easily lead to message parsing errors.

REVISE

YDLIDAR-G6-Development-Distance-Sensor-FIG-29

www.ydlidar.com

Read User Manual Online (PDF format)

Loading......

Download This Manual (PDF format)

Download this manual  >>

YDLIDAR User Manuals

Related Manuals