## LiDAR Basics with VLP-16

LIDAR—Light Detection and Ranging—is used to find the precise distance of objects in relation to us. Velodyne LiDAR sensors use time-of-flight methodology for doing this.

When a laser pulse is emited, its time-of-shooting and direction are registered. The laser pulse travels through air until it hits an obstacle which reflects some of the energy. The time-of-acquisition and power received are registered by sensor after recieving the portion of energy. The spherical coordinates of the obstacle is calculated using time-of-acquisition which is returned along with power received(as relectance) after each scan.

As LiDAR sensor returns reading in spherical coordinates, let's brush up with the spherical coordinate system.
___
To know more on LiDAR's history and how it works this [blog](https://news.voyage.auto/an-introduction-to-lidar-the-key-self-driving-car-sensor-a7e405590cff) by Oliver Cameron is helpful.

### Spherical Coordinate System
In a spherical coordinate system, a point is defined by a distance and two angles. To represent the two angles we use azimuth($\theta$) and polar angle($\phi$) convention. Thus a point is defined by $(\text{r}, \theta, \phi)$.



As you can see from above diagram, the azimuth angle is in X-Y plane measured from X-axis and polar angle is in Z-Y plane measured from Z axis.

From above diagram, we can get the following equations for converting a cartesian coordinate to spherical coordinates.

<math>\begin{align} r&=\sqrt{x^2 + y^2 + z^2} \\ \theta &= \arccos\frac{z}{\sqrt{x^2 + y^2 + z^2}} = \arccos\frac{z}{r} \\ \varphi &= \arctan \frac{y}{x} \end{align}</math>

We can derive cartesian coordinates from spherical coordinates using below equations.

<math>\begin{align} x&=r \, \sin\theta \, \cos\varphi \\ y&=r \, \sin\theta \, \sin\varphi \\ z&=r \, \cos\theta\end{align}</math>

___
Read [more](https://en.wikipedia.org/wiki/Spherical_coordinate_system) about Spherical coordinate system at Wikipedia.

## VLP-16 coordinate system
Velodyne VLP-16 returns reading in spherical coordinates. But there is a slight difference from the above discussed convention.

In sensor coordinate system, a point is defined by (radius $\text{r}$, elevation $\omega$, azimuth $\alpha$). Elevation angle, $\omega$ is in Z-Y plane measured from Y-axis. Azimuth angle, $\alpha$ is in X-Y plane measured from Y-axis. Below is the diagram.



Cartesian coordinates can be derived by following equations.

<math>\begin{align} x&=r \, \cos\omega \, \sin\alpha \\ y&=r \, \cos\omega \, \cos\alpha \\ z&=r \, \sin\omega\end{align}</math>

A computation is necessary to convert the spherical data from the sensor to Cartesian coordinates using above equations. This can be done using a ros package.


Above diagram shows the coordinate system of sensor mounted on a car.
___
This [manual](https://velodynelidar.com/docs/manuals/63-9243%20REV%20D%20MANUAL,USERS,VLP-16.pdf) is a good start to know more about Velodyne VLP-16.

## Data format
An unstructured point cloud is returned after each scan by sensor. Even though LiDAR returns reading in spherical coordinates, widely used coordinate system is Cartesian.

A point in point cloud is defined by it's coordinates and reflectance. Reflectance tells us the reflectivity of the surface. A zero value in reflectance denotes that the laser pulse didn't result in a measurement.

There are many formats to store and process point clouds like PCD, PCL but we can treat point cloud as a `Numpy` array. Each element of the array will have `(x,y,z,r)`. For processing point cloud we can use `Numpy`.


c001d0b30eaf4310db0ebb5ad80a9af66945f76f
ipynb
Jupyter Notebook
tutorial/LiDAR Basics  with VLP-16.ipynb
mrtpk/lidar-buster
1bb1d59d2d470af4c08350cbd912081728cd01eb
MIT
2018-09-11T05:17:48.000Z
2021-03-23T02:10:59.000Z
tutorial/LiDAR Basics  with VLP-16.ipynb
mrtpk/lidar-buster
1bb1d59d2d470af4c08350cbd912081728cd01eb
MIT
2019-03-02T11:56:58.000Z
2019-03-26T11:27:20.000Z
tutorial/LiDAR Basics  with VLP-16.ipynb
mrtpk/lidar-buster
1bb1d59d2d470af4c08350cbd912081728cd01eb
MIT
2018-09-10T06:34:38.000Z
2021-04-22T12:12:02.000Z
Qwen/Qwen-72B
1. YES
2. YES