# A Methodology to Model the Rain and Fog Effect on the Performance of Automotive LiDAR Sensors
## 4 Modeling of the Rain and Fog Effect in the Virtual LiDAR Sensor  
Figure 2 depicts the toolchain of the proposed approach and the signal processing steps to model the rain and fog effect in the virtual LiDAR sensor. As mentioned earlier in Section 1, the model is built using the standardized interfaces OSI and FMI and integrated into the virtual environment of CarMaker. This provides the ray tracing framework with a bidirectional reflectance distribution function (BRDF) that considers the direction of the incident ray \(\theta\), material surface, and color properties [20]. The LiDAR model uses the ray tracing module of CarMaker. The material properties of the simulated objects, the angle-dependent spectral reflectance \(R_{\lambda}(\theta)\), and the reflection types (including diffuse, specular, retroreflective, and transmissive) are specified in the material library of CarMaker.  
The FMU controller passes the required input configuration to the simulation framework via _osi3::LidarSensorViewConfiguration_. The simulation tool verifies the input configuration and provides the ray tracing detections via _osi3::LidarSensorView::reflection_, interface time delay \(\tau\), and relative power \(P_{rel}(t)\)[4].  
The FMU controller then calls the LiDAR model and passes the time delay \(\tau\), relative power \(P_{rel}(t)\), azimuth \(\theta_{az}\), and elevation \(\varphi_{el}\) angles of the detected ray for further processing. In the next step, the FMU controller calls the environmental condition module and passes the user-selected rain rate (\(r_{rate}\)) or visibility distance \(V\) to the rain or fog modules. In the rain/fog module, virtual rain and fog are created, through which the scan module casts the LiDAR rays according to its scan pattern (\(\theta_{az}\), \(\varphi_{el}\)), and a collision detection algorithm is applied to determine whether the transmitted ray of each scan point hits the rain or fog droplet; if the beam hits the droplet, the backscattered coefficient \(\beta_{back}\) and the extinction coefficient \(\sigma_{ext}\) based on the DSD are calculated. Furthermore, it also provides the spherical coordinates (\(R_{d}\), \(\theta_{az}\), \(\varphi_{el}\)) of the rain or fog droplets (\(R_{cell}\), \(\theta_{az}\), \(\varphi_{el}\)) that collided with the LiDAR ray. Next, the rain/fog module calls the LiDAR model and passes the rain or fog droplets data for further processing. The central component of the LiDAR model is the simulation controller. It is used as the primary interface component to provide interactions with the different components of the model, for instance, configuring the simulation pipeline, inserting ray tracing and the rain/fog module data, executing each step of simulation, and retrieving the results.  
Figure 2: Co-simulation framework of the proposed approach to model the rain and fog effect in a virtual LiDAR sensor.  
The link budget module calculates the arrival of photons over time. The detector module's task is to capture these photons' arrivals \(n[i]\) and convert them into a photocurrent signal \(l_{d}[i]\). In this work, we have implemented silicon photomultipliers (SiPM) as a detector. Next, the circuit module amplifies and converts the detector's photocurrent signal \(i_{d}[i]\) to a voltage signal \(v_{c}[i]\) processed by the ranging module. The last part of the toolchain is the ranging module, which determines the range \(R\) and intensity \(I\) of the target based on the \(v_{c}[i]\) received from the analog circuit for every reflected scan point. The LiDAR point cloud \(N_{points}\) is exported in Cartesian coordinates.