Studio 10 - LiDAR Programming
LiDAR Basics
Working Principle
LIDAR sensors use light to measure the distance between the sensor and an object or surface. More specifically, the LiDAR sensors measure distance by emitting a laser beam and measuring the time it takes for the beam to reflect off an object and return to the sensor.
LiDAR Protocol
In CG2111A Project, LiDAR communicates with the RPi using Serial over USB. The sensor's operation, such as its sampling rate, rotation speed, and scan initiation, is controlled by sending commands as bytes defined in its datasheet and protocol documentation. To simplify this process, a Python Library is provided!
Process LiDAR Output
2D LiDARs provide angle and distance measurements of the environment around the sensor. (This is known as the polar coordinates). To extract useful information from this data, you may need to convert them from polar coordinates to cartesian coordinates.
More on LiDAR Protocol
The RPLIDAR uses a non-textual binary data packet based protocol to communicate with host systems (e.g., RPi, PC)
All the packets transmitted on the interface channel share uniform packet formats.
If a data packet is sent from host systems to RPLIDARs, such a packet is called a Request.
Once an RPILIDAR receives a request, it will reply the host system with a data packet called a Response.

Based on the related request types, there are three different request/response modes:
Single Request-Single Response
Single Request-Multiple Response
Single Request-No Response
Request Packets' Format
All request packets sent by a host system share the following common format. Little endian byte order is used.

A fixed 0xA5 byte is used for each request packet, RPLIDAR uses this byte as the
identification of a new request packet. An 8-bit (1 byte) command field must follow
the start flag byte.
Request Overview
All the available requests are listed in the below table. The value should be in Command.

Response Packets' Format
All the response packets are divided into two classes: response descriptors and data responses. If the current request received by RPiLiDAR requires a response, RPiLiDAR will always send a response descriptor packet first and then send one or more data response packets based on the type of requests.


The response descriptors carry the information of the incoming data responses. All the response descriptors share a same format. Its format is shown as follows

A response descriptor uses fixed two bytes’ pattern
0xA5 0x5Afor the host system to identify the start of a response descriptor.The response descriptor is different from the data response, and it doesn't tell any information about the RPiLiDAR's error code and status, only the data reponse contains this information!
The 2 bits for Send Mode will determine whether its single response mode or multiple response mode.

Last updated