3import matplotlib.pyplot
as plt
13file_name =
"./src/planning/src/utils/skidpadcones1.txt"
15with open(file_name,
"w")
as file:
17 for i
in range(0,int(centerX*2+5)*2):
19 if math.sqrt((x-centerX)**2 + (centerY-1.5)**2) > outerRadius:
20 file.write(f
"{x:.3f} {1.5:.3f} {0}\n")
21 file.write(f
"{x:.3f} {-1.5:.3f} {0}\n")
24 for i
in range(numPoints):
25 theta = (2 * math.pi / numPoints) * i - math.pi / 2
26 x = centerX + radius * math.cos(theta)
27 y = centerY + radius * math.sin(theta)
28 file.write(f
"{x:.3f} {-y:.3f} {0}\n")
30 for i
in range(numPoints):
31 theta = (2 * math.pi / numPoints) * i - math.pi / 2
32 x = centerX + outerRadius * math.cos(theta)
33 y = centerY + outerRadius * math.sin(theta)
35 file.write(f
"{x:.3f} {-y:.3f} {0}\n")
37 for i
in range(numPoints):
38 theta = (2 * math.pi / numPoints) * i - math.pi / 2
39 x = centerX + radius * math.cos(theta)
40 y = centerY + radius * math.sin(theta)
41 file.write(f
"{x:.3f} {y:.3f} {0}\n")
43 for i
in range(numPoints):
44 theta = (2 * math.pi / numPoints) * i - math.pi / 2
45 x = centerX + outerRadius * math.cos(theta)
46 y = centerY + outerRadius * math.sin(theta)
48 file.write(f
"{x:.3f} {y:.3f} {0}\n")
50 file_path = os.path.abspath(file_name)
51 print(f
"File written to: {file_path}")
54print(f
"Generated {numPoints * 4} points in total.")
56points = np.loadtxt(file_name)
57plt.figure(figsize=(8, 8))
58plt.scatter(points[:, 0], points[:, 1], c=points[:, 2], cmap=
'viridis')
59plt.colorbar(label=
'Speed')
62plt.title(
'Skidpad Cones')
67plt.savefig(
'./src/planning/src/utils/skidpad_plot.png', dpi=300, bbox_inches=
'tight')
68print(
"Plot saved as skidpad_plot.png")
74 print(
"Display not available - plot saved to file instead")