Convert autonomous_actor to use event loop time
It used to use the global time object, which is wrong. Switch to event
loop time!
Change-Id: Ida5318308ba29375ba0c439c6fc54bb0debd8d2b
diff --git a/aos/actions/actor.h b/aos/actions/actor.h
index fe6e425..b55b336 100644
--- a/aos/actions/actor.h
+++ b/aos/actions/actor.h
@@ -88,6 +88,10 @@
::aos::EventLoop *event_loop() { return event_loop_; }
+ ::aos::monotonic_clock::time_point monotonic_now() {
+ return event_loop_->monotonic_now();
+ }
+
private:
// Checks if an action was initially running when the thread started.
bool CheckInitialRunning();
diff --git a/y2014/actors/autonomous_actor.cc b/y2014/actors/autonomous_actor.cc
index bb38269..76a037c 100644
--- a/y2014/actors/autonomous_actor.cc
+++ b/y2014/actors/autonomous_actor.cc
@@ -249,7 +249,7 @@
static const double kPickupDistance = 0.5;
static const double kTurnAngle = 0.3;
- monotonic_clock::time_point start_time = monotonic_clock::now();
+ const monotonic_clock::time_point start_time = monotonic_now();
LOG(INFO, "Handling auto mode\n");
AutoVersion auto_version;
@@ -285,7 +285,7 @@
// Turn the claw on, keep it straight up until the ball has been grabbed.
LOG(INFO, "Claw going up at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
PositionClawVertically(12.0, 4.0);
SetShotPower(115.0);
@@ -293,7 +293,7 @@
this_thread::sleep_for(chrono::milliseconds(250));
if (ShouldCancel()) return true;
LOG(INFO, "Readying claw for shot at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (ShouldCancel()) return true;
// Drive to the goal.
@@ -331,14 +331,14 @@
hot_goal_decoder.Update();
if (ShouldCancel()) return true;
} while (!hot_goal_decoder.left_triggered() &&
- (monotonic_clock::now() - start_time) < chrono::seconds(9));
+ (monotonic_now() - start_time) < chrono::seconds(9));
} else if (auto_version == AutoVersion::kStraight) {
this_thread::sleep_for(chrono::milliseconds(400));
}
// Shoot.
LOG(INFO, "Shooting at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
Shoot();
this_thread::sleep_for(chrono::milliseconds(50));
@@ -350,7 +350,7 @@
if (ShouldCancel()) return true;
} else if (auto_version == AutoVersion::kSingleHot) {
LOG(INFO, "auto done at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
PositionClawVertically(0.0, 0.0);
return true;
}
@@ -359,21 +359,21 @@
if (ShouldCancel()) return true;
// Intake the new ball.
LOG(INFO, "Claw ready for intake at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
PositionClawBackIntake();
StartDrive(kShootDistance + kPickupDistance, 0.0, drive_params, kFastTurn);
LOG(INFO, "Waiting until drivetrain is finished\n");
WaitForDriveProfileDone();
if (ShouldCancel()) return true;
LOG(INFO, "Wait for the claw at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitUntilClawDone()) return true;
}
// Drive back.
{
LOG(INFO, "Driving back at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(-(kShootDistance + kPickupDistance), 0.0, drive_params,
kFastTurn);
this_thread::sleep_for(chrono::milliseconds(300));
@@ -411,7 +411,7 @@
}
LOG(INFO, "Shooting at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
// Shoot
Shoot();
if (ShouldCancel()) return true;
diff --git a/y2014_bot3/actors/autonomous_actor.cc b/y2014_bot3/actors/autonomous_actor.cc
index fac6d2f..1a25c55 100644
--- a/y2014_bot3/actors/autonomous_actor.cc
+++ b/y2014_bot3/actors/autonomous_actor.cc
@@ -30,7 +30,7 @@
bool AutonomousActor::RunAction(
const ::frc971::autonomous::AutonomousActionParams ¶ms) {
- monotonic_clock::time_point start_time = monotonic_clock::now();
+ const monotonic_clock::time_point start_time = monotonic_now();
LOG(INFO, "Starting autonomous action with mode %" PRId32 "\n", params.mode);
Reset();
@@ -38,10 +38,10 @@
if (!WaitForDriveDone()) return true;
LOG(INFO, "Done %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
- event_loop()->monotonic_now(),
+ monotonic_now(),
::std::chrono::milliseconds(5) / 2);
while (!ShouldCancel()) {
phased_loop.SleepUntilNext();
diff --git a/y2016/actors/autonomous_actor.cc b/y2016/actors/autonomous_actor.cc
index 01650c4..a02362e 100644
--- a/y2016/actors/autonomous_actor.cc
+++ b/y2016/actors/autonomous_actor.cc
@@ -232,9 +232,8 @@
::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
event_loop()->monotonic_now(),
::std::chrono::milliseconds(5) / 2);
- monotonic_clock::time_point end_time =
- monotonic_clock::now() + align_duration;
- while (end_time > monotonic_clock::now()) {
+ const monotonic_clock::time_point end_time = monotonic_now() + align_duration;
+ while (end_time > monotonic_now()) {
if (ShouldCancel()) break;
vision_status_fetcher_.Fetch();
@@ -573,7 +572,7 @@
}
void AutonomousActor::TwoBallAuto() {
- monotonic_clock::time_point start_time = monotonic_clock::now();
+ const monotonic_clock::time_point start_time = monotonic_now();
OpenShooter();
MoveSuperstructure(0.10, -0.010, 0.0, {8.0, 60.0}, {4.0, 10.0}, {10.0, 25.0},
false, 12.0);
@@ -582,7 +581,7 @@
WaitForIntake();
LOG(INFO, "Intake done at %f seconds, starting to drive\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (ShouldCancel()) return;
const double kDriveDistance = 5.05;
StartDrive(-kDriveDistance, 0.0, kTwoBallLowDrive, kSlowTurn);
@@ -597,12 +596,12 @@
const bool ball_detected = ball_detector_fetcher_->voltage > 2.5;
first_ball_there = ball_detected;
LOG(INFO, "Saw the ball: %d at %f\n", first_ball_there,
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
}
MoveSuperstructure(0.10, -0.010, 0.0, {8.0, 40.0}, {4.0, 10.0}, {10.0, 25.0},
false, 0.0);
LOG(INFO, "Shutting off rollers at %f seconds, starting to straighten out\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(0.0, -0.4, kTwoBallLowDrive, kSwerveTurn);
MoveSuperstructure(-0.05, -0.010, 0.0, {8.0, 40.0}, {4.0, 10.0}, {10.0, 25.0},
false, 0.0);
@@ -622,7 +621,7 @@
if (!WaitForDriveDone()) return;
LOG(INFO, "First shot done driving at %f seconds\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
WaitForSuperstructureProfile();
@@ -645,7 +644,7 @@
}
LOG(INFO, "First shot at %f seconds\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (ShouldCancel()) return;
SetShooterSpeed(0.0);
@@ -665,7 +664,7 @@
if (!WaitForDriveNear(0.06, kDoNotTurnCare)) return;
LOG(INFO, "At Low Bar %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
OpenShooter();
constexpr double kSecondBallAfterBarDrive = 2.10;
@@ -683,7 +682,7 @@
false, 12.0);
LOG(INFO, "Done backing up %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
constexpr double kDriveBackDistance = 5.15 - 0.4;
StartDrive(-kDriveBackDistance, 0.0, kTwoBallLowDrive, kFinishTurn);
@@ -692,7 +691,7 @@
StartDrive(0.0, -kBallSmallWallTurn, kTwoBallLowDrive, kFinishTurn);
LOG(INFO, "Straightening up at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
CloseIfBall();
if (!WaitForDriveNear(kDriveBackDistance - 2.3, kDoNotTurnCare)) return;
@@ -703,7 +702,7 @@
if (!ball_detected) {
if (!WaitForDriveDone()) return;
LOG(INFO, "Aborting, no ball %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
return;
}
}
@@ -720,7 +719,7 @@
if (!WaitForDriveDone()) return;
LOG(INFO, "Second shot done driving at %f seconds\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
WaitForSuperstructure();
AlignWithVisionGoal();
if (ShouldCancel()) return;
@@ -731,31 +730,31 @@
// 2.2 with 0.4 of vision.
// 1.8 without any vision.
LOG(INFO, "Going to vision align at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
WaitForAlignedWithVision(
(start_time + chrono::milliseconds(13500) + kVisionExtra * 2) -
- monotonic_clock::now());
+ monotonic_now());
BackLongShotTwoBallFinish();
WaitForSuperstructureProfile();
if (ShouldCancel()) return;
LOG(INFO, "Shoot at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
Shoot();
LOG(INFO, "Second shot at %f seconds\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (ShouldCancel()) return;
SetShooterSpeed(0.0);
LOG(INFO, "Folding superstructure back down\n");
TuckArm(true, false);
LOG(INFO, "Shot %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
WaitForSuperstructureLow();
LOG(INFO, "Done %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
}
void AutonomousActor::StealAndMoveOverBy(double distance) {
@@ -780,7 +779,7 @@
bool AutonomousActor::RunAction(
const ::frc971::autonomous::AutonomousActionParams ¶ms) {
- monotonic_clock::time_point start_time = monotonic_clock::now();
+ monotonic_clock::time_point start_time = monotonic_now();
LOG(INFO, "Starting autonomous action with mode %" PRId32 "\n", params.mode);
InitializeEncoders();
@@ -923,10 +922,10 @@
if (!WaitForDriveDone()) return true;
LOG(INFO, "Done %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
- event_loop()->monotonic_now(),
+ monotonic_now(),
::std::chrono::milliseconds(5) / 2);
while (!ShouldCancel()) {
diff --git a/y2017/actors/autonomous_actor.cc b/y2017/actors/autonomous_actor.cc
index 33c29a8..fa072ac 100644
--- a/y2017/actors/autonomous_actor.cc
+++ b/y2017/actors/autonomous_actor.cc
@@ -48,7 +48,7 @@
bool AutonomousActor::RunAction(
const ::frc971::autonomous::AutonomousActionParams ¶ms) {
- monotonic_clock::time_point start_time = monotonic_clock::now();
+ const monotonic_clock::time_point start_time = monotonic_now();
LOG(INFO, "Starting autonomous action with mode %" PRId32 "\n", params.mode);
Reset();
@@ -106,7 +106,7 @@
SendSuperstructureGoal();
this_thread::sleep_for(start_time + chrono::seconds(15) -
- monotonic_clock::now());
+ monotonic_now());
if (ShouldCancel()) return true;
set_shooter_velocity(0.0);
@@ -180,7 +180,7 @@
SendSuperstructureGoal();
LOG(INFO, "Starting drive back %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(-2.75, kDriveDirection * 1.24, kSlowDrive,
kFirstGearStartTurn);
@@ -203,19 +203,19 @@
StartDrive(0.0, -kDriveDirection * 0.15, kSlowDrive, kSmashTurn);
LOG(INFO, "Starting second shot %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
set_indexer_angular_velocity(-2.15 * M_PI);
SendSuperstructureGoal();
if (!WaitForDriveNear(0.2, 0.1)) return true;
this_thread::sleep_for(start_time + chrono::seconds(11) -
- monotonic_clock::now());
+ monotonic_now());
if (ShouldCancel()) return true;
set_intake_max_velocity(0.05);
set_intake_goal(0.08);
this_thread::sleep_for(start_time + chrono::seconds(15) -
- monotonic_clock::now());
+ monotonic_now());
if (ShouldCancel()) return true;
set_intake_max_velocity(0.50);
@@ -280,10 +280,9 @@
SendSuperstructureGoal();
LOG(INFO, "Started shooting at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
- this_thread::sleep_for(start_time + chrono::seconds(9) -
- monotonic_clock::now());
+ this_thread::sleep_for(start_time + chrono::seconds(9) - monotonic_now());
if (ShouldCancel()) return true;
set_intake_max_velocity(0.05);
@@ -291,7 +290,7 @@
SendSuperstructureGoal();
this_thread::sleep_for(start_time + chrono::seconds(15) -
- monotonic_clock::now());
+ monotonic_now());
if (ShouldCancel()) return true;
set_shooter_velocity(0.0);
@@ -302,7 +301,7 @@
}
LOG(INFO, "Done %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
event_loop()->monotonic_now(),
diff --git a/y2018/actors/autonomous_actor.cc b/y2018/actors/autonomous_actor.cc
index 80cdbe9..18b6789 100644
--- a/y2018/actors/autonomous_actor.cc
+++ b/y2018/actors/autonomous_actor.cc
@@ -59,7 +59,7 @@
bool AutonomousActor::RunAction(
const ::frc971::autonomous::AutonomousActionParams ¶ms) {
- monotonic_clock::time_point start_time = monotonic_clock::now();
+ const monotonic_clock::time_point start_time = monotonic_now();
LOG(INFO, "Starting autonomous action with mode %" PRId32 "\n", params.mode);
Reset();
@@ -112,7 +112,7 @@
*/
LOG(INFO, "Done %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
event_loop()->monotonic_now(),
@@ -170,7 +170,7 @@
if (!WaitForArmTrajectoryClose(0.001)) return true;
LOG(INFO, "Arm close at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::std::this_thread::sleep_for(chrono::milliseconds(1000));
@@ -257,7 +257,7 @@
if (!WaitForDriveProfileNear(kFullDriveLength - (kSecondTurnDistance)))
return true;
LOG(INFO, "Final turn at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(0.0, M_PI / 2.0, kFarScaleFinalTurnDrive, kFarScaleSweepingTurn);
if (!WaitForDriveProfileNear(0.15)) return true;
@@ -265,13 +265,13 @@
StartDrive(0.0, 0.3, kFarScaleFinalTurnDrive, kFarScaleSweepingTurn);
LOG(INFO, "Dropping at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
set_open_claw(true);
SendSuperstructureGoal();
::std::this_thread::sleep_for(chrono::milliseconds(1000));
LOG(INFO, "Backing up at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(1.5, -0.55, kFarScaleFinalTurnDrive, kFarScaleSweepingTurn);
@@ -313,7 +313,7 @@
::std::this_thread::sleep_for(chrono::milliseconds(500));
LOG(INFO, "Dropping second box at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
set_open_claw(true);
SendSuperstructureGoal();
@@ -346,7 +346,7 @@
set_arm_goal_position(arm::UpIndex());
SendSuperstructureGoal();
LOG(INFO, "Lifting arm at %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitForTurnProfileDone()) return true;
StartDrive(0.0, 0.0, kDrive, kTurn);
@@ -379,7 +379,7 @@
if (!WaitForDriveNear(0.2, 0.2)) return true;
set_max_drivetrain_voltage(6.0);
LOG(INFO, "Lowered drivetrain voltage %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::std::this_thread::sleep_for(chrono::milliseconds(300));
set_open_claw(true);
@@ -431,7 +431,7 @@
SendSuperstructureGoal();
set_intake_angle(-0.60);
LOG(INFO, "Dropped first box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::std::this_thread::sleep_for(chrono::milliseconds(700));
@@ -439,7 +439,7 @@
SendSuperstructureGoal();
LOG(INFO, "Starting second box drive %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
constexpr double kSecondBoxSwerveAngle = 0.35;
constexpr double kSecondBoxDrive = 1.38;
StartDrive(kSecondBoxDrive, 0.0, kDrive, kFastTurn);
@@ -466,7 +466,7 @@
SendSuperstructureGoal();
LOG(INFO, "Grabbing second box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::std::this_thread::sleep_for(chrono::milliseconds(200));
StartDrive(-0.04, 0.0, kThirdBoxSlowBackup, kThirdBoxSlowTurn);
@@ -474,7 +474,7 @@
set_max_drivetrain_voltage(12.0);
LOG(INFO, "Got second box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
::std::this_thread::sleep_for(chrono::milliseconds(500));
set_grab_box(false);
@@ -484,7 +484,7 @@
set_disable_box_correct(false);
SendSuperstructureGoal();
LOG(INFO, "Driving to place second box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(-kSecondBoxDrive + 0.16, kSecondBoxSwerveAngle, kDrive, kFastTurn);
if (!WaitForDriveNear(0.4, M_PI / 2.0)) return true;
@@ -494,7 +494,7 @@
kFastTurn);
LOG(INFO, "Starting throw %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitForDriveNear(0.4, M_PI / 2.0)) return true;
if (!WaitForArmTrajectoryClose(0.25)) return true;
SendSuperstructureGoal();
@@ -506,7 +506,7 @@
set_open_claw(true);
set_intake_angle(-M_PI / 4.0);
LOG(INFO, "Releasing second box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
SendSuperstructureGoal();
::std::this_thread::sleep_for(chrono::milliseconds(700));
@@ -514,7 +514,7 @@
SendSuperstructureGoal();
LOG(INFO, "Driving to third box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
StartDrive(kThirdCubeDrive, kSecondBoxEndExtraAngle, kThirdBoxDrive,
kFastTurn);
if (!WaitForDriveNear(kThirdCubeDrive - 0.1, M_PI / 4.0)) return true;
@@ -535,15 +535,15 @@
if (!WaitForDriveProfileDone()) return true;
LOG(INFO, "Waiting for third box %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitForBoxGrabed()) return true;
LOG(INFO, "Third box grabbed %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
const bool too_late =
- monotonic_clock::now() > start_time + chrono::milliseconds(12500);
+ monotonic_now() > start_time + chrono::milliseconds(12500);
if (too_late) {
LOG(INFO, "Third box too long, going up. %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
set_grab_box(false);
set_arm_goal_position(arm::UpIndex());
set_roller_voltage(0.0);
@@ -573,20 +573,20 @@
SendSuperstructureGoal();
LOG(INFO, "Final open %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
}
if (!WaitForDriveProfileDone()) return true;
if (!WaitForTurnProfileDone()) return true;
::std::this_thread::sleep_for(chrono::milliseconds(14750) -
- (monotonic_clock::now() - start_time));
+ (monotonic_now() - start_time));
set_arm_goal_position(arm::UpIndex());
SendSuperstructureGoal();
::std::this_thread::sleep_for(chrono::milliseconds(15000) -
- (monotonic_clock::now() - start_time));
+ (monotonic_now() - start_time));
set_close_claw(true);
SendSuperstructureGoal();
diff --git a/y2019/actors/autonomous_actor.cc b/y2019/actors/autonomous_actor.cc
index 5138123..8408789 100644
--- a/y2019/actors/autonomous_actor.cc
+++ b/y2019/actors/autonomous_actor.cc
@@ -130,7 +130,7 @@
bool AutonomousActor::RunAction(
const ::frc971::autonomous::AutonomousActionParams ¶ms) {
- const monotonic_clock::time_point start_time = monotonic_clock::now();
+ const monotonic_clock::time_point start_time = monotonic_now();
const bool is_left = params.mode == 0;
{
@@ -258,7 +258,7 @@
set_suction_goal(false, 1);
SendSuperstructureGoal();
LOG(INFO, "Dropping disc 1 %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitForDriveYCloseToZero(1.13)) return true;
if (!WaitForMilliseconds(::std::chrono::milliseconds(300))) return true;
@@ -284,7 +284,7 @@
// As soon as we pick up Panel 2 go score on the rocket
if (!WaitForGamePiece()) return true;
LOG(INFO, "Got gamepiece %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
LineFollowAtVelocity(-4.0);
SplineHandle spline3 =
PlanSpline(AutonomousSplines::HPToThirdCargoShipBay(is_left),
@@ -301,18 +301,18 @@
// Line follow in to the second disc.
LineFollowAtVelocity(-0.7, 3);
LOG(INFO, "Drawing in disc 2 %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitForDriveYCloseToZero(1.2)) return true;
set_suction_goal(false, 1);
SendSuperstructureGoal();
LOG(INFO, "Dropping disc 2 %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
if (!WaitForDriveYCloseToZero(1.13)) return true;
if (!WaitForMilliseconds(::std::chrono::milliseconds(200))) return true;
LOG(INFO, "Backing up %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
LineFollowAtVelocity(0.9, 3);
if (!WaitForMilliseconds(::std::chrono::milliseconds(400))) return true;
} else {
@@ -354,7 +354,7 @@
}
LOG(INFO, "Done %f\n",
- ::aos::time::DurationInSeconds(monotonic_clock::now() - start_time));
+ ::aos::time::DurationInSeconds(monotonic_now() - start_time));
return true;
}
diff --git a/y2019/actors/autonomous_actor.h b/y2019/actors/autonomous_actor.h
index 1992543..edb2272 100644
--- a/y2019/actors/autonomous_actor.h
+++ b/y2019/actors/autonomous_actor.h
@@ -124,10 +124,9 @@
}
bool WaitForMilliseconds(std::chrono::milliseconds wait) {
- ::aos::monotonic_clock::time_point end_time =
- ::aos::monotonic_clock::now() + wait;
+ ::aos::monotonic_clock::time_point end_time = monotonic_now() + wait;
- while (::aos::monotonic_clock::now() < end_time) {
+ while (monotonic_now() < end_time) {
if (ShouldCancel()) {
return false;
}