YDLIDAR GS2 DEVELOPMENT Linear Array Solid LiDAR Sensor User Manual

June 9, 2024
YDLIDAR

YDLIDAR GS2 DEVELOPMENT Linear Array Solid LiDAR Sensor

WORKING MECHANISM

Mode
The YDLIDAR GS2(hereinafter referred to as GS2) system has 3 working modes: idle mode, scan mode, stop mode.

  • Idle mode: When GS2 is powered on, the default mode is idle mode. In idle mode, the GS2’s ranging unit does not work and the laser is not light.
  • Scan mode: When GS2 is in scanning mode, the ranging unit turns on the laser. When the GS2 starts to work, it continuously samples the external environment and outputs it in real time after background processing.
  • Stop mode: When GS2 runs with an error, such as turning on the scanner, the laser is off, the motor does not rotate, etc.GS2 will automatically turn off the distance measuring unit and feedback the error code.

Measuring PrincipleYDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-
Sensor-FIG-1
GS2 is a short-range solid-state lidar with a range of 25-300mm. It is mainly composed of a line laser and a camera. After the one-line laser emits the laser light, it is captured by the camera. According to the fixed structure of the laser and the camera, combined with the principle of triangulation distance measurement, we can calculate the distance from the object to the GS2. According to the calibrated parameters of the camera, the angle value of the measured object in the lidar coordinate system can be known. As a result, we have obtained the complete measurement data of the measured object.

Point O is the origin of coordinates, the purple area is the angle of view of the right camera, and the orange area is the angle of view of the left camera.

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-2

With the mod punctuation as the coordinate origin, the front is the direction of the coordinate system 0 degree, and the angle increases clockwise. When the point cloud is output, the order of the data (S1~S160) is L1~L80, R1~R80. The Angle and distance calculated by the SDK are all represented in the coordinate system clockwise.

SYSTEM COMMUNICATION

Communication Mechanism
GS2 communicates commands and data with external devices through the serial port. When an external device sends a system command to GS2, GS2 resolves the system command and returns a corresponding reply message. According to the command content, GS2 switches the corresponding working status. Base on the content of the message, the external system can parse the message and obtain the response data.

System Command
The external system can set the corresponding working status of GS2 and send corresponding data by sending related system commands. The system commands issued by GS2 are as follows:

CHART 1 YDLIDAR GS2 SYSTEM COMMAND

System command Description Mode switching Answer mode
0×60 Obtaining the Device Address Stop mode Single response
0×61 Obtaining device parameters Stop mode Single response
0×62 Obtaining version Information Stop mode Single response
0×63 Start scanning and output point cloud data Scan mode Continuous

response
0x64| Stop device, stop scanning| Stop mode| Single response
0x67| Soft restart| /| Single response
0×68| Set the serial port baud rate| Stop mode| Single response
0×69| Set the edge mode (anti-noise mode)| Stop mode| Single 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.
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. When the system is cascaded with multiple GS2 devices, some commands will receive responses from multiple GS2 devices consecutively. 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 single response, multiple response and continuous response messages use the same data protocol. The contents of the protocol are: packet header, device address, packet type, data length, data segment and check code, and are output through the serial port hexadecimal system.

CHART 2 YDLIDAR GS2 SCHEMATIC DIAGRAM OF SYSTEM MESSAGE DATA PROTOCOL

Packet header| Device address| Packet type| Response length| Data segment| Check code
---|---|---|---|---|---
4 Bytes| 1 Byte| 1 Byte| 2 Bytes| N Bytes| 1 Byte

Byte offsetYDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-4

  • Packet header: The message packet header for GS2 is marked 0xA5A5A5A5.
  • Device address: GS2 device address, according to the number of cascades, is divided into: 0x01, 0x02, 0x04;
  • Packet type: See chart 1 for the types of system commands.
  • Response length: Represents the length of the response
  • Data segment: Different system commands respond to different data content, and their data protocols are different.
  • Check code: check code.

