The online racing simulator
Searching in All forums
(8 results)
papalotis
S3 licensed
For anyone interested in more details you can find the thesis this project was part of here

https://drive.google.com/file/d/1SIrpjD05K56_k1y09Y9g2JjjhPEWIHED/view?usp=drivesdk

As far as publishing the code, I have nothing against that in principle, I just have to find some time to clean it up so that it can be used by other people. I'll probably end up putting everything in a container and call it a day 😉
I Trained a Neural Network to Drive Formula Student Tracks in LFS
papalotis
S3 licensed
Hey everyone,

Recently, I was involved in a research project involving autonomous driving at my uni. My task was to develop a vehicle control algorithm. I decided to use LFS as the basis for my testing, and now that the project is done, I thought the people in this forum might be interested.

My idea for the project was to use a neural network and train it on my driving data to get it to drive around Formula Student tracks. In case you aren’t aware, Formula Student has had a driverless category since 2017. One of the reasons I picked LFS as my sim was that it already had a Formula Student vehicle, as well as flat areas and cones, so the work to adapt it for my use case was smaller than for other sims.

In order to gather data, I created a tool that can convert hand-drawn tracks to lyt files, which I could then use in LFS. In the beginning, the tracks were simple, and over time I created tracks that contained corner complexes, which proved to be problematic during the evaluation phase. Overall, I created around 20 tracks on which I gathered data. I did 2-3 laps on each track. You can find a short demo of the creation process in this link:





I gathered the data using a mouse for steering, throttle, and brake, as I don’t have a sim setup. I also limited the performance of the vehicle by applying a 50% air restrictor to the engine and only using first gear. My project was a proof of concept, so I didn’t want to overcomplicate things by using multiple gears.

During driving, my program gets data from LFS using OutSim and InSim and sends the driving commands using vJoy. The computation takes around 5ms, so the driving can happen at the fastest rate LFS currently allows—100Hz (until the 1000Hz physics engine arrives).

As for driving performance, I’m very satisfied with the current state of the project. Of course, the main limitation of the method I used is that the AI will only ever be as fast as I am. If I ever come back to this project, I’d like to explore other methods, such as reinforcement learning, to further improve performance.

Here is a video of the final result:

Create a track from photo (WIP)
papalotis
S3 licensed
I am working on a small tool that will create a LYT file given an image of a track (pencil trace). This is one of my first experiments. You are more than welcome to try it, my PB is 1:16.89 with the FBM on default setup with 25% fuel (although I am driving with a mouse, so there is lots of room for improvement Wink ). If you want you can also reply with a layout that you want me to try. All I need apart from the picture, is the start point, the direction at the start and the width of the track at its narrowest point (to extract the scale of the track).
LYT revision 252 in W patch
papalotis
S3 licensed
When I create a layout using the W patch and I notice that the revision is set to 252. The official lyt documentation says that a file should not be read if the revision is set > 251. However the documentation is valid for version 0.6H. Has something changed in the lyt format. Is the change related to mods or is it more general? Are the changes documented somewhere? Can I assume that my parser that works for revision 251 will mostly work for revision 252?

Thanks in advance Smile
papalotis
S3 licensed
thank you so much this works exactly as I wanted.

in case anyone wants a shortcut here is a python implementation

def world_to_local(
world_vector: np.ndarray, pitch: float, roll: float, yaw: float
) -> np.ndarray:
"""
Function to transform world_vector to local_vector using the Euler angles
and 3D affine transformation. Uses the 3x3 matrix form because only rotation is
required.

Credit: https://www.lfs.net/forum/post/1961008#post1961008

Args:
world_vector (np.ndarray): The world vector to be transformed
pitch (float): The pitch of the car
roll (float): The roll of the car
yaw (float): The yaw of the car (don't forget outsim provides the heading
pointing to the right, not straight ahead)

Returns:
np.ndarray: The local transformed vector
"""

sin_roll, cos_roll = np.sin(roll), np.cos(roll)
sin_pitch, cos_pitch = np.sin(pitch), np.cos(pitch)
sin_yaw, cos_yaw = np.sin(yaw), np.cos(yaw)

local_vector = np.empty(3)

# Total rotation matrix row 1 * world_vector
local_vector[0] = (
cos_roll * cos_yaw * world_vector[0]
+ (cos_pitch * sin_yaw + sin_pitch * sin_roll * cos_yaw) * world_vector[1]
+ (sin_pitch * sin_yaw - cos_pitch * sin_roll * cos_yaw) * world_vector[2]
)

# Total rotation matrix row 2 * world_vector
local_vector[1] = (
-cos_roll * sin_yaw * world_vector[0]
+ (cos_pitch * cos_yaw - sin_pitch * sin_roll * sin_yaw) * world_vector[1]
+ (sin_pitch * cos_yaw + cos_pitch * sin_roll * sin_yaw) * world_vector[2]
)

# Total rotation matrix row 3 * world_vector
local_vector[2] = (
sin_roll * world_vector[0]
- sin_pitch * cos_roll * world_vector[1]
+ cos_pitch * cos_roll * world_vector[2]
)

return local_vector


papalotis
S3 licensed
Hey Johnners, can you post a code snippet of your world to vehicle transformation for the linear velocity and acceleration? I've been banging my head over this for way to long, thanks
papalotis
S3 licensed
Thank you so much, this is the perfect solution. To be honest I didn't expect this to be that easy, or at all possible.
[Solved] Get Wheel Spin Data Live (like Outsim)
papalotis
S3 licensed
Solved TL;DR Since Patch 0.6U9 there is an Extended OutSim format available that includes Wheel data

I am wondering if there is a way to get the wheel spin of each wheel. I know raf files have that information included, as I can see it in F1PerfView. do you know if there is a way to do this (possibly by recording raf files as the car is driven), and if not if there is a way to at least approximate it with outsim/outgauge data
Last edited by papalotis, . Reason : Solved
FGED GREDG RDFGDR GSFDG