Counter for invalidate laps in a session

Discussion and support for i2 Standard and i2 Pro applications

Counter for invalidate laps in a session

Postby buzzard73 on Mon Jul 31, 2023 3:13 am

I have a math channel 'Invalid lap' that calculates if track limits were exceeded and all I want to do is have a count of these invalidated laps for the session. In my head, this sounded like a simple operation, however I just can't find a way to increment a count by 1 when a condition is true.

The closest I got was:

integrate(derivative('Invalid lap'),'Invalid lap'==1)
where 'Invalid lap' is stat_max('One','Num Tires Off Track'==4,range_change("Outings:Laps"))

however this stopped counting when there were 2 consecutive invalid laps.

If I was writing code, I'd loop through the laps and increment a count by one, where 'invalid lap'==1 but I cannot for the life in me, find a way to do it in i2 pro, and my head is hurting!
buzzard73
 
Posts: 2
Joined: Sat Apr 15, 2023 5:18 am

Re: Counter for invalidate laps in a session

Postby buzzard73 on Wed Aug 02, 2023 5:24 am

So I've found a resolution to my issue (and it took a while)...

I created a maths channel called 'invalid lap' with the following expression:
Code: Select all
stat_max(flip_flop('Num Tires Off Track'==4,'Num Tires Off Track'<4),1,range_change("Outings:Laps"))

This will return '1' when all 4 tyres are registered outside track limits but reset to '0' at the start of the next lap, which is important for using derivative in the next part.

I then created another maths channel 'Total invalid laps' as follows:
Code: Select all
integrate(derivative('invalid lap'),'invalid lap'==1)


Using the flipflop function and stat_max, the condition is false, until it becomes true (which it remains for the remainder of the lap) and then reverts to false at the start of the next lap. This allows the nested integrate & derivative functions to work correctly.

Originally, for say... lap 9 & 10, If there were track limits violations in consecutive laps, invalid lap would become '1' for lap 9 and then remain as '1' for the duration of lap 10, before resetting for lap 11 if no further violations were received. This would be registered incorrectly (in the invalid lap channel) as a single violation and not two separate violations.

With the flipflop, the value only changes during the lap (at the point the violation takes place) and therefore registers a false to true change and not one continuous true, which didn't trigger the count.

There is one potential pitfall though - if you were to cross the start/finish line with all four wheels off the track, this would probably (to be tested) register as a single track violation over both laps and only count it once. I don't actually know how this would be perceived or punished in the rules but for the sake of practice and qualifying, it's unlikely to happen. Plus if someone wants to do this, I think the lap time penalty will be greater than any track limits violation penalty!

So there it is - I've found a way to use a counter that reports on how many times a condition was met during a session.
buzzard73
 
Posts: 2
Joined: Sat Apr 15, 2023 5:18 am


Return to i2 Data Analysis Software

Who is online

Users browsing this forum: No registered users and 6 guests