Repository navigation
Expand file tree
/
Copy pathgraphics.py
More file actions
103 lines (79 loc) · 2.57 KB
/
Copy pathgraphics.py
File metadata and controls
103 lines (79 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import pandas as pd
class TelemetryGraph:
"""
Handles graphing telemetry data from an iRacing session.
Each graph displays data over time with markers for lap boundaries.
"""
def __init__(self, session):
"""Initialize the graph with a telemetry session."""
self.session = session
def addLapLines(self, ax):
"""Mark the beginning of each lap on the graph."""
startTimes = self.session.getLapStartTimes()
for startTime in startTimes:
ax.axvline(
x=startTime,
color="black",
linestyle="--",
alpha=0.5
)
def graphPedals(self, ax):
"""Graph throttle and brake inputs over time."""
ax.clear()
ax.plot(
self.session.times,
self.session.throttles,
label="Throttle"
)
ax.plot(
self.session.times,
self.session.brakes,
label="Brake"
)
self.addLapLines(ax)
ax.set_xlabel("Time")
ax.set_ylabel("Pedal Input")
ax.set_title("Throttle / Brake")
ax.legend()
ax.grid(True)
def graphSteering(self, ax):
"""Graph steering wheel angle over time."""
ax.clear()
ax.plot(
self.session.times,
self.session.steering,
label="Steering"
)
self.addLapLines(ax)
ax.set_xlabel("Time")
ax.set_ylabel("Steering Angle")
ax.set_title("Steering Wheel Angle")
ax.grid(True)
def graphSlipAngles(self, ax):
"""Graph vehicle slip angle over time."""
ax.clear()
ax.plot(
self.session.times,
self.session.slipAngles,
label="Slip Angle"
)
self.addLapLines(ax)
ax.set_xlabel("Time")
ax.set_ylabel("Slip Angle")
ax.set_title("Slip Angle")
ax.grid(True)
def graphLateralAccelerationDisparities(self, ax):
"""Graph calculated lateral acceleration disparities over time."""
ax.clear()
# Retrieve disparity values calculated from session telemetry.
lateralAccelerationDisparities = self.session.getLateralAccelerationDisparities()
ax.plot(
self.session.times,
lateralAccelerationDisparities,
label="Lateral Acceleration Disparity"
)
self.addLapLines(ax)
ax.set_xlabel("Time")
ax.set_ylabel("Lateral Acceleration Disparity")
ax.set_title("Lateral Acceleration Disparity")
ax.grid(True)