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