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: 4
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: 4
Joined: Sat Apr 15, 2023 5:18 am

Re: Counter for invalidate laps in a session

Postby kristap on Sun Jul 21, 2024 8:59 am

Thanks - hadn't even heard of the flip_flop function much less tried it.

Have you considered or tried counting events within a single lap?
kristap
 
Posts: 11
Joined: Thu Nov 10, 2016 2:43 pm

Re: Counter for invalidate laps in a session

Postby buzzard73 on Mon Aug 05, 2024 5:23 am

kristap wrote:Thanks - hadn't even heard of the flip_flop function much less tried it.

Have you considered or tried counting events within a single lap?


The integrate function (I believe) does this, as it adds 1 each time an event occur, and the flip-flop resets the event as it would remain true and only count once, if that's what you mean.
buzzard73
 
Posts: 4
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 2 guests