Results 1 to 3 of 3

Thread: Errors loading Tesla telemetry files

  1. #1
    Potential Tuner
    Join Date
    Oct 2022
    Posts
    2

    Question Errors loading Tesla telemetry files

    I'm trying out RaceRender to see if I can create an overlay for high performance lapping I'm doing with my Tesla Model 3 Performance. The M3P, when in Track Mode, automatically records telemetry to the dashcam USB stick.

    However, whenever I try to load the telemetry in RaceRender, it appears to succeed but the results aren't correct. Certain laps are missing entirely or partially.

    If I look at the diagnostics logs, I see lots of output like this:

    Code:
    2022-10-26 18:09:25,"2 duplicate timestamps detected (73720 total rows)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23730 timestamp (31.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23731 timestamp (48.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23732 timestamp (65.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23733 timestamp (81.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23734 timestamp (99.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23735 timestamp (131.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23736 timestamp (148.00) is before previous (132815.00)"
    2022-10-26 18:09:25,"Fixing erroneous timing data: Row 23737 timestamp (165.00) is before previous (132815.00)
    There are thousands of lines like that.

    Looking in the telemetry CSV file, row 23730 is the start of lap 4 (one of the missing laps). The previous timestamp it's complaining about (132815) is the last timestamp of lap 3. So it seems that RaceRender is somehow unable to determine that row 23730 is a new lap, even though it very clearly says so. For the life of me, I can't figure out what's wrong with the CSV file, it all looks correct to me. I even tried filtering out fields I didn't need and reformatting it making sure all values were quoted, but the issue persists.

    Every single telemetry file my Tesla created has similar issues. Sometimes worse, sometimes better. I was considering buying RaceRender if I like it, and it would certainly suit my needs, but if this can't be fixed that's an obvious dealbreaker.

    You can download the CSV in question here: https://ufile.io/xtmhjshu (it was too large to attach).

    RaceRender is the latest version, 3.7.1.0. OS is Windows 11 21H2. Let me know if you need any more details.

  2. #2
    Advanced Tuner
    Join Date
    Apr 2018
    Posts
    296
    RaceRender needs an ever increasing "Time" column. It doesn't necessarily need to be named "Time", but it needs to be an absolute value with respect to time. It looks like the "Elapsed Time" column resets at the start of each lap.

    Fortunately! With a [somewhat complicated] formula, you can easily create a Time column using Google Sheets (or your editor of choice). Insert a column to the right of the Elapsed Time column. Then enter Time in the first cell. Then enter the formula below in the second cell:

    Code:
    Lap,Elapsed Time (ms),Time
    0,33,=SUM(SUMIF($C1,">0",$C1),$B2)-SUMIFS($B1,$B1,">=0",$B1,"<"&$B2)
    0,50,=SUM(SUMIF($C2,">0",$C2),$B3)-SUMIFS($B2,$B2,">=0",$B2,"<"&$B3)
    0,73,=SUM(SUMIF($C3,">0",$C3),$B4)-SUMIFS($B3,$B3,">=0",$B3,"<"&$B4)
    This formula adds the previous Time if it exists to the Elapsed Time for the lap. It then subtracts the previous elapsed time if it exists and it's less than the current elapsed time (i.e. it won't subtract across a lap boundary).

    If you then copy the second cell (C2), you can select C2, hold shift, and scroll all the way to the last row, and right-click > Paste special > Formula only. And after your computer churns on it for a bit, you should magically get an ever increasing Time column. Then Download as a CSV and import the file into RaceRender. I see a nice track map with an out lap, an in lap, and 10 laps in between.

  3. #3
    Potential Tuner
    Join Date
    Oct 2022
    Posts
    2
    Thanks, I actually figured this out myself yesterday but I hadn't had time yet to update this thread.

    I ended up writing a PowerShell script that can fix the files:

    Code:
    param(
        [Parameter(Mandatory=$true, Position=0, ParameterSetName="Path", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [ValidateNotNullOrEmpty()]
        [SupportsWildcards()]
        [string[]] $Path,
        [Parameter(Mandatory=$true, ParameterSetName="LiteralPath", ValueFromPipelineByPropertyName=$true)]
        [Alias("PSPath")]
        [ValidateNotNullOrEmpty()]
        [string[]] $LiteralPath,
        [Parameter(Position=1)][string]$OutputPath,
        [Parameter()][switch]$FixBrakePressure
    )
    begin {
        if ($OutputPath -and -not (Test-Path $OutputPath -PathType Container)) {
            throw "'$OutputPath' is not a directory."
        }
    }
    process {
        if ($Path) {
            $inputs = Get-Item -Path $Path
        } else {
            $inputs = Get-Item -LiteralPath $LiteralPath
        }
        
        foreach ($file in $inputs)
        {
            $output = $OutputPath
            if (-not $output) {
                $output = $file.DirectoryName
            }
    
            $output = Join-Path $output "$($file.BaseName).fixed.csv"
            $prevLapTime = 0
            $currentLap = 0
            Write-Verbose "Processing $($file.Name)..."
            Import-Csv $file | ForEach-Object {
                $lap = $_.Lap
                $lapTime = $_.'Elapsed Time (ms)'
                if ($lap -ne $currentLap) {
                    $prevLapTime = $totalTime
                    $currentLap = $lap
                }
    
                $totalTime = $prevLapTime + $lapTime
                $_.'Elapsed Time (ms)' = $totalTime
                $_ | Add-Member -MemberType NoteProperty -Name "Lap Time (ms)" -Value $lapTime
    
                if ($FixBrakePressure -and $_.'Brake Pressure (bar)' -lt 0) {
                    $_.'Brake Pressure (bar)' = 0
                }
    
                $_
            } | Export-Csv $output
        }
    }
    Copy/paste the above code into a file called "Fix-TeslaTelemetry.ps1", and then you can run it from a PowerShell console using "./Fix-TeslaTelemetry.ps1 path_to_telemetry_file.csv". It can also optionally correct negative brake pressure values (my files had some values like that, which caused the brake pressure gauge to look weird), and it can process multiple files at once using wildcards.

    It should work with both Windows PowerShell and PowerShell (Core), though I've only tested it using the latter.

    Hopefully this will be useful for other people hitting this issue.
    Last edited by Sven3000; 10-28-2022 at 01:16 PM.