Note: The GS2 data communication adopts the small-endian mode, low order first.

DATA PROTOCOL

Obtain the Device Address Command
When an external device sends this command to GS2, GS2 returns a device address packet, the message is:

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-5

In cascading, if N devices (up to 3 supported) are threaded, the command returns N answers at 0x01, 0x02, 0x04, corresponding to 1-3 modules respectively.

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-6

Definition: The address of module 1 is 0x01, module 2 is 0x02, and module 3 is 0x04.

Obtain Version Information Command
When an external device sends a scan command to GS2, the GS2 returns its version information. The reply message is:

In the case of cascading, if N (maximum 3) devices are connected in series, this command will return N responses, where the address is the address of the last device.
The version number is 3 bytes length, and the SN number is 16 bytes length.

Obtain Device Parameter Command
When an external device sends this command to GS2, GS2 will return its device parameters, and the message is:

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-8 YDLIDARGS2-DEVELOPMENT-Linear-
Array -Solid-LiDAR-Sensor-FIG-9

In cascading, if N devices (up to 3 supported) are threaded, the command returns N answers, corresponding to the parameters of each device.
The K and B received by the protocol are of uint16 type, which need to be converted to float type and then divided by 10000 before being substituted into the calculation function.

  • d_compensateK0 = (float)K0/10000.0f;
  • d_compensateB0 = (float)B0/10000.0f;
  • d_compensateK1 = (float)K1/10000.0f;
  • d_compensateB1 = (float)B1/10000.0f;

Bias is of type int8, which needs to be converted to float type and divided by 10 before substituting into the calculation function.

  • bias = (float)Bias /10;

Command

Scan Command

When an external device sends a scan command to GS2, GS2 enters scan mode and continuously feeds back point cloud data. The message is: Command sent: (Send address 0x00, cascade or not, will start all devices)

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-10

Command received: (In cascading cases, this command only returns one response, and the address is the largest address, for example: No.3 device are cascaded, and the address is 0x04.)

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-11

The data segment is the point cloud data scanned by the system, which is sent to the serial port in hexadecimal to the external device according to the following data structure. The data length of the whole packet is 322 Bytes, including 2 Bytes of environmental data and 160 ranging points (S1-S160), each of which is 2 Bytes, the upper 7 bits are intensity data, and the lower 9 bits are distance data. The unit is mm.YDLIDARGS2-DEVELOPMENT-Linear-Array
-Solid-LiDAR-Sensor-FIG-12

Stop Command

When the system is in the scanning state, GS2 has been sending point cloud data to the outside world. To disable the scanning at this time, send this command to stop the scanning. After sending the stop command, the module will reply to the response command, and the system will enter the standby sleep state immediately. At this time, the ranging unit of the device is in low power consumption mode, and the laser is turned off.

  • Command sending: (send address 0x00, no matter whether cascading or not, all devices will be closed).

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-16

In the case of cascading, if N (maximum 3) devices are connected in series, this command will only return a response, where the address is the address of the last device, for example: if 3 devices are cascaded, the address is 0x04.

Set The Baud Rate Command

When the external device sends this command to GS2, the output baud rate of GS2 can be set.

  • Command sent: (sending address 0x00, only supports setting the baud rate of all cascaded devices to be the same), the message is:

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-11

Among them, the data segment is the baud rate parameter, including four baud rates (bps), respectively: 230400, 512000, 921600, 1500000 corresponding to code 0-3 (note: the three-module serial connection must be ≥921600, the default is 921600).

In the case of cascading, if N devices (maximum support 3) devices are connected in series, the command will return N responses, corresponding to the parameters of each device, and the addresses are: 0x01, 0x02, 0x04.

  • After setting the baud rate, need to soft restart the device.

Set The Edge Mode (Strong anti-jamming mode)
When the external device sends this command to the GS2, the anti-jamming mode of the GS2 can be set.

  • Command sending: (sending address, cascade address), the message is:

