This reference application demonstrates how to test perception and controls in a closed-loop and run them on Speedgoat real-time target machines. Both systems are tested safely with virtual vehicle simulation. The whole scene is visualized in the Unreal Engine, generating synthetic camera images for the lane detection algorithm. This visualization allows us to verify the controller in a realistic and interactive environment, perform design iterations quickly, and log data for detailed analysis.
The reference application is based on the Highway Lane Following MATLAB® example. While the original example is intended for desktop simulation, we have adapted it for real-time testing, therefore, splitting the application into the following four parts: The vehicle dynamics model, the lane detection algorithm, the lane following controller, and the visualization. The lane detection algorithm supports code generation and is deployed to a Speedgoat Performance real-time target machine alongside the vehicle dynamics model. We call this part the HIL-model (Hardware-in-the-Loop). The CPU-based vision algorithm achieves 10fps on a Speedgoat Performance real-time target machine, the same rate used in the original example, which is sufficient to validate the interaction of perception and controls. If the goal is to achieve higher frame rates at a later stage (e.g., 60fps), consider using an FPGA implementation.