Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
spline.py
Go to the documentation of this file.
1# pylint: skip-file
2# mypy: ignore-errors
3import matplotlib.pyplot as plt
4
5x_values0 = []
6y_values0 = []
7ox_values0 = []
8oy_values0 = []
9rx_values0 = []
10ry_values0 = []
11
12x_values1 = []
13y_values1 = []
14ox_values1 = []
15oy_values1 = []
16rx_values1 = []
17ry_values1 = []
18
19with open("spline0.txt", "r") as file:
20 for line in file:
21 line = line.strip() # Remove leading/trailing whitespace
22 if line:
23 x, y = line.split()
24 x_values0.append(float(x))
25 y_values0.append(float(y))
26
27with open("spline1.txt", "r") as file:
28 for line in file:
29 line = line.strip() # Remove leading/trailing whitespace
30 if line:
31 x, y = line.split()
32 x_values1.append(float(x))
33 y_values1.append(float(y))
34
35
36plt.plot(ox_values0, oy_values0, "g-", label="Corrected Track Limits")
37plt.plot(ox_values1, oy_values1, "g-")
38
39plt.plot(x_values0, y_values0, "r-", label="Spline Approximation")
40plt.plot(x_values1, y_values1, "r-")
41
42
43plt.plot(rx_values0, ry_values0, "bo", label="Uncorrected Blue Cones", markersize=5)
44plt.plot(rx_values1, ry_values1, "yo", label="Uncorrected Yellow Cones", markersize=5)
45
46plt.plot(axis="equal")
47plt.legend()
48plt.show()