command reception

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-15

Address is the address of the module that needs to be configured in the cascade link. Mode=0 corresponds to the standard mode, Mode=1 corresponds to the edge mode (receptacle facing up), Mode=2 corresponds to the edge mode (receptacle facing down). In the edge mode, the fixed output of the lidar is 10HZ, and the filtering effect of ambient light will be enhanced. Mode=0XFF means reading, the lidar will return to the current mode. Lidar works in standard mode by default.

  • Set module 1: Address =0x01
  • Set module 2: Address =0x02
  • Set module 3: Address =0x04

System Reset Command
When an external device sends this command to GS2, GS2 will enter a soft restart, and the system will reset and restart.
Command sending: (sending address, can only be the exact concatenated address: 0x01/0x02/0x04)

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-16

Address is the address of the module that needs to be configured in the cascade link.

  • Reset module 1: Address =0x01
  • Reset module 2: Address =0x02
  • Reset module 3: Address =0x04

DATA ANALYSIS

CHART 3 DATA STRUCTURE DESCRIPTION

Content Name Description
K0(2B) Device parameters (uint16) The left camera angle parameter k0

coefficient (see section 3.3)
B0(2B)| Device parameters| (uint16) The left camera angle parameter k0 coefficient (see section 3.3)
K1(2B)| Device parameters| (uint16) The right camera angle parameter k1 coefficient (see section 3.3)
B1(2B)| Device parameters| (uint16) The right camera angle parameter b1 coefficient (see section 3.3)
BIAS| Device parameters| (int8) The current camera angle parameter bias coefficient (see section 3.3)
ENV(2B)| Environment data| Ambient light intensity
Si(2B)| Distance measurement data| The lower 9 bits are the distance, the upper 7 bits are the intensity value

  • Distance analysis
    Distance calculation formula: Distance = ( ≪ 8|) &0x01ff, unit is mm.
    Strength calculation: Quality = _ ≫ 1

  • Angle analysis
    The direction of laser emission is taken as the front of the sensor, the projection of the laser circle center on the PCB plane is taken as the origin of the coordinates, and the polar coordinate system is established with the normal line of the PCB plane as the 0-degree direction. Following the clockwise direction, the angle gradually increases.

To convert the original data transmitted by the Lidar to the coordinate system in the above figure, a series of calculations are required. The conversion function is as follows (for details, please refer to the SDK):

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-28 YDLIDARGS2
-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-FIG-29

Check code analysis
The check code uses single-byte accumulation to check the current data packet. The four-byte packet header and check code itself do not participate in the check operation. The check code solution formula is:

  • CheckSum = ADD1()
  • = 1,2, … ,

ADD1 is the cumulative formula, it means to accumulate the numbers from subscript 1 to end in the element.

OTA UPGRADE

Upgrade Workflow

Send Protocol

CHART 4 OTA DATA PROTOCOL FORMAT (SMALL ENDIAN)

Parameter Length (BYTE) Description
Packet_Header 4 Data packet header, fixed as A5A5A5A5
Device_Address 1 Specifies the address of the device
Pack_ID 1 Data packet ID (data type)
Data_Len 2 Data length of data segment, 0-82
--- --- ---
Data n Data, n = Data_Len
Check_Sum 1 Checksum, the checksum of the remaining bytes after the header

is removed

CHART 5 OTA UPGRADE INSTRUCTIONS

Instruction type Pack_ID Description
Start_IAP 0x0A Send this command to start IAP after power on
Running_IAP 0x0B Run IAP, transmit packets
Complete_IAP 0x0C End of IAP
ACK_IAP 0x20 IAP reply
RESET_SYSTEM 0x67 Reset and restart the module at the specified address

Start_IAP Instruction

