YDLIDAR G4 DEVELOPMENT MANUAL Doc#:01.13.000008 文档编码:01.13.
CONTENTS Working Mechanism ......................................................................................................................... 2 System workflow ........................................................................................................................... 2 System Communication .................................................................................................................... 3 Communication mechanism .......................................................
WORKING MECHANISM The YDLIDAR G4 (hereafter referred to as G4) system has 3 working modes: idle mode, scan mode, stop mode. Idle mode: When G4 is powered on, the default mode is idle mode. In idle mode, the G4's ranging unit does not work and the laser is not lit. Scan mode: When G4 is in scanning mode, the ranging unit turns on the laser. When the G4 starts to work, it continuously samples the external environment and outputs it in real time after background processing.
SYSTEM COMMUNICATION Communication mechanism G4 communicates commands and data with external devices through the serial port. When an external device sends a system command to G4, G4 resolves the system command and returns a corresponding reply message. According to the command content, G4 switches the corresponding working status. According to the content of the message, the external system can parse the message and obtain the response data.
0xD0 Ranging frequency setting - 0xD1 Get the current ranging frequency - 0x40 Soft restart - Single response Single response No response 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.
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.
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) Sampling data The system test sampling data is the distance data of the sampling point. Zero resolution: The zero-bit data is in a zero-bit packet with LSN = 1, that is, the number of Si is 1, and S1 = zerodistance data. FSA = LSA = zero angle data. For the analysis of the specific values of distance and angle, see the analysis of distance and angle.
𝐴𝑛𝑔𝑙𝑒𝐿𝑆𝐴 = 243.47° + AngCorrect 𝐿𝑆𝑁 = 243.47° − 7.8374° = 235.6326° Therefore 𝑑𝑖𝑓𝑓(𝐴𝑛𝑔𝑙𝑒) = 18.6148°,and according to this, the angle data of each sample point in the data packet of this frame can be obtained. Check code parsing: The check code uses a two-byte exclusive OR to verify the current data packet. It does not participate in XOR operations itself, and the XOR order is not strictly in byte order, as shown in the XOR order.
FIG 9 YDLIDAR G4 DEVICE INFORMATION RESPONSE CONTENT DATA STRUCTURE DIAGRAM Model number:One byte device model, such as the G4 model code is 04. 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, representing the hardware version. Serial number:16 bytes, the only factory serial number.
That is, the number of response content bytes is 1. This response is a single response and the type code is 04. The command response is fixed at 0x01, indicating that the system is enabled for a lowpower state. G4 defaults to low power consumption. Low-power mode shutdown [A5 02] When an external device sends a low-power mode shutdown command (A5 02) to G4, G4 does not automatically enter a low-power state in idle mode (in standby: the motor runs and the ranging unit does not lose power).
0xA509 Increase the current scan frequency of 0.1Hz 0xA50A Reduce the current scan frequency of 0.1Hz 0xA50B Increase the current scan frequency of 1Hz 0xA50C Reduce the current scan frequency of 1Hz The above commands are the same type of commands and have the same message structure.
That is, the number of response content bytes is 1. This response is a single response and the type code is 04. The command response is fixed to 0x01, indicating that the system is enabled to have a constant frequency. Constant frequency off [A5 0F] This command is used to shut down the system constant frequency. After the radar is turned off, the lidar does not perform automatic speed adjustment in the scanning mode.
Ranging frequency acquisition [A5 D1] This command is used to obtain the current ranging frequency of the system. The message structure and response content of the command are consistent with the ranging frequency setting. The user can refer to the section on setting the ranging frequency. This section does not elaborate. Restart command [A5 40] When an external device sends a Get Device command (A5 40) to G4, G4 enters a soft reboot and the system restarts. This command does not answer.