kutu / pyirsdk Goto Github PK
View Code? Open in Web Editor NEWPython 3 implementation of iRacing SDK
License: MIT License
Python 3 implementation of iRacing SDK
License: MIT License
How would I get the live speed of a specific carID?? Is it possible to get the speed of other vehicles in the session?
Hello, sorry if this is a silly question.
Python is new to me, and I'm just an engineer trying to perform some data analysis, not a programmer.
I'm attempting to extract data, such as speed, from an IBT file. According to the example in the tutorial, this should work. Reading the CarSetup, as mentioned in a previous question, works fine, but unfortunately, the speed extraction does not seem to be functioning: IndexError: list index out of range
Thank you for your great work!
Hi,
Thanks for the amazing library.
Is it possible to read the Setup information from the IBT class as in the C++ version examples?
Thanks Chris
if (1 == idk.getSessionStrVal("DriverInfo:DriverSetupName:", tstr, MAX_STR))
{
printf("CarSetupName: %s", tstr);
if(1 == idk.getSessionStrVal("DriverInfo:DriverSetupLoadTypeName:", tstr, MAX_STR))
printf(", %s", tstr);
if(1 == idk.getSessionStrVal("DriverInfo:DriverSetupIsModified:", tstr, MAX_STR))
if(atoi(tstr) == 1)
printf(", modified");
if(1 == idk.getSessionStrVal("DriverInfo:DriverSetupPassedTech:", tstr, MAX_STR))
if(atoi(tstr) == 0)
printf(", failed tech");
printf("\n");
}
// get the current setup and dump it
const char *sesStr = idk.getSessionStr();
if(sesStr)
{
//****Note, this assumes CarSetup is the last section of the session string.
const char *tstr = strstr(sesStr, "CarSetup:");
if(tstr)
{
printf(tstr);
printf("\n");
}
}
Hi,
Great work, hopefully this is still a live project.
I have checked the vars.txt file but can't seem to find anything relating to exact GPS position on track. Latitude and Longitude would help.
Regards
Would I be able to request two features for this:
Different exit code from running irsdk.py --parse output.yaml
successfully =0
unsuccessfully = 1 (if there is a error (like when Sim is not running) )
Option to output as JSON instead of YAML
ta
I'm looking for Track Usage in percent. I can see a summary of track usage "SessionTrackRubberState": "high usage" but not the percentage I can find in the Garage61 exports. Its possible this value comes from the IBT files.
I have asked on the iracing forum but the response from David was not definitive.
Any chance someone can shed light on it?
Thanks :)
I see at live sector times, but not sector attributes available apart from distances.
So, as far as I see, there are no metrics that are saving the sector times. Am I right?
Thus, all I can do is to get the lap time from ir['LapLastLapTime'] and do some estimations using the ir['lapDistPct'], ir['SplitTimeInfo']['Sectors'] and the current time which I use the value from ir['SessionTime']
Hey,
first up, thank you for this great library!
I would just like to know if it was possible to add values like hybrid regeneration / deploy or battery status since they are very important values if you drive a gtp. I am currently building my own dashboard since I have much more experience with python than with SimHub, however SimHub can read out these values.
Kind regards,
Jonas
Hi,
Sometimes (about 20% of the time) pyirsdk cannot initialize connection to the mmap file. I basically use code from example 3 and modified only loop() function to send telemetry over TCP. Some basic debug showed that mmap() is succesfull, but _header.version is 0, and _header.var_buf is "[]". I also tried to dump mmap with pyirsdk.exe but it failed to produce any file as well.
Restarting the script does not work. Only workaround is to close the sim and start it again. Sometimes I have to do this multiple times.
So it looks like the problem is iracing itself? Did you have same problem in the past?
Hi
chat_command(begin_chat) opens a new chat.
But how can I send now a chat message, for instance "clear #22 all your penalties have been cleared'
Thanks for your reply
Andi
Hi Kutu,
First of all thank you for this library!
I've been using *.bin
files and I receive all the time that tracemalloc
RuntimeWarning
every time I ir.startup(test_file=my_bin_file)
.
Looking at the source code I see that the file is opened but not closed after reading. Is this on purpose?
Lines 415 to 418 in ad72f97
I am happy to help by sending a PR fixing this if you want but maybe there's something that i am missing out.
Thanks again in advance!
I'm looking for a means to control the replay camera with Python; can it be done with this SDK implementation?
Thanks,
Mathieu
I'm unable to find the live brake bias from the telemetry. The only key I can find that contains something similar is under 'CarSetup' (which isn't in the vars.txt) - maybe I'm missing something crucial.
Hello, I found your code for obtaining iRacing telemetry data on Github. I want to DIY a dashboard and need to obtain iRacing telemetry data, but I don’t have a parsing document for iRacing shared memory. Could you please give me? Looking forward to your help
The name of these indexed variables is a bit misleading. - e.g. CarIdxBestLapNum
, CarIdxBestLapTime
, CarIdxLastLapTime
I've tried accessing via ir['CarIdxBestLapNum']
and ir['CarIdxBestLapNum', 0]
however I am always ever returned arrays of -1 or an error if the latter is tried. It is an array that is returned implying this is a list of all cars bestLapTime not a specific car index's lap time and not a specific provided car index?
Documentation currently says "Cars best lap number". "All cars best lap number" would be more precise.
Can you please update the vars.txt with that info.
I am trying to get the iracing ID of the logged in user. I assumed this would do it: PlayerCarIdx
t = ir['PlayerCarIdx']
print('players iracingid:', t)
But that only give me 0. (I joined a Official Practice session and ran it). My other code works ok.
Am I reading that description wrong?
Is this setting:
CarIdxEstTime Estimated time to reach current location on track, s
talking about the estimated time for me to reach the position of the other cars (by index), or the estimated time for them to reach that position?
Hello,
I have just installed pyirsdk and I tried to run the basics example :
import irsdk
ir = irsdk.IRSDK()
ir.startup()
print(ir['Speed'])
And I get the following error :
~/.local/lib/python3.6/site-packages/irsdk.py in startup(self, test_file, dump_to)
354 self.__is_using_test_file = True
355 else:
--> 356 self._shared_mem = mmap.mmap(0, MEMMAPFILESIZE, MEMMAPFILE, access=mmap.ACCESS_READ)
357
358 if self._shared_mem:
TypeError: an integer is required (got type str)
Do you have any idea how I can fix it ?
Hello- noticed that when a replay of a multi-class session is running, the 'CarClassShortName' property for a driver will return as None. Seems to only be the case during a replay. Just wanted to confirm whether it's because of the data made available by iRacing? Here is the usage:
https://github.com/Fuzzwah/race-info/blob/master/race-info.py#L230
I am using the pyirsdk to build a dashboard interface and I always get "100%, 100%, 100%" for the "TreadRemaining" property of each tire. I know that this info only updates after a pit (to replicate crew inspection), but even when I run a bunch of laps, go into the pits, change tires, leave the pits, and see that the Black Box has updated with the tire wear numbers, the API is still giving me the 3x 100%s. Any idea why this is happening? I am running the DW12 in a Practice session.
Thanks!
Hi kutu
Many thanks for the great SDK, it works like a charm:-)
Regarding incidents: there is only the incidents counter in the "DriverInfo" available right?
So, the way to detect the type of incident ist to store the old incident count and subtract the new.
So you get x1, x2 and x4 incidents, right?
Is there another approach to detect the incidents?
The off track can be detected reading the CarIdxTrackSurface, but how can I detect "loss of control" and "light contact with another driver" (0x0)?
Hope you can give me a direction, thanks in advance, Andi
code error when use car formula renault2.0.
Other cars no error! (I tested on skip barber and bmw. This car no problem)
sorry for my bad english.
Traceback (most recent call last):
File "C:\Users\cenanw8-1user\Downloads\datamonitorW161020.py", line 210, in
databox(ysX+0,30,d1_List,"LFshockDefl (m)",1000)
File "C:\Users\cenanw8-1user\Downloads\datamonitorW161020.py", line 120, in databox
if maxdata<i:maxdata=i
TypeError: unorderable types: float() < NoneType()
Is it possible to commit a data.bin file in the repository? This is welcome for developing while not having Iracing access.
Hi @kutu,
I think something is not right in the latest December build of the iRacing.
The IsOnTrackCar is returning True when the car is not on the track.
The rumble pitch variables (like TireRF_RumblePitch) are always returning 0.
Any idea if they changed the sdk?
Seems to be that the 'official' C code pulls in the hot tire pressures (on cars that have the sensors) and the python version does not.
Currently, when a teammate is running in a team race, ir['FuelLevel']
always returns 0
. However, as spotter/CC, I can see my teammates current fuel level.
Is it possible to get the fuel level via pyirsdk?
Hello,
It would extremely useful to be able to pass several binary files on startup, and have the sdk cycle through them whenever the freeze_var_buffer_latest()
function is called.
It would allow easier testing of behavior that depends on specific conditions.
Would you review a PR with this feature?
Hi,
This might be an iRacing issue. I don't think its my issue but it could be.
I have these two lines:
data['PlayerCarPosition'] = self.ir['PlayerCarPosition'] data['PlayerCarPowerAdjust'] = self.ir['PlayerCarPowerAdjust']
ir is an instance of irsdk.IRSDK() and data is a my structure going forward. If I print these out I get the same number.
'PlayerCarPosition': 19, 'PlayerCarPowerAdjust': 19,
I'm not sure that car position and power adjust would be the same assuming power adjust is the same as we see in the BOP.
I can't seem to get anything but "0.0" Perhaps I misunderstand what it's supposed to provide. The documentation's explanation isn't very description of how to use it. Thanks!
Hi, thanks for all the hard work.
I wanted to move from my rig to development machine for some testing, and I've ported over to IBT
to do that with an ibt file. I can't see an obvious way to advance the tick on that ibt file – am I missing something or is it just not possible?
Hi @kutu, I have one customer (only one from thousands) that is facing the issue below:
At first the problem would happen all the time, then I noticed that I was using an old version of the pyirsdk, I just update to latest version, the customer tried and 3 starts were successfully, but on the 4th the issue came back again.
11-16 19:20:38 SimRacingStudioApp.MainLoopThread.excepthook DEBUG Traceback (most recent call last):
File "backend\listeners\gameListener.py", line 464, in run
File "backend\listeners\gameListener.py", line 551, in mainloop
File "backend\listeners\iracingListener.py", line 19, in checkStatus
File "irsdk.py", line 400, in startup
File "irsdk.py", line 500, in _check_sim_status
File "http\client.py", line 475, in read
File "http\client.py", line 627, in _safe_read
http.client.IncompleteRead: IncompleteRead(0 bytes read, 35 more expected)
Any idea what could be causing this?
Thanks
Hello,
thank you rally much for this big contribution to the racing world. I want to develop a tool for my SimRacing team, but I don't have iRacing, so I'm really keen on using a data.bin file to debug the code before using it with the drivers.
My question is, how do I simulate the time in IRSDK with this mode of test_file? I mean, I can print the speed for example, just by doing ir['Speed'], but it says 0.0 all the time. How can I move forward in the recorded time?
Thank you very much.
Can you please provide an example how to use the Flags class and the SessionFlags variable?
When I print the sessionflags, I just get a big int number.
Thanks!
I would like to know if it is possible to use this project to read the ibt files (telemetry) since I imagine they are quite similar.
I can read data from the file, but it only shows me the first sample and I don't know how to move it to the next ones ...
import irsdk
ir = irsdk.IRSDK()
ir.startup(test_file='test.ibt')
Hey folks, appreciate the SDK. Its been really nice & well documented so far.
I was wondering if there is a variable (like ir['battery']) for the hybrid battery in cars for the GTP class.
I was unable to find it, maybe it exists or maybe it doesn't. (I assume its just a variable I overlooked)
Again, good work on the repo, its well made :)
The csMode class (irsdk.py, line 156) seems to remain unused in the rest of the lib.
Is there a way to tell iRacing to use one of these "auto-director" modes for a replay?
I've discovered that installing the package through the setup.py doesn't work when PyYAML is not preinstalled.
That's because setup.py uses this line:
from irsdk import VERSION
.
irsdk file is of course dependent on PyYAML.
Quick fix: move VERSION to different file like version.py and change line
from irsdk import VERSION
to
from version import VERSION
This is not a critical problem, but worth to resolve.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.