Command sending

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-20

  • Data segment Data format:
  • Data[0~1]: The default is 0x00;
  • DATA[2~17]: It is a fixed character verification code:
  • 0x73 0x74 0x61 0x72 0x74 0x20 0x64 0x6F 0x77 0x6E 0x6C 0x6F 0x61 0x64 0x00 0x00
  • Refer to sending message
  • A5 A5 A5 A5 01 0A 12 00 00 00 73 74 61 72 74 20 64 6F 77 6E 6C 6F 61 64 00 00 C3

Command reception: Due to FLASH sector operations, the return delay is long and fluctuates between 80ms and 700ms)

Receive data format

  • Address: the module address;
  • ACK: The default is 0x20, indicating that the data packet is an acknowledgment packet; Data[0~1]: The default is 0x00;
  • Data[2]: 0x0A indicates that the response command is 0x0A;
  • Data[3]: 0x01 indicates normal reception, 0 indicates abnormal reception;
  • Reference to receive:
    A5 A5 A5 A5 01 20 04 00 00 00 0A 01 30
Running_IAP Instruction

Command sending

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-24

The firmware will be split during the upgrade, and the first two bytes of the data segment (Data) indicate the offset of this segment of data relative to the first byte of the firmware.

YDLIDARGS2-DEVELOPMENT-Linear-Array -Solid-LiDAR-Sensor-
FIG-25

  • Data[0~1]: Package_Shift = Data[0]+ Data[1]*256;
  • Data[2]~Data[17]: is a fixed string verification code:
  • 0x64 0x6F 0x77 0x6E 0x6C 0x6F 0x61 0x64 0x69 0x6E 0x67 0x00 0x00 0x00 0x00 0x00 Data[18]~Data[81]: firmware data;
  • Refer to sending message
  • A5 A5 A5 A5 01 0B 52 00 00 00 64 6F 77 6E 6C 6F 61 64 69 6E 67 00 00 00 00 00 +
    (Data[18]~Data[81]) + Check_Sum

Command reception

  • Address: i s the module address;
  • ACK: The default is 0x20, indicating that the data packet is an acknowledgment packet;

Data[0~1] : Package_Shift = Data[0]+ Data[1]*256 indicates the firmware data offset of the response. It is recommended to judge the offset as a protection mechanism when detecting the response during the upgrade process.

  • Data[2]=0x0B indicates that the response command is 0x0B;
  • Data[3]=0x01 indicates normal reception, 0 indicates abnormal reception;

Reference to receive
A5 A5 A5 A5 01 20 04 00 00 00 0B 01 31

Complete_IAP Instruction

Command sending

  • Data[0~1]: The default is 0x00;
  • Data[2]~Data[17]: It is a fixed string verification code:
    0x63 0x6F 0x6D 0x70 0x6C 0x65 0x74 0x65 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Data[18]~Data[21]: encryption flag, uint32_t type, encrypted firmware is 1, non-encrypted firmware is 0;

Refer to sending message:
A5 A5 A5 A5 01 0C 16 00 00 00 63 6F 6D 70 6C 65 74 65 00 00 00 00 00 00 00 00

  • (uint32_t encryption flag) + Check_Sum

Command reception

  • Receive data format:
  • Address: is the module address;
  • ACK: The default is 0x20, indicating that the data packet is an acknowledgment packet;
  • Data[0~1]: The default is 0x00;
  • Data[2]: 0x0C indicates that the response command is 0x0C;
  • Data[3]: 0x01 indicates normal reception, 0 indicates abnormal reception;
  • Refer to the received message:
    A5 A5 A5 A5 01 20 04 00 00 00 0C 01 32

RESET_SYSTEM Instruction
Please refer to Chapter 3.8 System Reset Command for details.

