Oct 7, 2021
How to create a Time-Of-Flight User Analysis using ZOS-API
LiDAR (Light Detection and Ranging) is a sensor technology that can help create 3D digital maps of the environment by measuring the time taken for emitted light to reflect from surrounding objects and return to a receiver. Such 3D mapping is becoming essential in the automotive industry as a key enabling technology of autonomous vehicles. Outside of the automotive industry, LiDAR is used on mobile devices, for features like augmented reality, measuring distances, and blurring backgrounds in photos and videos.
In this blog post we will show how a User Analysis can be created using the ZOS-API to measure the time-of-flight (TOF) of a LiDAR system. The analysis will read a ZRD file, extract the data and plot the time-of-flight of rays reaching the detector.
What is a User Analysis?
ZOS-API (Application Programming Interface) enables connections and customization of OpticStudio. There are 4 Program modes to connect the application program and OpticStudio, but they can be gathered into 2 main categories:
1) Full Control (Standalone and User Extensions modes), in which the user generally has full control over the lens design and user interface.
2) Limited Access (User Operands and User Analysis modes), in which the user is locked down to working with a copy of the existing lens file.
The User Analysis Mode is used to populate data for custom analysis. The displayed data is using the modern graphics provided in OpticStudio for most analyses. This mode does not allow changes to the current lens system or the user interface (i.e. in this mode only changes to a copy of the system are allowed). User analyses can be written using either C++ (COM) or C# (.NET). The User Analysis of this article is written in C#.
For more information about the User-Analysis, check the built-in Help file under The Programming Tab... About the ZOS-API...User Analysis.
Open boilerplate template
We can create a User Analysis in C#:
A Windows Explorer opens with the solution folder ‘..\Documents\Zemax\ZOS-API Projects\CSharpUserAnalysisApplication1’. Visual Studio also opens with a new solution. The solution contains a boilerplate code, a template that can be used as the basis for any User Analysis. In Visual Studio, the user analysis is then compiled as an executable. The executable is then copied to the \Zemax\ZOS-API\User Analysis folder so that OpticStudio can use it.
Open the LIDAR file
The image below shows a system representing a Flash LIDAR. A LIDAR sits at the top of the van. The van is on the road and there are 2 pedestrians and a living green wall.
The LIDAR sends a laser pulse towards the scene:
Light is scattered by the surrounding objects. Part of that light is scattered back to the LIDAR detector. For example, below, the light scattering back off from the red pedestrian reaches a pixel of the LIDAR detector.
The LIDAR records how long it takes to get the signal back; that is the time of flight. The time-of-flight is converted into a distance. Which pixel is hit indicates the direction of the incoming light.
With both values, it tells that the scattered light comes from a red pedestrian that stands at 10m from the van. OpticStudio does not measure the time but the path length of rays, so the distance between the object and the detector.
The Detector Viewer can show radiometric results on the detector, but it doesn’t show the path length of the rays from the LIDAR source back to the LIDAR detector. That’s when ZOS-API comes in handy! User analysis can be built to show the Distance to Object Data and thus reflect the Time-of-Flight information.
Reading a ZRD file using the Ray Database Viewer
The path length of rays can be read in ZRD files, which are Ray database files. The next step is to run a Ray Trace and Save Rays in a ZRD file.
Under Analyze...Ray Database viewer, the path length of the rays that hit Detector 17 can be displayed. The “Apply Filter” setting is set to H17 to filter the rays that hit Detector 17.
For example, Ray 1 Segment 8 has hit Detector 17 and the path of that ray is the sum of the paths of all segments, which is 4E4 mm, so 40m. The ray has traveled to the object and then back to the detector. The distance of the object is half that path. It is 20m.
So, the distance of objects to the detector can be found by reading the path length of each ray that hits the detector. This operation can be done automatically using the ZOS-API.
We have now covered what a User Analysis is, how to open a boilerplate template, how to open a LIDAR file, and how to read a ZRD file using the Ray Database Viewer. To learn more about how to read a ZRD file using ZOS-API, fill data arrays, plot results, create settings, save, build and move executables, run user analysis and further possibilities for a time-dependent analysis read the full Knowledgebase article here.
To try out Zemax capabilities please download a free trial here.
Principal Optical Engineer