Tyre Wear Estimate
 
Notifications
Clear all

Tyre Wear Estimate

1 Posts
1 Users
0 Reactions
21 Views
(@sean-m)
New Member
Joined: 3 hours ago
Posts: 1
Topic starter  

Good evening all, below is my first attempt at some JS code for use in your templates.

This code below will give you a percentage readout of which ever tyre it is set up for, based on the last 3 stints. It will use a default value of .25% wear per lap for the first stint (can change this value if you know roughly what your car/track combo is), after that it uses the average of up to last 3 real stints to work out the average tyre wear per lap. It then uses this to display an estimated current tyre state.

It also accounts for if you opt not to change the tyre in the stop and continues to give accurate data

I am  also about to post some code that will give you a 5 lap average for yourself, and utilising the Romainrob plugin can be modified to get 5 lap averages for the entire field. so look out for that

Enjoy, 

 

//created by SeanM 08/11/24
// Only one tyre currently Front Left(4 copies on different text boxes to get all 4 tyres)
// replace all $prop('TyreWearFrontLeft') and $prop('GameRawData.Telemetry.PitSvFlags')&1<<0)!=0 for other tyres.

	// Front Right
		//$prop('TyreWearFrontRight')
		//$prop('GameRawData.Telemetry.PitSvFlags')&1<<1)!=0
	// Rear Left
		//$prop('TyreWearRearLeft')
		//$prop('GameRawData.Telemetry.PitSvFlags')&1<<2)!=0
	// Rear Right
		//$prop('TyreWearRearRight')
		//$prop('GameRawData.Telemetry.PitSvFlags')&1<<3)!=0

// Type wear estimate utalisiing upto 3 stints
// Allows for chainging tyres and not changing tyres


if (root.T1 == null)
{
	root.WearChange = 0 // tyre wear memory
	root.T1 = 0 //Tyre wear slot 1 Memory
	root.T2 = 0 //Tyre wear slot 2 Memory
	root.T3 = 0 //Tyre wear slot 2 Memory
	root.Distro = 1 // Indicates what memory slot the next wear value goes
	root.Tf = 100 // Formuated wear value
	root.Tpl = 0 // Average wear per Lap over 3 Stints
	root.StintCount = 0 //Stint count 1-3
	root.StintLength = 0 // length of current Stint
	root.MemLap = 0 // lap memory to enable update at start finish
	
}

var Default = 0.25 // default tyre wear for first stint. if you know from another session what the tyre wear is roughly change this value to get a representive indication on stint 1

if (($prop('IsInPit') == 1) && (root.WearChange != $prop('TyreWearFrontLeft'))) //checks if you are in the pit AND tyre wear has changed
{
	if (root.WearChange == 0) // Starting session or starting dash sets default
	{
		root.WearChange = $prop('TyreWearFrontLeft')
		root.MemLap = $prop('CurrentLap')
		root.Tpl = Default
	}
		else if (root.Distro == 1) // saves tyre wear in slot 1
		{
			root.Distro = 2
			root.WearChange = $prop('TyreWearFrontLeft')
			root.T1 = (100-$prop('TyreWearFrontLeft')) removed link  // finds wear per lap for that Stint
			root.Tpl = ((root.T1 + root.T2 + root.T3) removed link ) // finds average wear for session over maxium last 3 Stints
			root.StintLength = 0
			if (($prop('GameRawData.Telemetry.PitSvFlags')&1<<0)!=0) // if the tyre is changed reset tyre wear to 100
			{
			root.Tf = 100
			}
			else // if tyre isnt changed update tyre to real value
			{
			root.Tf = $prop('TyreWearFrontLeft')
			}
		}
		else if (root.Distro == 2) // repeat for slot 2
		{
			root.Distro = 3
			root.WearChange = $prop('TyreWearFrontLeft')
			root.T2 = (100-$prop('TyreWearFrontLeft')) removed link 
			root.Tpl = ((root.T1 + root.T2 + root.T3) removed link )
			root.StintLength = 0
			if (($prop('GameRawData.Telemetry.PitSvFlags')&1<<0)!=0)
			{
			root.Tf = 100
			}
			else
			{
			root.Tf = $prop('TyreWearFrontLeft')
			}
		}
		else if (root.Distro == 3) // repeat for slot 3
		{
			root.Distro = 1
			root.WearChange = $prop('TyreWearFrontLeft')
			root.T3 = (100-$prop('TyreWearFrontLeft')) removed link 
			root.Tpl = ((root.T1 + root.T2 + root.T3) removed link )
			root.StintLength = 0
			if (($prop('GameRawData.Telemetry.PitSvFlags')&1<<0)!=0)
			{
			root.Tf = 100
			}
			else
			{
			root.Tf = $prop('TyreWearFrontLeft')
			}
		}
		
		
	if (root.StintCount < 3) // ensures only up to 3 is used for the average
	{
			root.StintCount++
	}
	else
	{
		root.StintCount = 3
	}
		
}
if (root.MemLap == $prop('CurrentLap')) 
{
	//return root.Distro
	//return root.Tpl
	return root.Tf.toFixed(2) + '%'
	//return root.T1
	//return root.StintLength
}
else if (root.MemLap < $prop('CurrentLap')) // crossing start finsih update estiamted tyre wear
{
	root.MemLap = $prop('CurrentLap')
	root.StintLength++
	root.Tf = root.Tf - root.Tpl
}
//return root.Distro
//return root.Tpl
return root.Tf.toFixed(2) + '%' // displat estimated tyre wear
//return root.T1
//return root.StintLength

 

This topic was modified 3 hours ago by Sean M

   
Quote
Share: