### Access session standings and track setup changes Source: https://context7.com/kutu/pyirsdk/llms.txt Demonstrates how to iterate through session results and monitor for changes in car setup data. ```python if ir['SessionInfo']: sessions = ir['SessionInfo']['Sessions'] for session in sessions: print(f"Session: {session['SessionName']}") if 'ResultsPositions' in session and session['ResultsPositions']: for result in session['ResultsPositions'][:5]: print(f" P{result['Position']}: {result['ClassPosition']}") # Track car setup changes last_setup_tick = -1 car_setup = ir['CarSetup'] if car_setup: setup_tick = ir.get_session_info_update_by_key('CarSetup') if setup_tick != last_setup_tick: last_setup_tick = setup_tick print(f"Setup updated: {car_setup['UpdateCount']}") ``` -------------------------------- ### Implement Real-Time Telemetry Monitoring Source: https://context7.com/kutu/pyirsdk/llms.txt A complete application example demonstrating connection management, live telemetry data retrieval, and session info monitoring. ```python #!python3 import irsdk import time class State: ir_connected = False last_car_setup_tick = -1 def check_iracing(): if state.ir_connected and not (ir.is_initialized and ir.is_connected): state.ir_connected = False state.last_car_setup_tick = -1 ir.shutdown() print('Disconnected from iRacing') elif not state.ir_connected and ir.startup() and ir.is_initialized and ir.is_connected: state.ir_connected = True print('Connected to iRacing') if ir['WeekendInfo']: print(f"Track: {ir['WeekendInfo']['TrackName']}") def loop(): ir.freeze_var_buffer_latest() # Live telemetry speed_ms = ir['Speed'] speed_mph = speed_ms * 2.237 rpm = ir['RPM'] gear = ir['Gear'] fuel = ir['FuelLevel'] lap = ir['Lap'] lap_time = ir['LapCurrentLapTime'] print(f"Lap {lap} | {lap_time:.1f}s | {speed_mph:.0f} mph | " f"Gear {gear} | RPM {rpm:.0f} | Fuel {fuel:.1f}L") # Check for setup changes car_setup = ir['CarSetup'] if car_setup: tick = ir.get_session_info_update_by_key('CarSetup') if tick != state.last_car_setup_tick: state.last_car_setup_tick = tick print(f"Setup changed! Update #{car_setup['UpdateCount']}") ir.unfreeze_var_buffer_latest() if __name__ == '__main__': ir = irsdk.IRSDK() state = State() try: while True: check_iracing() if state.ir_connected: loop() time.sleep(1/60) # 60 Hz update rate except KeyboardInterrupt: print("\nExiting...") if state.ir_connected: ir.shutdown() ``` -------------------------------- ### Read Session Data with Existence Check Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/01 Introduction.md Safely read complex session data, like starting grid information, by first checking if the relevant data structure exists. This prevents errors when data is not available. ```python >>> if ir['WeekendInfo']: >>> print(ir['WeekendInfo']['WeekendOptions']['StartingGrid']) <<< '2x2 inline pole on left' ``` -------------------------------- ### GET /telemetry/player-session Source: https://github.com/kutu/pyirsdk/blob/master/vars.txt Retrieves session-specific data for the player, including race position, incident counts, and car class information. ```APIDOC ## GET /telemetry/player-session ### Description Retrieves data related to the player's current session, including race standing and incident tracking. ### Method GET ### Endpoint /telemetry/player-session ### Response #### Success Response (200) - **PlayerCarPosition** (int) - Players position in race - **PlayerCarMyIncidentCount** (int) - Players own incident count for this session - **PlayerCarClassPosition** (int) - Players class position in race - **PlayerFastRepairsUsed** (int) - Players car number of fast repairs used ``` -------------------------------- ### GET /telemetry/data Source: https://github.com/kutu/pyirsdk/blob/master/vars.txt Retrieves the current state of telemetry data points from the iRacing SDK. ```APIDOC ## GET /telemetry/data ### Description Returns the current values for various telemetry data points including vehicle status, engine metrics, and lap timing. ### Method GET ### Response #### Success Response (200) - **dpRRTireChange** (boolean) - Pitstop rr tire change request - **dpRRTireColdPress** (float) - Pitstop rr cold tire pressure adjustment, Pa - **Engine0_RPM** (float) - Engine rpm, revs/min - **FuelLevel** (float) - Liters of fuel remaining, l - **Gear** (integer) - -1=reverse, 0=neutral, 1..n=current gear - **Lap** (integer) - Laps started count - **LatAccel** (float) - Lateral acceleration (including gravity), m/s^2 - **LFtempCL** (float) - LF tire left carcass temperature, C ``` -------------------------------- ### GET /telemetry/pit-status Source: https://github.com/kutu/pyirsdk/blob/master/vars.txt Retrieves current pit service status, repair times, and tire change configurations. ```APIDOC ## GET /telemetry/pit-status ### Description Provides information regarding the player's pit stop status, including repair times and requested service parameters. ### Method GET ### Endpoint /telemetry/pit-status ### Response #### Success Response (200) - **PitstopActive** (bool) - Is the player getting pit stop service - **PitRepairLeft** (float) - Time left for mandatory pit repairs, s - **PitSvFuel** (float) - Pit service fuel add amount, l or kWh - **PitSvLFP** (float) - Pit service left front tire pressure, kPa ``` -------------------------------- ### GET /telemetry/vehicle Source: https://github.com/kutu/pyirsdk/blob/master/vars.txt Retrieves current vehicle telemetry data including tire wear, pressures, acceleration, and engine metrics. ```APIDOC ## GET /telemetry/vehicle ### Description Retrieves real-time telemetry data for the player's vehicle, including tire conditions, engine status, and physical dynamics. ### Method GET ### Endpoint /telemetry/vehicle ### Response #### Success Response (200) - **LFTiresAvailable** (int) - Left front tires remaining (255 = unlimited) - **LFwearL** (float) - LF tire left percent tread remaining, % - **LongAccel** (float) - Longitudinal acceleration, m/s^2 - **LRbrakeLinePress** (float) - LR brake line pressure, bar - **ManifoldPress** (float) - Engine manifold pressure, bar - **OilTemp** (float) - Engine oil temperature, C ``` -------------------------------- ### Initialize and Connect to IRSDK Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/01 Introduction.md Import the library, create an IRSDK instance, and establish a connection to the iRacing simulator. Ensure iRacing is running and a test session is active. ```python >>> import irsdk >>> ir = irsdk.IRSDK() >>> ir.startup() <<< True ``` -------------------------------- ### Initialize and Access Telemetry with IRSDK Source: https://context7.com/kutu/pyirsdk/llms.txt Demonstrates basic connection, telemetry variable retrieval, and session info access using the IRSDK class. ```python import irsdk # Initialize and connect to iRacing ir = irsdk.IRSDK() if ir.startup(): print("Connected to iRacing!") # Access live telemetry data using dictionary-style access speed = ir['Speed'] # Current speed in m/s rpm = ir['RPM'] # Engine RPM fuel = ir['FuelLevel'] # Fuel level in liters gear = ir['Gear'] # Current gear (-1=reverse, 0=neutral, 1-n=forward) throttle = ir['Throttle'] # Throttle position 0.0-1.0 brake = ir['Brake'] # Brake position 0.0-1.0 lap = ir['Lap'] # Current lap number lap_time = ir['LapCurrentLapTime'] # Current lap time in seconds print(f"Speed: {speed:.1f} m/s, RPM: {rpm:.0f}, Gear: {gear}, Fuel: {fuel:.1f}L") # Access session info data (nested dictionary structure) if ir['WeekendInfo']: track = ir['WeekendInfo']['TrackName'] print(f"Track: {track}") # Clean up when done ir.shutdown() ``` -------------------------------- ### Initialize and Run an iRacing Application Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/03 Base application.md This script establishes a connection to iRacing, maintains a state object, and runs a loop to process telemetry and session data. ```python #!python3 import irsdk import time # this is our State class, with some helpful variables class State: ir_connected = False last_car_setup_tick = -1 # here we check if we are connected to iracing # so we can retrieve some data def check_iracing(): if state.ir_connected and not (ir.is_initialized and ir.is_connected): state.ir_connected = False # don't forget to reset your State variables state.last_car_setup_tick = -1 # we are shutting down ir library (clearing all internal variables) ir.shutdown() print('irsdk disconnected') elif not state.ir_connected and ir.startup() and ir.is_initialized and ir.is_connected: state.ir_connected = True print('irsdk connected') # our main loop, where we retrieve data # and do something useful with it def loop(): # on each tick we freeze buffer with live telemetry # it is optional, but useful if you use vars like CarIdxXXX # this way you will have consistent data from those vars inside one tick # because sometimes while you retrieve one CarIdxXXX variable # another one in next line of code could change # to the next iracing internal tick_count # and you will get incosistent data ir.freeze_var_buffer_latest() # retrieve live telemetry data # check here for list of available variables # https://github.com/kutu/pyirsdk/blob/master/vars.txt # this is not full list, because some cars has additional # specific variables, like break bias, wings adjustment, etc t = ir['SessionTime'] print('session time:', t) # retrieve CarSetup from session data # we also check if CarSetup data has been updated # with ir.get_session_info_update_by_key(key) # but first you need to request data, before checking if its updated car_setup = ir['CarSetup'] if car_setup: car_setup_tick = ir.get_session_info_update_by_key('CarSetup') if car_setup_tick != state.last_car_setup_tick: state.last_car_setup_tick = car_setup_tick print('car setup update count:', car_setup['UpdateCount']) # now you can go to garage, and do some changes with your setup # this line will be printed, only when you change something # and press apply button, but not every 1 sec # note about session info data # you should always check if data exists first # before do something like ir['WeekendInfo']['TeamRacing'] # so do like this: # if ir['WeekendInfo']: # print(ir['WeekendInfo']['TeamRacing']) # and just as an example # you can send commands to iracing # like switch cameras, rewind in replay mode, send chat and pit commands, etc # check pyirsdk.py library to see what commands are available # https://github.com/kutu/pyirsdk/blob/master/irsdk.py#L134 (class BroadcastMsg) # when you run this script, camera will be switched to P1 # and very first camera in list of cameras in iracing # while script is running, change camera by yourself in iracing # and notice how this code changes it back every 1 sec ir.cam_switch_pos(0, 1) if __name__ == '__main__': # initializing ir and state ir = irsdk.IRSDK() state = State() try: # infinite loop while True: # check if we are connected to iracing check_iracing() # if we are, then process data if state.ir_connected: loop() # sleep for 1 second # maximum you can use is 1/60 # cause iracing updates data with 60 fps time.sleep(1) except KeyboardInterrupt: # press ctrl+c to exit pass ``` -------------------------------- ### Initialize and Read Telemetry with iRacing SDK Source: https://github.com/kutu/pyirsdk/blob/master/README.md Establishes a connection to the iRacing SDK and retrieves the current speed telemetry value. ```python #!python3 import irsdk ir = irsdk.IRSDK() ir.startup() print(ir['Speed']) ``` -------------------------------- ### Manage replay playback Source: https://context7.com/kutu/pyirsdk/llms.txt Commands to adjust playback speed, navigate to specific frames, and search for events. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Set replay playback speed (negative for reverse) ir.replay_set_play_speed(speed=2, slow_motion=False) # 2x speed ir.replay_set_play_speed(speed=1, slow_motion=True) # Slow motion # Jump to specific position in replay ir.replay_set_play_position(irsdk.RpyPosMode.begin, frame_num=0) # Go to start ir.replay_set_play_position(irsdk.RpyPosMode.current, frame_num=100) # Jump forward 100 frames # Search through replay ir.replay_search(irsdk.RpySrchMode.next_incident) # Jump to next incident ir.replay_search(irsdk.RpySrchMode.prev_lap) # Jump to previous lap ir.replay_search(irsdk.RpySrchMode.to_start) # Jump to start # Search to specific session time ir.replay_search_session_time(session_num=0, session_time_ms=60000) # 1 minute in # Clear replay tape ir.replay_set_state(irsdk.RpyStateMode.erase_tape) ``` -------------------------------- ### Test iRacing SDK with Dump Files Source: https://context7.com/kutu/pyirsdk/llms.txt Use memory dump files for development and testing without running iRacing. Create dump files from live sessions or parse existing dump files. ```python import irsdk # Create a dump file from live session (run while iRacing is active) ir = irsdk.IRSDK() ir.startup(dump_to='session_dump.bin') # Saves current memory state ir.shutdown() # Later: Use dump file for testing without iRacing running ir = irsdk.IRSDK() if ir.startup(test_file='session_dump.bin'): print(f"Speed: {ir['Speed']}") print(f"Track: {ir['WeekendInfo']['TrackName']}") ir.shutdown() # Parse session to human-readable text file ir = irsdk.IRSDK() ir.startup(test_file='session_dump.bin') ir.parse_to('session_data.txt') # Creates formatted text output ir.shutdown() ``` -------------------------------- ### Control iRacing camera system Source: https://context7.com/kutu/pyirsdk/llms.txt Methods for switching camera focus and setting camera state flags. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Switch camera to car in position 1 (leader), camera group 1, camera 0 ir.cam_switch_pos(position=1, group=1, camera=0) # Switch camera to specific car number ir.cam_switch_num(car_number='42', group=1, camera=0) # Set camera state flags ir.cam_set_state(irsdk.CameraState.cam_tool_active) # Available camera state flags: # - CameraState.is_session_screen # - CameraState.is_scenic_active # - CameraState.cam_tool_active # - CameraState.ui_hidden # - CameraState.use_auto_shot_selection # - CameraState.use_temporary_edits # - CameraState.use_key_acceleration # - CameraState.use_mouse_aim_mode ``` -------------------------------- ### Control Force Feedback and Reload Textures Source: https://context7.com/kutu/pyirsdk/llms.txt Adjust force feedback settings and reload car textures dynamically using irsdk commands. Ensure irsdk is initialized before use. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Set maximum force feedback force (in Nm) ir.ffb_command(irsdk.FFBCommandMode.ffb_command_max_force, value=15.0) # Reload all textures ir.reload_all_textures() # Reload textures for specific car ir.reload_texture(car_idx=5) # Reload textures for car index 5 ``` -------------------------------- ### Configure pit stop services Source: https://context7.com/kutu/pyirsdk/llms.txt Commands to manage fuel, tire changes, and other pit services. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Clear all pit checkboxes ir.pit_command(irsdk.PitCommandMode.clear) # Add fuel (amount in liters, 0 uses existing amount) ir.pit_command(irsdk.PitCommandMode.fuel, 50) # Add 50 liters # Request tire changes (pressure in kPa, 0 uses existing pressure) ir.pit_command(irsdk.PitCommandMode.lf, 175) # Left front, 175 kPa ir.pit_command(irsdk.PitCommandMode.rf, 175) # Right front ir.pit_command(irsdk.PitCommandMode.lr, 170) # Left rear ir.pit_command(irsdk.PitCommandMode.rr, 170) # Right rear # Other pit commands ir.pit_command(irsdk.PitCommandMode.ws) # Windshield tearoff ir.pit_command(irsdk.PitCommandMode.fr) # Fast repair # Clear specific services ir.pit_command(irsdk.PitCommandMode.clear_tires) ir.pit_command(irsdk.PitCommandMode.clear_fuel) ir.pit_command(irsdk.PitCommandMode.clear_ws) ir.pit_command(irsdk.PitCommandMode.clear_fr) ``` -------------------------------- ### Read iRacing Data from a Test File Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/02 Using irsdk script.md Initialize the irsdk library and read data from a specified binary file (e.g., 'data.bin') instead of a live iRacing session. This is useful for testing scripts without the simulator running. The test file can also be an IBT Telemetry file. ```python #!python3 import irsdk ir = irsdk.IRSDK() ir.startup(test_file='data.bin') print(ir['Speed']) ``` -------------------------------- ### iRacing SDK Command Line Interface Source: https://context7.com/kutu/pyirsdk/llms.txt Utilize the irsdk command-line tool for dumping and parsing session data. This tool can be used independently of the Python SDK. ```bash irsdk --version ``` ```bash irsdk --dump data.bin ``` ```bash irsdk --test data.bin --parse data.txt ``` ```bash irsdk --parse live_data.txt ``` -------------------------------- ### Parse Dumped Binary File to Text Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/02 Using irsdk script.md Use the irsdk.exe script to parse a previously dumped binary file into a human-readable text file. ```bash irsdk.exe --test data.bin --parse data.txt ``` -------------------------------- ### Dump iRacing Memory Map to Binary Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/02 Using irsdk script.md Use the irsdk.exe script to dump the current iRacing memory map to a binary file for later analysis. ```bash irsdk.exe --dump data.bin ``` -------------------------------- ### Manage Connection State Source: https://context7.com/kutu/pyirsdk/llms.txt Uses is_connected and is_initialized properties to monitor and handle connection status in a loop. ```python import irsdk import time class State: ir_connected = False ir = irsdk.IRSDK() state = State() def check_iracing(): if state.ir_connected and not (ir.is_initialized and ir.is_connected): # Lost connection state.ir_connected = False ir.shutdown() print('Disconnected from iRacing') elif not state.ir_connected and ir.startup() and ir.is_initialized and ir.is_connected: # New connection established state.ir_connected = True print('Connected to iRacing') # Main loop with reconnection handling while True: check_iracing() if state.ir_connected: print(f"Speed: {ir['Speed']:.1f} m/s") time.sleep(1) ``` -------------------------------- ### Read iRacing Telemetry from IBT Files Source: https://context7.com/kutu/pyirsdk/llms.txt Open and read iRacing telemetry data from .ibt files for post-session analysis. This does not require a live connection to iRacing. Ensure the 'race_telemetry.ibt' file exists. ```python import irsdk # Open IBT telemetry file išt = irsdk.IBT() išt.open('race_telemetry.ibt') # Get list of available variables print("Available variables:",ništ.var_headers_names) # Read single sample (latest) speed =ništ['Speed'] rpm =ništ['RPM'] print(f"Final: Speed={speed:.1f} m/s, RPM={rpm:.0f}") # Read specific sample by index speed_at_100 =ništ.get(100, 'Speed') rpm_at_100 =ništ.get(100, 'RPM') print(f"Sample 100: Speed={speed_at_100:.1f} m/s, RPM={rpm_at_100:.0f}") # Read all samples for a variable (for plotting/analysis) all_speeds =ništ.get_all('Speed') all_throttle =ništ.get_all('Throttle') all_brake =ništ.get_all('Brake') print(f"Total samples: {len(all_speeds)}") print(f"Max speed: {max(all_speeds):.1f} m/s") print(f"Average throttle: {sum(all_throttle)/len(all_throttle)*100:.1f}%") # Clean up išt.close() ``` -------------------------------- ### Replay Control Commands Source: https://context7.com/kutu/pyirsdk/llms.txt Control replay playback including speed, position, and state for building replay analysis tools. ```APIDOC ## Replay Control Commands ### Description Manage replay playback speed, navigation, and tape state. ### Methods - **replay_set_play_speed(speed, slow_motion)**: Adjust playback speed. - **replay_set_play_position(mode, frame_num)**: Jump to a specific frame. - **replay_search(mode)**: Search for incidents or laps. - **replay_search_session_time(session_num, session_time_ms)**: Jump to a specific session time. - **replay_set_state(mode)**: Set replay state (e.g., erase_tape). ``` -------------------------------- ### Send chat commands Source: https://context7.com/kutu/pyirsdk/llms.txt Automate chat window interactions and trigger macros. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Open chat window ir.chat_command(irsdk.ChatCommandMode.begin_chat) # Reply to last private message ir.chat_command(irsdk.ChatCommandMode.reply) # Send chat macro (1-15) ir.chat_command_macro(macro_num=1) # Trigger macro 1 # Close chat window ir.chat_command(irsdk.ChatCommandMode.cancel) ``` -------------------------------- ### Parse Current iRacing Memory Map to Text Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/02 Using irsdk script.md Use the irsdk.exe script to directly parse the current iRacing memory map into a readable text file. ```bash irsdk.exe --parse data.txt ``` -------------------------------- ### Telemetry and Video Commands Source: https://context7.com/kutu/pyirsdk/llms.txt Control telemetry recording and video capture from within your application. ```APIDOC ## Telemetry and Video Commands ### Description Manage telemetry recording files and video capture settings. ### Methods - **telem_command(mode)**: Control telemetry (start, stop, restart). - **video_capture(mode)**: Control video/screenshot capture (trigger_screen_shot, start_video_capture, end_video_capture, toggle_video_capture, show_video_timer, hide_video_timer). ``` -------------------------------- ### Camera Control Commands Source: https://context7.com/kutu/pyirsdk/llms.txt Methods to control iRacing's camera system, including switching focus between cars and camera groups. ```APIDOC ## Camera Control Commands ### Description Provides methods to switch camera focus and set camera state flags. ### Methods - **cam_switch_pos(position, group, camera)**: Switch camera to a specific car position. - **cam_switch_num(car_number, group, camera)**: Switch camera to a specific car number. - **cam_set_state(state)**: Set camera state flags (e.g., cam_tool_active). ``` -------------------------------- ### Chat Commands Source: https://context7.com/kutu/pyirsdk/llms.txt Send chat commands for automated messaging and macro activation. ```APIDOC ## Chat Commands ### Description Manage chat window state and trigger chat macros. ### Methods - **chat_command(mode)**: Control chat window (begin_chat, reply, cancel). - **chat_command_macro(macro_num)**: Trigger a specific chat macro (1-15). ``` -------------------------------- ### Control telemetry and video capture Source: https://context7.com/kutu/pyirsdk/llms.txt Manage recording states for telemetry data and video capture. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Telemetry recording control ir.telem_command(irsdk.TelemCommandMode.start) # Start recording ir.telem_command(irsdk.TelemCommandMode.stop) # Stop recording ir.telem_command(irsdk.TelemCommandMode.restart) # Write file and start new # Video capture control ir.video_capture(irsdk.VideoCaptureMode.trigger_screen_shot) # Take screenshot ir.video_capture(irsdk.VideoCaptureMode.start_video_capture) # Start recording ir.video_capture(irsdk.VideoCaptureMode.end_video_capture) # Stop recording ir.video_capture(irsdk.VideoCaptureMode.toggle_video_capture) # Toggle recording ir.video_capture(irsdk.VideoCaptureMode.show_video_timer) # Show timer overlay ir.video_capture(irsdk.VideoCaptureMode.hide_video_timer) # Hide timer overlay ``` -------------------------------- ### Access Session Info Data Source: https://context7.com/kutu/pyirsdk/llms.txt Retrieves structured race weekend and driver information from the session data. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Access weekend info if ir['WeekendInfo']: weekend = ir['WeekendInfo'] print(f"Track: {weekend['TrackName']}") print(f"Track Length: {weekend['TrackLength']}") print(f"Weather: {weekend['TrackSkies']}") print(f"Air Temp: {weekend['TrackAirTemp']}") # Access driver info if ir['DriverInfo']: drivers = ir['DriverInfo']['Drivers'] for driver in drivers: print(f"#{driver['CarNumber']} {driver['UserName']} - {driver['CarScreenName']}") ``` -------------------------------- ### Read Speed Data from IRSDK Source: https://github.com/kutu/pyirsdk/blob/master/tutorials/01 Introduction.md Access real-time telemetry data, such as speed, after successfully connecting to the iRacing simulator. Always check for data existence before accessing. ```python >>> ir['Speed'] <<< 0.0 ``` -------------------------------- ### Freeze Telemetry Variable Buffer Source: https://context7.com/kutu/pyirsdk/llms.txt Captures a consistent snapshot of telemetry data using freeze_var_buffer_latest to ensure synchronization across multiple variables. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Freeze buffer for consistent multi-car data reads ir.freeze_var_buffer_latest() # All CarIdx variables now represent the same simulation tick positions = ir['CarIdxPosition'] # Race positions for all cars lap_pcts = ir['CarIdxLapDistPct'] # Track position % for all cars laps = ir['CarIdxLapCompleted'] # Completed laps for all cars rpms = ir['CarIdxRPM'] # Engine RPM for all cars # Find leader position for idx, pos in enumerate(positions): if pos == 1: print(f"Leader is car index {idx} at {lap_pcts[idx]*100:.1f}% around lap") break # Always unfreeze when done ir.unfreeze_var_buffer_latest() ``` -------------------------------- ### Telemetry Variables Source: https://github.com/kutu/pyirsdk/blob/master/vars.txt A comprehensive list of telemetry variables available through the iRacing SDK. ```APIDOC ## Telemetry Variables ### Description This section lists the available telemetry variables from the iRacing SDK, along with their units and a brief description. ### Variables - **SessionUniqueID** (Session ID) - Session ID - **Shifter** (Log inputs from the players shifter control) - **ShiftGrindRPM** (RPM of shifter grinding noise, RPM) - **ShiftIndicatorPct** (DEPRECATED use DriverCarSLBlinkRPM instead, %) - **ShiftPowerPct** (Friction torque applied to gears when shifting or grinding, %) - **Skies** (Skies (0=clear/1=p cloudy/2=m cloudy/3=overcast)) - **SolarAltitude** (Sun angle above horizon in radians, rad) - **SolarAzimuth** (Sun angle clockwise from north in radians, rad) - **Speed** (GPS vehicle speed, m/s) - **SteeringFFBEnabled** (Force feedback is enabled) - **SteeringWheelAngle** (Steering wheel angle, rad) - **SteeringWheelAngleMax** (Steering wheel max angle, rad) - **SteeringWheelLimiter** (Force feedback limiter strength limits impacts and oscillation, %) - **SteeringWheelMaxForceNm** (Value of strength or max force slider in Nm for FFB, N*m) - **SteeringWheelPctDamper** (Force feedback % max damping, %) - **SteeringWheelPctIntensity** (Force feedback % max intensity, %) - **SteeringWheelPctSmoothing** (Force feedback % max smoothing, %) - **SteeringWheelPctTorque** (Force feedback % max torque on steering shaft unsigned, %) - **SteeringWheelPctTorqueSign** (Force feedback % max torque on steering shaft signed, %) - **SteeringWheelPctTorqueSignStops** (Force feedback % max torque on steering shaft signed stops, %) - **SteeringWheelPeakForceNm** (Peak torque mapping to direct input units for FFB, N*m) - **SteeringWheelTorque** (Output torque on steering shaft, N*m) - **SteeringWheelTorque_ST** (Output torque on steering shaft at 360 Hz, N*m) - **SteeringWheelUseLinear** (True if steering wheel force is using linear mode) - **Throttle** (0=off throttle to 1=full throttle, %) - **ThrottleRaw** (Raw throttle input 0=off throttle to 1=full throttle, %) - **TireLF_RumblePitch** (Players LF Tire Sound rumblestrip pitch, Hz) - **TireLR_RumblePitch** (Players LR Tire Sound rumblestrip pitch, Hz) - **TireRF_RumblePitch** (Players RF Tire Sound rumblestrip pitch, Hz) - **TireRR_RumblePitch** (Players RR Tire Sound rumblestrip pitch, Hz) - **TireSetsAvailable** (How many tire sets are remaining 255 is unlimited) - **TireSetsUsed** (How many tire sets used so far) - **TrackTemp** (Deprecated set to TrackTempCrew, C) - **TrackTempCrew** (Temperature of track measured by crew around track, C) - **TrackWetness** (How wet is the average track surface, irsdk_TrackWetness) - **VelocityX** (X velocity, m/s) - **VelocityX_ST** (X velocity, m/s at 360 Hz) - **VelocityY** (Y velocity, m/s) - **VelocityY_ST** (Y velocity, m/s at 360 Hz) - **VelocityZ** (Z velocity, m/s) - **VelocityZ_ST** (Z velocity, m/s at 360 Hz) - **VertAccel** (Vertical acceleration (including gravity), m/s^2) - **VertAccel_ST** (Vertical acceleration (including gravity) at 360 Hz, m/s^2) - **VidCapActive** (True if video currently being captured) - **VidCapEnabled** (True if video capture system is enabled) - **Voltage** (Engine voltage, V) - **WaterLevel** (Engine coolant level, l) - **WaterTemp** (Engine coolant temp, C) - **WeatherDeclaredWet** (The steward says rain tires can be used) - **WindDir** (Wind direction at start/finish line, rad) - **WindVel** (Wind velocity at start/finish line, m/s) - **Yaw** (Yaw orientation, rad) - **YawNorth** (Yaw orientation relative to north, rad) - **YawRate** (Yaw rate, rad/s) - **YawRate_ST** (Yaw rate at 360 Hz, rad/s) ``` -------------------------------- ### Pit Stop Commands Source: https://context7.com/kutu/pyirsdk/llms.txt Send pit service commands to configure pit stops while the driver is in the car. ```APIDOC ## Pit Stop Commands ### Description Configure pit services such as fuel, tire changes, and repairs. ### Methods - **pit_command(mode, value)**: Send pit service commands. Modes include fuel, tire positions (lf, rf, lr, rr), windshield tearoff (ws), and fast repair (fr). ``` -------------------------------- ### Interpret iRacing Session Flags and Enums Source: https://context7.com/kutu/pyirsdk/llms.txt Interpret bitfield values from telemetry data using provided enums for session flags, engine warnings, track location, and pit service status. Ensure irsdk is initialized and connected. ```python import irsdk ir = irsdk.IRSDK() ir.startup() # Check session flags flags = ir['SessionFlags'] if flags & irsdk.Flags.green: print("Green flag!") elif flags & irsdk.Flags.yellow: print("Yellow flag - caution!") elif flags & irsdk.Flags.checkered: print("Checkered flag!") elif flags & irsdk.Flags.black: print("Black flag issued!") # Check engine warnings warnings = ir['EngineWarnings'] if warnings & irsdk.EngineWarnings.fuel_pressure_warning: print("Low fuel pressure!") if warnings & irsdk.EngineWarnings.oil_temp_warning: print("High oil temperature!") if warnings & irsdk.EngineWarnings.pit_speed_limiter: print("Pit speed limiter active") # Check track surface surface = ir['PlayerTrackSurface'] if surface == irsdk.TrkLoc.on_track: print("On track") elif surface == irsdk.TrkLoc.in_pit_stall: print("In pit stall") elif surface == irsdk.TrkLoc.off_track: print("Off track!") # Check pit service status pit_status = ir['PlayerCarPitSvStatus'] if pit_status == irsdk.PitSvStatus.in_progress: print("Pit service in progress...") elif pit_status == irsdk.PitSvStatus.complete: print("Pit service complete!") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.