Giter Club home page Giter Club logo

ldparser's Introduction

Small tool to parse MoTec ld files.

Primarily, this parser was written to parse telemetry information of ld files written by Assetto Corsa Competizione, see also the related project 'acctelemetry'. However, the parser should work with other ld files as well. It was tested with the sample ld files that come with a MoTec Mi2 Pro installation as well as with files written by ACC.

The decoding of the ld file is solely based on reverse engineering the binary data. As of now, ldx files are not considered.

Usage

See the main function on how to use the tool.

As an example, the main function reads all ld files in a given directory and creates some plots. Invoke with

python ldparser.py /path/to/some/dir

ldparser's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ldparser's Issues

Issue using the new version

Hello,

Thank you for your hard work in creating this tool! I was using the previous version and it was working great! I tried the new version, but I'm having some errors.

In particular I'm having the following error:
In the function "decode_string" when it tries to decode the following bytes: "b'\x85\x00Copyright (C) 1997-2019 Motec Holdings P/L\nC127 V6.11M Aug 19'"

It gives the following error:
"line 415, in decode_string
return bytes.decode('ascii').strip().rstrip('\0').strip()
UnicodeDecodeError: 'ascii' codec can't decode byte
0x85 in position 0: ordinal not in range(128)"

I google a bit and I believe the error is related to the byte 0x85. It is not being able to be decode.

image

Thank you!

MoTeC i2 failsto open written .ld files

Hi guys,

I am trying to use the parser to write .ld files and read them with MoTeC.
Success to read a sample .ld file with ldData.fromfile('./tmp/test1.ld'), but once I write it back to .ld with write('./tmp/test2.ld') -process runs without python errors-, MoTeC is unable to open the file.

It can read the headers,
image

...but this message is poping up when trying to open the data:
image

I tried to downgrade to older version of MoTeC (1.1) but doesn´t work.
The written file "test2.ld" can be parsed again with ldData.fromfile('./tmp/test2.ld')m but I can't make MoTeC to open it....

Does anybody succed to open a written .ld file on MoTeC?
Thanks in advance.

Time Sync of Data

Hello,
This tool is incredibly helpful. I'm struggling with understanding how I can sync multiple channels with different sample rates. I'm thinking of a time based list that is included with each channel. Then I can use that to sync the channels with higher and lower sample rates. I may have missed it, but is there anything like this?

Work on writing the ld format (From CSV)

Are you interested in writing the format in inverse? I'm working on using this parser to write a pandas dataframe into a MoTeC file, so you can use MoTeC to analyse data off of any logger. Can the project be expanded to include this?

Found a new conversion value

Hello gotzl,

I was playing with your code and on my files for the channel RPM I noticed that the value is wrong. As an example the real value is 6000RPM but what I get is 1000RPM.

I noticed that the value is wrong by a factor of 6. When looking at the data I noticed that in this section of the code:

self.shift, self.u1, self.scale, self.dec = \ np.fromfile(f, dtype=np.int16, count=4) # .astype(np.int32)
image

the self.u1 shows the value 6.

For that reason I modified the function to this:
image

I noticed that after doing this modification my RPM channel is working and my other channels are still correct. The reason is that self.u1 is 1 for all the other channels except for the RPM channel which is 6.

What do you think? I think It makes sense to make this modification in your code.

Hope this is helpful. Best regards.

Question - Feature request on the ldChan class

Hello!

Thank you for the update on the repo.

I have a question for you. In the new version it's possible to access the data as:
l.channs[0].data or l.channs[1].data, etc.

This is not very practical because I need to check every time the name. Would it be possible for this to be a dictionary instead of a list? That way it would be more convenient to get data based on the channel name.

What I would suggest is to be able to get the data as l.channs['Beacon'].data

Let me know what you think.

UnicodeDecodeError and Datatype 5 not recognised.

Hi gotzl,

Thank you for your fantastic script. With the latest version I am getting a UnicodeDecodeError.
image

I can get around this by adding an ignore attribute to the .decode on line 407
return bytes.decode('ascii','ignore').strip().rstrip('\0').strip()

Though after this fix when parsing a .ld file from a real MoTec data logger file I get the Datatype 5 not recognised error mentioned in issue #4. As was mentioned there I fixed this error by adding 0x05 to in32 at line 352 as below (not sure if this is how to fix this error properly but this seems to work):
elif dtype_a in [0, 0x05]:
dtype = [None, np.int16, None, np.int32][dtype-1]

Hope this helps with your development.

datatyp error

Hi,

first of all - I love this piece of code!!

I do get an raised exception on Datatype not recognized. Datatype 5. It is tripping on Laptime

writing

I'm trying to write ld copy file using de ld write sketch inside the original code, i'm getting some errors.

/... parse code here

if name == 'main':

import numpy as np
import sys, os, glob
from itertools import groupby
import pandas as pd

if len(sys.argv)!=2:
    print("Usage: ldparser.py /some/path/")
    exit(1)

for f in glob.glob('%s/*.ld'%sys.argv[1]):
    print(os.path.basename(f))

    l = ldData.fromfile(f)
    print(l.head)
    print(list(map(str, l)))
    print()
    l.write("/wdt/Sample.ld")

the error is:

Traceback (most recent call last):
File "write ld.py", line 468, in
l.write("/wdt/Sample.ld")
File "write ld.py", line 118, in write
with open(f, 'wb') as f_:
FileNotFoundError: [Errno 2] No such file or directory: '/wdt/Sample.ld'

If I change the line l.write to l.write("wdt/Sample.ld") I got

Traceback (most recent call last):
File "write ld.py", line 468, in
l.write("wdt/Sample.ld")
File "write ld.py", line 119, in write
self.head.write(f_, len(self.channs))
File "write ld.py", line 294, in write
self.aux.write(f)
File "write ld.py", line 157, in write
self.venue.write(f)
File "write ld.py", line 187, in write
self.vehicle.write(f)
File "write ld.py", line 209, in write
f.write(struct.pack(ldVehicle.fmt, self.id.encode(), self.weight))
struct.error: pack expected 4 items for packing (got 2)

DiRT Rally 2.0 RDA

Hi again Gotzl,

Again I want to thank you for this fantastic script it has proven very helpful with my final year project at university. Though due to a lack of real racing I am having to turn to simulator data and as you said you only have access to data from certain simulators/loggers.

Here are 2 .ld files from DiRT Rally 2.0 captured using the tool RaceTrack Data Acquisition (RDA):
https://we.tl/t-TJuyHuUK9X

When I decode these .ld files using ldparser I don't get the datatype 5 error like with MoTec Logger files, but all of the data comes out in a very small range and the data does not match what is seen in MoTec i2 software. I did notice the scale value for each channel is extremely large where with the MoTec logger channel scale is usually (I believe always) = 1. Apologies I have not worked this one out yet, you seem to be more knowledgeable in this area. If you would like data from other sims and loggers to test please feel free to reach out.

Regards,
Josh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.