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