# Highly Curved Lane Detection Algorithms Based on Kalman Filter
## 3 Setup for Simulation in 3D Environments and Results  
The 3D lane detection environment for simulation is designed using the GAZEBO simulator. MATLAB is used for image preprocessing, lane detection algorithm, and closed-loop lane keeping control, shown in Figure 10(a). It shows the software communication in brief. Figure 10(b) shows the comprehensive connection between nodes and topics in the gazebo simulator. From the gazebo GUI, the camera sensor node gives us the image_row topic. The Matlab node receives  
Figure 11: Gazebo-MATLAB Software Communication; (a) Brief Visualization of Software Architecture, (b) RQT Graph. Figure 10: Centrifugal force when a car goes around a curve. the raw RGB image of the lane and processes the frames. Then, the Matlab node generates the heading angle and sends it using cmd_vel topic to the gazebo. In order to get the trajectory of the robot, the odom topic is used to plot the position of the vehicle. For lane detection and closed-loop lane keeping control, we used two simulated track environments using pioneer robot-vehicle as shown in Figure 12. Using this image input from the Gazebo simulator, the algorithm detects the lane and estimates the vehicle's angular velocity and linear velocity based on lane detection results and output in Matlab. Initial parameters are set according to the simulation environment. For top view transformation, parameters are set as \(H=59\), \(f=0.01\), \(\alpha=0.62\), \(\theta_{v}=0.9\), \(\theta_{h}=1.1\), and to get the binary image of the lane, the auto threshold for each channel is used. \(\textit{Thresh}_{average}=0.5804\). To assess the viability of the introduced algorithms, random noises were added with real values. We performed the experiment with noisy measurement data of the parabola equation in Matlab. Figure 12b illustrates the 3d view and map of the athletic field and Figure 12a illustrates another track environment. The plotted graph of the trajectory path is generated from the odometry data of the robot-vehicle which shows that the curve lane follows the road curve scenario, as shown in Figure 13a,b with respect to the lane tracking of environments from Figure 12a,b. Figure 12: Gazebo real-time physic engine simulation of the environments; (**a**) Normal Track Environment, (**b**) Athletic field Track. Figure 13: Plotted graph of the trajectory path of the ground vehicle; (**a**) Normal Track Environment, (**b**) Athletic field Track. The angular velocity control uses a proportional-integral-differential (PID) controller, which is a control loop feedback mechanism. In PID control, the current output is based on the feedback of the previous output, which is computed to keep the error small. The error is calculated as the difference between the desired and the measured value, which should be as small as possible. Two objectives are executed, keeping the robot driving along the centerline \(dy~{}=~{}0\) and keeping the robot heading angle, \(\theta~{}=~{}0\), as shown in Figure 14. The equation can be expressed as \(y_{center\_line}=\big{(}y_{right\_line}+y_{left\_line}\big{)}/2\); \(dy~{}=~{}y_{center\_line}-y_{center\_pixel}\) from where error term can be written as \(error~{}=~{}-(dy+l\sin\theta)\). The steering angle of the car can be estimated using a straight line detection result while also detecting the curve lanes. Figures 15 and 16 show the PID error and \(dy\) difference in pixel respectively. The steering angle is derived from the arctangent of the centerline of the vehicle. Here, co-efficient of p-term = 0.3 and co-efficient of d-term = 0.1. Figure 17 shows the steering angle in the simulation experiment in scenario one. Figure 15 shows that most of the time the error is positive. As a result, Figure 17 generates positive steering angles most of the time which means steering left. All the figures below are the result of the simulation from the map of Figure 13a. The vehicle maneuver was performed counter-clockwise. To stay in the center lane, the vehicle needs to take steering on the left.