Skip to content

Commit 6fb5950

Browse files
committed
Add mirror-path script and mirror several paths
1 parent a1d7ca3 commit 6fb5950

4 files changed

Lines changed: 508 additions & 0 deletions

File tree

scripts/mirror-path.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import sys
2+
import json
3+
import pathlib
4+
5+
if len(sys.argv) < 3:
6+
raise SystemExit("Usage: python[3] " + sys.argv[0] + " <path of input file> <path of new output file>")
7+
8+
in_path = pathlib.Path(sys.argv[1])
9+
if not in_path.exists():
10+
raise SystemExit("Specified auto path does not exist!")
11+
12+
out_path = pathlib.Path(sys.argv[2])
13+
14+
def mirror(inPath):
15+
file = open(inPath)
16+
17+
doc = json.load(file)
18+
19+
for waypoint in doc["waypoints"]:
20+
waypoint["linkedName"] = None
21+
waypoint["anchor"]["y"] = 8 - waypoint["anchor"]["y"]
22+
if not waypoint["prevControl"] is None:
23+
waypoint["prevControl"]["y"] = 8 - waypoint["prevControl"]["y"]
24+
if not waypoint["nextControl"] is None:
25+
waypoint["nextControl"]["y"] = 8 - waypoint["nextControl"]["y"]
26+
27+
doc["goalEndState"]["rotation"] *= -1
28+
29+
doc["idealStartingState"]["rotation"] *= -1
30+
31+
return doc
32+
33+
try:
34+
outfile = open(out_path, "x")
35+
except:
36+
raise SystemExit("Specified out path already exists")
37+
38+
json.dump(mirror(in_path), outfile, indent=2)
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
{
2+
"version": "2025.0",
3+
"waypoints": [
4+
{
5+
"anchor": {
6+
"x": 4.0,
7+
"y": 0.5999999999999996
8+
},
9+
"prevControl": null,
10+
"nextControl": {
11+
"x": 4.522842413251909,
12+
"y": 0.46679386164985903
13+
},
14+
"isLocked": false,
15+
"linkedName": null
16+
},
17+
{
18+
"anchor": {
19+
"x": 7.356458333333333,
20+
"y": 1.301304824561404
21+
},
22+
"prevControl": {
23+
"x": 6.264326197317278,
24+
"y": 0.3555995869590429
25+
},
26+
"nextControl": {
27+
"x": 7.604110608649321,
28+
"y": 1.5157532838154486
29+
},
30+
"isLocked": false,
31+
"linkedName": null
32+
},
33+
{
34+
"anchor": {
35+
"x": 7.75,
36+
"y": 1.8890000000000002
37+
},
38+
"prevControl": {
39+
"x": 7.49826656534994,
40+
"y": 1.1741407578482397
41+
},
42+
"nextControl": {
43+
"x": 7.876325778892795,
44+
"y": 2.247733239742546
45+
},
46+
"isLocked": false,
47+
"linkedName": null
48+
},
49+
{
50+
"anchor": {
51+
"x": 7.75,
52+
"y": 3.339945175438597
53+
},
54+
"prevControl": {
55+
"x": 8.183541109157595,
56+
"y": 2.8896787623928537
57+
},
58+
"nextControl": {
59+
"x": 7.576599699524522,
60+
"y": 3.520034974691675
61+
},
62+
"isLocked": false,
63+
"linkedName": null
64+
},
65+
{
66+
"anchor": {
67+
"x": 7.000657894736843,
68+
"y": 3.339945175438597
69+
},
70+
"prevControl": {
71+
"x": 7.2374057894794595,
72+
"y": 3.567115609221368
73+
},
74+
"nextControl": {
75+
"x": 6.810930473863743,
76+
"y": 3.1578930370359064
77+
},
78+
"isLocked": false,
79+
"linkedName": null
80+
},
81+
{
82+
"anchor": {
83+
"x": 6.18327850877193,
84+
"y": 1.060899122807018
85+
},
86+
"prevControl": {
87+
"x": 6.870833208461253,
88+
"y": 2.1950843060236753
89+
},
90+
"nextControl": {
91+
"x": 5.873768378921202,
92+
"y": 0.55033348564276
93+
},
94+
"isLocked": false,
95+
"linkedName": null
96+
},
97+
{
98+
"anchor": {
99+
"x": 4.731228070175439,
100+
"y": 0.5999999999999996
101+
},
102+
"prevControl": {
103+
"x": 5.431228070175439,
104+
"y": 0.5999999999999996
105+
},
106+
"nextControl": {
107+
"x": 4.431228070175439,
108+
"y": 0.5999999999999996
109+
},
110+
"isLocked": false,
111+
"linkedName": null
112+
},
113+
{
114+
"anchor": {
115+
"x": 2.7983662280701753,
116+
"y": 0.5999999999999996
117+
},
118+
"prevControl": {
119+
"x": 3.2503289473684216,
120+
"y": 0.5800877192982457
121+
},
122+
"nextControl": null,
123+
"isLocked": false,
124+
"linkedName": null
125+
}
126+
],
127+
"rotationTargets": [
128+
{
129+
"waypointRelativePos": 0.5,
130+
"rotationDegrees": 0.0
131+
},
132+
{
133+
"waypointRelativePos": 1.5,
134+
"rotationDegrees": -90.0
135+
},
136+
{
137+
"waypointRelativePos": 4.376058041112453,
138+
"rotationDegrees": 91.0
139+
},
140+
{
141+
"waypointRelativePos": 5.0,
142+
"rotationDegrees": 0.0
143+
}
144+
],
145+
"constraintZones": [
146+
{
147+
"name": "Constraints Zone",
148+
"minWaypointRelativePos": 1.1999050332383672,
149+
"maxWaypointRelativePos": 4.217948717948717,
150+
"constraints": {
151+
"maxVelocity": 1.5,
152+
"maxAcceleration": 3.0,
153+
"maxAngularVelocity": 540.0,
154+
"maxAngularAcceleration": 720.0,
155+
"nominalVoltage": 12.0,
156+
"unlimited": false
157+
}
158+
}
159+
],
160+
"pointTowardsZones": [],
161+
"eventMarkers": [
162+
{
163+
"name": "StartIntake",
164+
"waypointRelativePos": 0.75,
165+
"endWaypointRelativePos": null,
166+
"command": {
167+
"type": "sequential",
168+
"data": {
169+
"commands": [
170+
{
171+
"type": "named",
172+
"data": {
173+
"name": "ExtendSlapdown"
174+
}
175+
},
176+
{
177+
"type": "named",
178+
"data": {
179+
"name": "StartIntake"
180+
}
181+
}
182+
]
183+
}
184+
}
185+
}
186+
],
187+
"globalConstraints": {
188+
"maxVelocity": 3.0,
189+
"maxAcceleration": 3.0,
190+
"maxAngularVelocity": 540.0,
191+
"maxAngularAcceleration": 720.0,
192+
"nominalVoltage": 12.0,
193+
"unlimited": false
194+
},
195+
"goalEndState": {
196+
"velocity": 0,
197+
"rotation": -0.0
198+
},
199+
"reversed": false,
200+
"folder": "Secondary",
201+
"idealStartingState": {
202+
"velocity": 0,
203+
"rotation": -0.0
204+
},
205+
"useDefaultConstraints": false
206+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": "2025.0",
3+
"waypoints": [
4+
{
5+
"anchor": {
6+
"x": 2.7983662280701753,
7+
"y": 0.5999999999999996
8+
},
9+
"prevControl": null,
10+
"nextControl": {
11+
"x": 4.558587991201369,
12+
"y": 0.6103598571029867
13+
},
14+
"isLocked": false,
15+
"linkedName": null
16+
},
17+
{
18+
"anchor": {
19+
"x": 4.0,
20+
"y": 0.5999999999999996
21+
},
22+
"prevControl": {
23+
"x": 3.2222697358960812,
24+
"y": 0.5473161994459899
25+
},
26+
"nextControl": null,
27+
"isLocked": false,
28+
"linkedName": null
29+
}
30+
],
31+
"rotationTargets": [],
32+
"constraintZones": [],
33+
"pointTowardsZones": [],
34+
"eventMarkers": [],
35+
"globalConstraints": {
36+
"maxVelocity": 3.0,
37+
"maxAcceleration": 3.0,
38+
"maxAngularVelocity": 540.0,
39+
"maxAngularAcceleration": 720.0,
40+
"nominalVoltage": 12.0,
41+
"unlimited": false
42+
},
43+
"goalEndState": {
44+
"velocity": 0,
45+
"rotation": -0.0
46+
},
47+
"reversed": false,
48+
"folder": "Secondary",
49+
"idealStartingState": {
50+
"velocity": 0,
51+
"rotation": -0.0
52+
},
53+
"useDefaultConstraints": true
54+
}

0 commit comments

Comments
 (0)