Q &A

  • Q: How to judge the reset is successful after sending the reset command? Whether delay is required?
    • A: The successful execution can be judged according to the response packet of the reset command; it is recommended to add a 500ms delay after receiving the response before performing subsequent operations.
  • Q: Module 4 receives some serial port data that does not conform to the protocol after reset, how to deal with it?
    • A: The power-on log of the module is a string of ASCII data with 4 0x3E headers, which does not affect the normal data parsing with 4 0xA5 headers, and can be ignored. Due to the physical link, the logs of No. 1 and No. 2 modules cannot be received.
  • Q: How to deal with if the upgrade process is interrupted by a power failure and restart?
    • A: Re-send the Start_IAP command to re-upgrade.
  • Q: What is the possible reason for the abnormal upgrade function in the cascade state?
    • A: Confirm whether the physical link is correct, such as whether the point cloud data of the three modules can be received;
    • Confirm that the addresses of the three modules do not conflict, and you can try to reassign the addresses;
    • Reset the module to be upgraded and then restart the try;
  • Q: Why is the read version number 0 after the cascade upgrade?
    • A: It means that the module upgrade is unsuccessful, users need to reset the module and then upgrade again.

ATTENTION

  1. During command interaction with GS2, except for the stop scan command, other commands cannot be interacted in scan mode, which may easily lead to message parsing errors.

  2. GS2 will not automatically start ranging when power on. It needs to send a start scan command to enter the scan mode. When need to stop ranging, send a stop scan command to stop scanning and enter sleep mode.

  3. Start GS2 normally, our recommended process is:
    First step:
    send the Get Device Address command to get the address of the current device and the number of cascades, and configure the address;
    Second step:
    send the get version command to get the version number;
    Third step:
    send a command to obtain device parameters to obtain the angle parameters of the device for data analysis;
    Fourth step:
    send a start scan command to obtain point cloud data.

  4. Suggestions for the design of light-transmitting materials for GS2 perspective windows:
    If the front cover perspective window is designed for GS2, it is recommended to use infrared-permeable PC as its light-transmitting material, and the light-transmitting area is required to be flat (flatness ≤0.05mm), and all areas in the plane should be transparent in the 780nm to 1000nm band. The light rate is greater than 90%.

  5. The recommended operation procedure for repeatedly switching GS2 on and off the navigation board:
    In order to reduce the power consumption of the navigation board, if GS2 needs to be powered on and off repeatedly, it is recommended to send a stop scan command (see section 3.5) before powering off, and then configure the TX and RX of the navigation board to high impedance. Then pull VCC low to turn it off. The next time the power is turned on, first pull up VCC, then configure TX and RX as normal output and input states, and then after a delay of 300ms, perform command interaction with the line laser.

  6. About the maximum waiting time after each GS2 command is sent:

    • Get address: delay 800ms, get version: delay 100ms;
    • Get parameters: delay 100ms, start scanning: delay 400ms;
    • Stop scanning: delay 100ms, set baud rate: delay 800ms;
    • Set edge mode: delay 800ms, start OTA: delay 800ms;

REVISE

Date Version Content
2019-04-24 1.0 Compose a first draft

2021-11-08

| ****

1.1

| Modify (Modify the protocol framework to merge left and right camera data; Suggestions for adding perspective window materials; Adding the baud rate

setting command)

2022-01-05| 1.2| Modify the receiving description of the command to obtain the device address, and the description of the left and right cameras
2022-01-12| 1.3| Add edge mode, supplement K, B, BIAS calculation description
2022-04-29| 1.4| Modify description of chapter 3.2: Obtain Version Information Command
2022-05-01| 1.5| Modify the address configuration method of the soft restart command


2022-05-31

| ****

1.6

| 1)  Update section 3.7

2)  Section 3.8 RESET command adds a single reply

3)  Added Chapter 5 OTA upgrade

2022-06-02| 1.6.1| 1)  Modify the OTA upgrade workflow

2)  Modify the Q&A of OTA

www.ydlidar.com

Read User Manual Online (PDF format)

Loading......

Download This Manual (PDF format)

Download this manual  >>

Related Manuals