Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
skidpadgenerator.py
Go to the documentation of this file.
1import math
2import os
3# Circle parameters
4centerX = 15.0
5centerY = 9.125
6radius = 8.7
7numPoints = 100 # Number of points to describe the circle
8
9entryspeed = 2.5
10exitspeed = 2.5
11circular_speed = 3.5
12
13file_name = "./src/planning/src/utils/skidpad.txt"
14
15# Get the absolute path of the file
16
17
18
19with open(file_name, "w") as file:
20
21 for i in range(0,30):
22 file.write(f"{i/2:.3f} 0 {entryspeed}\n")
23
24 # Generate and print circular path points
25 for i in range(numPoints):
26 theta = (2 * math.pi / numPoints) * i - math.pi / 2 # Angle in radians, start at x=15, y=0
27 x = centerX + radius * math.cos(theta)
28 y = centerY + radius * math.sin(theta)
29 file.write(f"{x:.3f} -{y:.3f} {circular_speed}\n")
30
31 for i in range(numPoints):
32 theta = (2 * math.pi / numPoints) * i - math.pi / 2 # Angle in radians, start at x=15, y=0
33 x = centerX + radius * math.cos(theta)
34 y = centerY + radius * math.sin(theta)
35 file.write(f"{x:.3f} -{y:.3f} {circular_speed}\n")
36
37 for i in range(numPoints):
38 theta = (2 * math.pi / numPoints) * i - math.pi / 2 # Angle in radians, start at x=15, y=0
39 x = centerX + radius * math.cos(theta)
40 y = centerY + radius * math.sin(theta)
41 file.write(f"{x:.3f} {y:.3f} {circular_speed}\n")
42
43 for i in range(numPoints):
44 theta = (2 * math.pi / numPoints) * i - math.pi / 2 # Angle in radians, start at x=15, y=0
45 x = centerX + radius * math.cos(theta)
46 y = centerY + radius * math.sin(theta)
47 file.write(f"{x:.3f} {y:.3f} {circular_speed}\n")
48
49
50 for i in range(0,30):
51 file.write(f"{15+i/2:.3f} 0 {exitspeed}\n")
52
53 for i in range(0,40):
54 file.write(f"{30+i/2:.3f} 0 {0}\n")
55
56 file_path = os.path.abspath(file_name)
57 print(f"File written to: {file_path}")