1
+ from command .autonomous .custom_pathing import FollowPathCustom , AngleType
2
+ from command .autonomous .trajectory import CustomTrajectory , PoseType
3
+ from robot_systems import Robot , Field
4
+ from utils import POIPose
5
+ from command import *
6
+ import config
7
+ import math
8
+
9
+ from commands2 import (
10
+ InstantCommand ,
11
+ SequentialCommandGroup ,
12
+ ParallelCommandGroup ,
13
+ ParallelDeadlineGroup ,
14
+ WaitCommand
15
+ )
16
+
17
+ from autonomous .auto_routine import AutoRoutine
18
+ from autonomous .routines .AMP_SKIP .coords import (
19
+ shoot_first_note ,
20
+ get_second_note ,
21
+ shoot_second_note ,
22
+ get_third_note ,
23
+ shoot_third_note ,
24
+ far_to_mid ,
25
+ mid_to_far ,
26
+ initial
27
+ )
28
+
29
+ from wpimath .geometry import Pose2d , Translation2d
30
+
31
+ path_1 = FollowPathCustom (
32
+ subsystem = Robot .drivetrain ,
33
+ trajectory = CustomTrajectory (
34
+ start_pose = POIPose (Pose2d (* shoot_first_note [0 ])),
35
+ waypoints = [coord for coord in shoot_first_note [1 ]],
36
+ end_pose = shoot_first_note [2 ],
37
+ max_velocity = config .drivetrain_max_vel_auto ,
38
+ max_accel = config .drivetrain_max_accel_auto - 1 ,
39
+ start_velocity = 0 ,
40
+ end_velocity = 0 ,
41
+ rev = True
42
+ ),
43
+ theta_f = math .radians (- 180 )
44
+ )
45
+
46
+ path_2 = FollowPathCustom (
47
+ subsystem = Robot .drivetrain ,
48
+ trajectory = CustomTrajectory (
49
+ # start_pose=get_second_note[0],
50
+ start_pose = PoseType .current ,
51
+ waypoints = [coord for coord in get_second_note [1 ]],
52
+ end_pose = get_second_note [2 ],
53
+ max_velocity = config .drivetrain_max_vel_auto ,
54
+ max_accel = config .drivetrain_max_accel_auto - 1 ,
55
+ start_velocity = 0 ,
56
+ end_velocity = 0 ,
57
+ rev = True ,
58
+ start_rotation = get_second_note [0 ].get ().rotation ().radians ()
59
+ ),
60
+ theta_f = math .radians (- 180 )
61
+ )
62
+
63
+ path_3 = FollowPathCustom (
64
+ subsystem = Robot .drivetrain ,
65
+ trajectory = CustomTrajectory (
66
+ # start_pose=shoot_second_note[0],
67
+ start_pose = PoseType .current ,
68
+ waypoints = [coord for coord in shoot_second_note [1 ]],
69
+ end_pose = shoot_second_note [2 ],
70
+ max_velocity = config .drivetrain_max_vel_auto ,
71
+ max_accel = config .drivetrain_max_accel_auto - 1 ,
72
+ start_velocity = 0 ,
73
+ end_velocity = 0 ,
74
+ rev = False ,
75
+ start_rotation = shoot_second_note [0 ].get ().rotation ().radians ()
76
+ ),
77
+ theta_f = math .radians (163.5 )
78
+ )
79
+
80
+ path_4 = FollowPathCustom (
81
+ subsystem = Robot .drivetrain ,
82
+ trajectory = CustomTrajectory (
83
+ # start_pose=get_third_note[0],
84
+ start_pose = PoseType .current ,
85
+ waypoints = [coord for coord in get_third_note [1 ]],
86
+ end_pose = get_third_note [2 ],
87
+ max_velocity = config .drivetrain_max_vel_auto ,
88
+ max_accel = config .drivetrain_max_accel_auto - 1 ,
89
+ start_velocity = 0 ,
90
+ end_velocity = 0 ,
91
+ rev = True ,
92
+ start_rotation = get_third_note [0 ].get ().rotation ().radians ()
93
+ ),
94
+ theta_f = math .radians (- 135 )
95
+ )
96
+
97
+ path_5 = FollowPathCustom (
98
+ subsystem = Robot .drivetrain ,
99
+ trajectory = CustomTrajectory (
100
+ # start_pose=shoot_third_note[0],
101
+ start_pose = PoseType .current ,
102
+ waypoints = [coord for coord in shoot_third_note [1 ]],
103
+ end_pose = shoot_third_note [2 ],
104
+ max_velocity = config .drivetrain_max_vel_auto ,
105
+ max_accel = config .drivetrain_max_accel_auto - 1 ,
106
+ start_velocity = 0 ,
107
+ end_velocity = 0 ,
108
+ rev = False ,
109
+ start_rotation = shoot_third_note [0 ].get ().rotation ().radians ()
110
+ ),
111
+ theta_f = math .radians (163.5 )
112
+ )
113
+
114
+ path_far_to_mid = FollowPathCustom (
115
+ subsystem = Robot .drivetrain ,
116
+ trajectory = CustomTrajectory (
117
+ start_pose = far_to_mid [0 ],
118
+ waypoints = [Translation2d (* coord ) for coord in far_to_mid [1 ]],
119
+ end_pose = far_to_mid [2 ],
120
+ max_velocity = 12 ,
121
+ max_accel = 3 ,
122
+ start_velocity = 0 ,
123
+ end_velocity = 0 ,
124
+ rev = False ,
125
+ ),
126
+ period = 0.03 ,
127
+ )
128
+
129
+ path_mid_to_far = FollowPathCustom (
130
+ subsystem = Robot .drivetrain ,
131
+ trajectory = CustomTrajectory (
132
+ start_pose = mid_to_far [0 ],
133
+ waypoints = [coord for coord in mid_to_far [1 ]],
134
+ end_pose = mid_to_far [2 ],
135
+ max_velocity = config .drivetrain_max_vel_auto ,
136
+ max_accel = config .drivetrain_max_accel_auto - 1.5 ,
137
+ start_velocity = 0 ,
138
+ end_velocity = 0 ,
139
+ rev = False
140
+ ),
141
+ )
142
+
143
+ auto = ParallelCommandGroup (
144
+ SetFlywheelShootSpeaker (Robot .flywheel , Field .calculations ),
145
+ SequentialCommandGroup (
146
+ ZeroWrist (Robot .wrist ),
147
+ ZeroElevator (Robot .elevator ),
148
+
149
+ InstantCommand (lambda : Field .odometry .disable ()),
150
+
151
+ ParallelCommandGroup (
152
+ path_1 .raceWith (AimWrist (Robot .wrist , Field .calculations )),
153
+ DeployIntake (Robot .intake ),
154
+ ),
155
+
156
+ # Shoot first note
157
+ InstantCommand (lambda : Field .odometry .enable ()),
158
+ ShootAuto (Robot .drivetrain , Robot .wrist , Robot .flywheel , Field .calculations ),
159
+ InstantCommand (lambda : Field .odometry .disable ()),
160
+
161
+ # Get second note
162
+ PathUntilIntake (path_2 , Robot .wrist , Robot .intake , 1 ),
163
+
164
+ # Go to shot location
165
+ path_3 .raceWith (AimWrist (Robot .wrist , Field .calculations )),
166
+
167
+ # Shoot second note
168
+ InstantCommand (lambda : Field .odometry .enable ()),
169
+ ShootAuto (Robot .drivetrain , Robot .wrist , Robot .flywheel , Field .calculations ),
170
+ InstantCommand (lambda : Field .odometry .disable ()),
171
+
172
+ # Get third note
173
+ PathUntilIntake (path_4 , Robot .wrist , Robot .intake ),
174
+
175
+ # Go to shot location
176
+ path_5 .raceWith (AimWrist (Robot .wrist , Field .calculations )),
177
+
178
+ # Shoot third note
179
+ InstantCommand (lambda : Field .odometry .enable ()),
180
+ ShootAuto (Robot .drivetrain , Robot .wrist , Robot .flywheel , Field .calculations ),
181
+ InstantCommand (lambda : Field .odometry .disable ()),
182
+
183
+ ),
184
+
185
+ # SequentialCommandGroup(
186
+ # InstantCommand(lambda: Field.odometry.disable()),
187
+ # path_1,
188
+ # path_2,
189
+ # path_3,
190
+ # path_4,
191
+ # path_5,
192
+ # )
193
+ # path_far_to_mid,
194
+ # path_mid_to_far
195
+
196
+ )
197
+
198
+ routine = AutoRoutine (Pose2d (* initial ), auto )
0 commit comments