PERRINN / project-424-unity

Simulation of the 424 in Unity using Vehicle Physics Pro
100 stars 51 forks source link

Autopilot Telemetry #76

Closed Maesla closed 2 years ago

Maesla commented 2 years ago

Autopilot telemetry

This development allows to use a csv telemetry file at the autopilot

How to use

  1. Go to the top menu bar, and select Perrin424/CSV importer
  2. Select the lap you want to import
  3. Click yes to the prompt window asking if you want to use it in the autopilot

https://user-images.githubusercontent.com/25863696/152835827-3b31af24-0281-4a52-96c8-51f196bb71dc.mp4

File format

Autopilot needs a VPReplayAsset, so we create a VPReplayAsset through the csv data. VPReplay asset needs position, rotation, and raw input, so this information must be contained into the csv The main code of this transformation can be found here: https://github.com/PERRINN/project-424-unity/blob/f16582eaf8d2ace5d6da5715af12ee06f253ebb0/Assets/Features/Telemetry%20Lap%20File/TelemetryLapToReplayAsset.cs

Autopilot

Autopilot code has needed to be refactored. Specially the part when the autopilot searches the closest frame to the current car position. This part has been completely rewritten. Now it uses an heuristic algorithm. The code guesses that the closest frame would be around the last found. This could be true because the frames are sorted as a path and we are using a kind of follow path algorithm The old algorithm is still in the project and it can be used, although it returns wrong closest frames. It will be deprecated when the autopilot is refactored

Known Issues

The main goal of this development was to completed the workflow from driving to autopilot, passing through the telemetry and the csv file. I didn't want to modify the autopilot at all, since we are planning to make a full refactor of the code. However, finally I had to modify it, as little as I could