Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 1 | #include "y2017/actors/autonomous_actor.h" |
| 2 | |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 3 | #include <chrono> |
Tyler Chatow | bf0609c | 2021-07-31 16:13:27 -0700 | [diff] [blame] | 4 | #include <cinttypes> |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 5 | #include <cmath> |
| 6 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 7 | #include "aos/logging/logging.h" |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 8 | #include "aos/util/phased_loop.h" |
Philipp Schrader | 996a2a2 | 2017-02-22 05:02:48 +0000 | [diff] [blame] | 9 | #include "y2017/control_loops/drivetrain/drivetrain_base.h" |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 10 | |
| 11 | namespace y2017 { |
| 12 | namespace actors { |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 13 | using ::aos::monotonic_clock; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 14 | using ::frc971::ProfileParametersT; |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 15 | namespace chrono = ::std::chrono; |
| 16 | namespace this_thread = ::std::this_thread; |
| 17 | |
| 18 | namespace { |
Philipp Schrader | 85fca55 | 2017-03-05 00:30:50 +0000 | [diff] [blame] | 19 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 20 | ProfileParametersT MakeProfileParameters(float max_velocity, |
| 21 | float max_acceleration) { |
| 22 | ProfileParametersT result; |
| 23 | result.max_velocity = max_velocity; |
| 24 | result.max_acceleration = max_acceleration; |
| 25 | return result; |
| 26 | } |
| 27 | |
| 28 | const ProfileParametersT kGearBallBackDrive = MakeProfileParameters(3.0, 3.5); |
| 29 | const ProfileParametersT kGearDrive = MakeProfileParameters(1.5, 2.0); |
| 30 | const ProfileParametersT kGearFastDrive = MakeProfileParameters(2.0, 2.5); |
| 31 | const ProfileParametersT kGearSlowDrive = MakeProfileParameters(1.0, 2.0); |
| 32 | const ProfileParametersT kGearPlaceDrive = MakeProfileParameters(0.40, 2.0); |
| 33 | const ProfileParametersT kSlowDrive = MakeProfileParameters(3.0, 2.0); |
| 34 | const ProfileParametersT kSlowTurn = MakeProfileParameters(3.0, 3.0); |
| 35 | const ProfileParametersT kFirstTurn = MakeProfileParameters(1.0, 1.5); |
| 36 | const ProfileParametersT kFirstGearStartTurn = MakeProfileParameters(2.0, 3.0); |
| 37 | const ProfileParametersT kFirstGearTurn = MakeProfileParameters(2.0, 5.0); |
| 38 | const ProfileParametersT kSecondGearTurn = MakeProfileParameters(3.0, 5.0); |
| 39 | const ProfileParametersT kSmashTurn = MakeProfileParameters(1.5, 5.0); |
Philipp Schrader | 85fca55 | 2017-03-05 00:30:50 +0000 | [diff] [blame] | 40 | |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 41 | } // namespace |
| 42 | |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 43 | AutonomousActor::AutonomousActor(::aos::EventLoop *event_loop) |
Philipp Schrader | 996a2a2 | 2017-02-22 05:02:48 +0000 | [diff] [blame] | 44 | : frc971::autonomous::BaseAutonomousActor( |
Austin Schuh | 402722c | 2019-06-29 21:27:06 -0700 | [diff] [blame] | 45 | event_loop, control_loops::drivetrain::GetDrivetrainConfig()), |
| 46 | superstructure_status_fetcher_( |
Austin Schuh | 402722c | 2019-06-29 21:27:06 -0700 | [diff] [blame] | 47 | event_loop |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 48 | ->MakeFetcher<::y2017::control_loops::superstructure::Status>( |
| 49 | "/superstructure")), |
| 50 | superstructure_goal_sender_( |
| 51 | event_loop->MakeSender<::y2017::control_loops::superstructure::Goal>( |
| 52 | "/superstructure")) {} |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 53 | |
Philipp Schrader | 996a2a2 | 2017-02-22 05:02:48 +0000 | [diff] [blame] | 54 | bool AutonomousActor::RunAction( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 55 | const ::frc971::autonomous::AutonomousActionParams *params) { |
Austin Schuh | 77ed543 | 2019-07-07 20:41:36 -0700 | [diff] [blame] | 56 | const monotonic_clock::time_point start_time = monotonic_now(); |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 57 | AOS_LOG(INFO, "Starting autonomous action with mode %" PRId32 "\n", |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 58 | params->mode()); |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 59 | Reset(); |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 60 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 61 | switch (params->mode()) { |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 62 | case 503: { |
| 63 | // Middle gear auto. |
| 64 | // Red is positive. |
| 65 | // Line up on boiler side edge. |
| 66 | constexpr double kDriveDirection = 1.0; |
| 67 | |
| 68 | set_intake_goal(0.18); |
| 69 | set_turret_goal(0.0); |
| 70 | SendSuperstructureGoal(); |
| 71 | |
| 72 | set_turret_goal(-M_PI / 4.0 * kDriveDirection); |
| 73 | SendSuperstructureGoal(); |
| 74 | |
| 75 | // Turn towards the peg. |
| 76 | StartDrive(0.0, kDriveDirection * 0.162, kGearDrive, kSlowTurn); |
| 77 | if (!WaitForDriveNear(100.0, 0.02)) return true; |
| 78 | if (!WaitForTurnProfileDone()) return true; |
| 79 | |
| 80 | // Drive, but get within 0.3 meters |
| 81 | StartDrive(1.73, 0.0, kGearFastDrive, kSlowTurn); |
| 82 | if (!WaitForDriveNear(0.3, 0.0)) return true; |
| 83 | |
| 84 | // Now, add a slow, short move to actually place the gear. |
| 85 | StartDrive(0.18, 0.0, kGearPlaceDrive, kSecondGearTurn); |
| 86 | if (!WaitForDriveNear(0.07, 0.0)) return true; |
| 87 | |
| 88 | set_gear_servo(0.3); |
| 89 | SendSuperstructureGoal(); |
| 90 | |
| 91 | // Slow down and then pause to let Chris pull the gear off. |
| 92 | this_thread::sleep_for(chrono::milliseconds(1000)); |
| 93 | |
| 94 | // Back up |
| 95 | StartDrive(-1.00, 0.0, kGearFastDrive, kSlowTurn); |
| 96 | if (!WaitForDriveNear(0.1, 0.1)) return true; |
| 97 | |
| 98 | // Turn towards the boiler. |
| 99 | StartDrive(0.0, -kDriveDirection * M_PI / 2.0, kGearFastDrive, kSlowTurn); |
| 100 | if (!WaitForDriveNear(0.1, 0.1)) return true; |
| 101 | |
| 102 | // Drive up near it. |
| 103 | StartDrive(1.8, 0.0, kGearFastDrive, kSlowTurn); |
| 104 | if (!WaitForDriveNear(0.1, 0.1)) return true; |
| 105 | |
| 106 | set_hood_goal(0.37); |
| 107 | set_intake_goal(0.23); |
| 108 | set_shooter_velocity(353.0); |
| 109 | set_vision_track(true); |
| 110 | set_use_vision_for_shots(true); |
| 111 | set_indexer_angular_velocity(-1.1 * M_PI); |
| 112 | SendSuperstructureGoal(); |
| 113 | |
| 114 | this_thread::sleep_for(start_time + chrono::seconds(15) - |
Austin Schuh | 77ed543 | 2019-07-07 20:41:36 -0700 | [diff] [blame] | 115 | monotonic_now()); |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 116 | if (ShouldCancel()) return true; |
| 117 | |
| 118 | set_shooter_velocity(0.0); |
| 119 | set_indexer_angular_velocity(0.0); |
| 120 | SendSuperstructureGoal(); |
| 121 | |
| 122 | } break; |
| 123 | |
| 124 | case 500: { |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 125 | // Red is positive. |
| 126 | constexpr double kDriveDirection = -1.0; |
| 127 | // Side peg + hopper auto. |
| 128 | |
| 129 | set_intake_goal(0.23); |
| 130 | set_turret_goal(-M_PI * kDriveDirection); |
| 131 | SendSuperstructureGoal(); |
| 132 | |
| 133 | constexpr double kLongPegDrive = 3.025; |
| 134 | |
| 135 | StartDrive(kLongPegDrive, -kDriveDirection * M_PI / 4, kGearDrive, |
| 136 | kFirstGearStartTurn); |
| 137 | if (!WaitForDriveNear(100.0, M_PI / 8.0)) return true; |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 138 | AOS_LOG(INFO, "Turn Middle: %f left to go\n", DriveDistanceLeft()); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 139 | |
| 140 | StartDrive(0.0, 0.0, kGearDrive, kFirstGearTurn); |
| 141 | |
| 142 | if (!WaitForTurnProfileDone()) return true; |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 143 | AOS_LOG(INFO, "Turn profile ended: %f left to go\n", DriveDistanceLeft()); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 144 | |
| 145 | set_hood_goal(0.43); |
| 146 | set_shooter_velocity(364.0); |
| 147 | SendSuperstructureGoal(); |
| 148 | |
| 149 | constexpr double kTurnDistanceFromStart = 1.08; |
| 150 | if (!WaitForDriveNear(kLongPegDrive - kTurnDistanceFromStart, 10.0)) { |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | StartDrive(0.0, kDriveDirection * (M_PI / 4 + 0.3), kGearSlowDrive, |
| 155 | kSecondGearTurn); |
| 156 | if (!WaitForTurnProfileDone()) return true; |
| 157 | |
| 158 | StartDrive(0.0, 0.0, kGearFastDrive, kSecondGearTurn); |
| 159 | |
| 160 | if (!WaitForDriveNear(0.3, 0.0)) return true; |
| 161 | |
| 162 | set_vision_track(true); |
| 163 | SendSuperstructureGoal(); |
| 164 | |
| 165 | StartDrive(0.19, 0.0, kGearPlaceDrive, kSecondGearTurn); |
| 166 | |
| 167 | if (!WaitForDriveNear(0.07, 0.0)) return true; |
| 168 | set_gear_servo(0.3); |
| 169 | SendSuperstructureGoal(); |
| 170 | |
| 171 | // Shoot from the peg. |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 172 | // set_indexer_angular_velocity(-2.1 * M_PI); |
| 173 | // SendSuperstructureGoal(); |
| 174 | // this_thread::sleep_for(chrono::milliseconds(1750)); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 175 | |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 176 | // this_thread::sleep_for(chrono::milliseconds(500)); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 177 | this_thread::sleep_for(chrono::milliseconds(750)); |
| 178 | set_indexer_angular_velocity(0.0); |
| 179 | set_vision_track(false); |
| 180 | set_turret_goal(0.0); |
| 181 | |
| 182 | set_hood_goal(0.37); |
| 183 | set_shooter_velocity(351.0); |
| 184 | set_intake_goal(0.18); |
| 185 | set_gear_servo(0.4); |
| 186 | |
| 187 | SendSuperstructureGoal(); |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 188 | AOS_LOG(INFO, "Starting drive back %f\n", |
| 189 | ::aos::time::DurationInSeconds(monotonic_now() - start_time)); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 190 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 191 | StartDrive(-2.75, kDriveDirection * 1.24, kSlowDrive, |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 192 | kFirstGearStartTurn); |
| 193 | if (!WaitForDriveNear(2.4, 0.0)) return true; |
| 194 | |
| 195 | if (!WaitForTurnProfileDone()) return true; |
| 196 | StartDrive(0.0, 0.0, kGearBallBackDrive, kFirstGearStartTurn); |
| 197 | |
| 198 | if (!WaitForDriveNear(0.2, 0.0)) return true; |
| 199 | this_thread::sleep_for(chrono::milliseconds(200)); |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 200 | // Trip the hopper |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 201 | StartDrive(0.0, kDriveDirection * 1.10, kSlowDrive, kSmashTurn); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 202 | |
| 203 | if (!WaitForDriveNear(0.2, 0.35)) return true; |
| 204 | set_vision_track(true); |
| 205 | set_use_vision_for_shots(true); |
| 206 | SendSuperstructureGoal(); |
| 207 | |
| 208 | if (!WaitForDriveNear(0.2, 0.2)) return true; |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 209 | StartDrive(0.0, -kDriveDirection * 0.15, kSlowDrive, kSmashTurn); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 210 | |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 211 | AOS_LOG(INFO, "Starting second shot %f\n", |
| 212 | ::aos::time::DurationInSeconds(monotonic_now() - start_time)); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 213 | set_indexer_angular_velocity(-2.15 * M_PI); |
| 214 | SendSuperstructureGoal(); |
| 215 | if (!WaitForDriveNear(0.2, 0.1)) return true; |
| 216 | |
| 217 | this_thread::sleep_for(start_time + chrono::seconds(11) - |
Austin Schuh | 77ed543 | 2019-07-07 20:41:36 -0700 | [diff] [blame] | 218 | monotonic_now()); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 219 | if (ShouldCancel()) return true; |
| 220 | set_intake_max_velocity(0.05); |
| 221 | set_intake_goal(0.08); |
| 222 | |
| 223 | this_thread::sleep_for(start_time + chrono::seconds(15) - |
Austin Schuh | 77ed543 | 2019-07-07 20:41:36 -0700 | [diff] [blame] | 224 | monotonic_now()); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 225 | if (ShouldCancel()) return true; |
| 226 | |
| 227 | set_intake_max_velocity(0.50); |
| 228 | set_intake_goal(0.18); |
| 229 | set_shooter_velocity(0.0); |
| 230 | set_indexer_angular_velocity(0.0); |
| 231 | SendSuperstructureGoal(); |
| 232 | |
| 233 | } break; |
| 234 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 235 | default: { |
| 236 | // hopper auto |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 237 | // Red is positive. |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 238 | constexpr double kDriveDirection = 1.0; |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 239 | set_intake_goal(0.07); |
| 240 | SendSuperstructureGoal(); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 241 | |
James Kuszmaul | 651fc3f | 2019-05-15 21:14:25 -0700 | [diff] [blame] | 242 | StartDrive(-3.42, kDriveDirection * (M_PI / 10 - 0.057), kSlowDrive, |
| 243 | kFirstTurn); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 244 | if (!WaitForDriveNear(3.30, 0.0)) return true; |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 245 | AOS_LOG(INFO, "Turn ended: %f left to go\n", DriveDistanceLeft()); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 246 | // We can go to 2.50 before we hit the previous profile. |
| 247 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 248 | if (!WaitForDriveNear(2.48, 0.0)) return true; |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 249 | AOS_LOG(INFO, "%f left to go\n", DriveDistanceLeft()); |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 250 | |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 251 | set_intake_goal(0.23); |
Austin Schuh | 76af51e | 2017-04-09 18:32:38 -0700 | [diff] [blame] | 252 | set_turret_goal(0.0); |
| 253 | // Values good for blue: |
| 254 | // TODO(austin): Drive these off the auto switch. |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 255 | |
| 256 | set_hood_goal(0.37); |
| 257 | set_shooter_velocity(353.0); |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 258 | SendSuperstructureGoal(); |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 259 | |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 260 | StartDrive(0.0, -M_PI / 8.0 * kDriveDirection, kSlowDrive, kSlowTurn); |
| 261 | if (!WaitForDriveNear(0.20, 0.0)) return true; |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 262 | |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 263 | this_thread::sleep_for(chrono::milliseconds(300)); |
| 264 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 265 | // Turn to trigger the hopper. |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 266 | StartDrive(0.0, (M_PI / 8.0 + 0.20) * kDriveDirection, kSlowDrive, |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 267 | kSmashTurn); |
| 268 | if (!WaitForDriveNear(0.05, 0.2)) return true; |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 269 | |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 270 | set_vision_track(true); |
Austin Schuh | 10475d7 | 2017-04-16 19:17:48 -0700 | [diff] [blame] | 271 | set_use_vision_for_shots(true); |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 272 | SendSuperstructureGoal(); |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 273 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 274 | // Now that everything is tracking, wait for the hood to zero before |
| 275 | // trying to shoot. |
| 276 | WaitForHoodZeroed(); |
| 277 | if (ShouldCancel()) return true; |
| 278 | |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 279 | this_thread::sleep_for(chrono::milliseconds(200)); |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 280 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 281 | // Turn back. |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 282 | StartDrive(0.0, (-0.15) * kDriveDirection, kSlowDrive, kSlowTurn); |
| 283 | if (!WaitForDriveNear(0.05, 0.02)) return true; |
Austin Schuh | 76af51e | 2017-04-09 18:32:38 -0700 | [diff] [blame] | 284 | |
Austin Schuh | 19e15d7 | 2017-06-24 13:34:47 -0700 | [diff] [blame] | 285 | set_indexer_angular_velocity(-2.1 * M_PI); |
| 286 | SendSuperstructureGoal(); |
| 287 | |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 288 | AOS_LOG(INFO, "Started shooting at %f\n", |
| 289 | ::aos::time::DurationInSeconds(monotonic_now() - start_time)); |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 290 | |
Austin Schuh | 77ed543 | 2019-07-07 20:41:36 -0700 | [diff] [blame] | 291 | this_thread::sleep_for(start_time + chrono::seconds(9) - monotonic_now()); |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 292 | if (ShouldCancel()) return true; |
Austin Schuh | 366f7ed | 2017-03-11 21:57:14 -0800 | [diff] [blame] | 293 | |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 294 | set_intake_max_velocity(0.05); |
| 295 | set_intake_goal(0.08); |
| 296 | SendSuperstructureGoal(); |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 297 | |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 298 | this_thread::sleep_for(start_time + chrono::seconds(15) - |
Austin Schuh | 77ed543 | 2019-07-07 20:41:36 -0700 | [diff] [blame] | 299 | monotonic_now()); |
Austin Schuh | 624088a | 2017-03-22 22:36:16 -0700 | [diff] [blame] | 300 | if (ShouldCancel()) return true; |
| 301 | |
| 302 | set_shooter_velocity(0.0); |
| 303 | set_indexer_angular_velocity(0.0); |
| 304 | SendSuperstructureGoal(); |
| 305 | |
| 306 | } break; |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 307 | } |
| 308 | |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 309 | AOS_LOG(INFO, "Done %f\n", |
| 310 | ::aos::time::DurationInSeconds(monotonic_now() - start_time)); |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 311 | |
Yash Chainani | a6fe97b | 2021-12-15 21:01:11 -0800 | [diff] [blame] | 312 | ::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency, |
Austin Schuh | d32b362 | 2019-06-23 18:49:06 -0700 | [diff] [blame] | 313 | event_loop()->monotonic_now(), |
Yash Chainani | a6fe97b | 2021-12-15 21:01:11 -0800 | [diff] [blame] | 314 | ActorBase::kLoopOffset); |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 315 | |
| 316 | while (!ShouldCancel()) { |
| 317 | phased_loop.SleepUntilNext(); |
| 318 | } |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 319 | AOS_LOG(DEBUG, "Done running\n"); |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 320 | |
| 321 | return true; |
| 322 | } |
| 323 | |
Tyler Chatow | f31da68 | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 324 | } // namespace actors |
| 325 | } // namespace y2017 |