Upgraded the rest of Time.
Change-Id: I0ee083837e51d8f74a798b7ba14a3b6bb3859f35
diff --git a/y2014/actors/drivetrain_actor.cc b/y2014/actors/drivetrain_actor.cc
index c0ee47b..7ab4f3d 100644
--- a/y2014/actors/drivetrain_actor.cc
+++ b/y2014/actors/drivetrain_actor.cc
@@ -50,8 +50,10 @@
turn_profile.set_maximum_velocity(params.maximum_turn_velocity *
control_loops::drivetrain::kRobotRadius);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
- ::aos::time::PhasedLoopXMS(5, 2500);
+ phased_loop.SleepUntilNext();
::frc971::control_loops::drivetrain_queue.status.FetchLatest();
if (::frc971::control_loops::drivetrain_queue.status.get()) {
diff --git a/y2014/actors/drivetrain_actor_main.cc b/y2014/actors/drivetrain_actor_main.cc
index 4cc0070..4ecd1ab 100644
--- a/y2014/actors/drivetrain_actor_main.cc
+++ b/y2014/actors/drivetrain_actor_main.cc
@@ -4,8 +4,6 @@
#include "y2014/actors/drivetrain_action.q.h"
#include "y2014/actors/drivetrain_actor.h"
-using ::aos::time::Time;
-
int main(int /*argc*/, char * /*argv*/[]) {
::aos::Init(-1);
diff --git a/y2014/actors/shoot_actor_main.cc b/y2014/actors/shoot_actor_main.cc
index 1d33404..96fd8ea 100644
--- a/y2014/actors/shoot_actor_main.cc
+++ b/y2014/actors/shoot_actor_main.cc
@@ -4,8 +4,6 @@
#include "y2014/actors/shoot_action.q.h"
#include "y2014/actors/shoot_actor.h"
-using ::aos::time::Time;
-
int main(int /*argc*/, char * /*argv*/[]) {
::aos::Init(-1);
diff --git a/y2014/autonomous/auto.cc b/y2014/autonomous/auto.cc
index 5860407..e7f7697 100644
--- a/y2014/autonomous/auto.cc
+++ b/y2014/autonomous/auto.cc
@@ -1,5 +1,6 @@
#include <stdio.h>
+#include <chrono>
#include <memory>
#include "aos/common/util/phased_loop.h"
@@ -22,12 +23,20 @@
#include "y2014/queues/hot_goal.q.h"
#include "y2014/queues/profile_params.q.h"
-using ::aos::time::Time;
-
namespace y2014 {
namespace autonomous {
+namespace chrono = ::std::chrono;
+namespace this_thread = ::std::this_thread;
+using ::aos::monotonic_clock;
-namespace time = ::aos::time;
+namespace {
+
+double DoubleSeconds(monotonic_clock::duration duration) {
+ return ::std::chrono::duration_cast<::std::chrono::duration<double>>(duration)
+ .count();
+}
+
+} // namespace
static double left_initial_position, right_initial_position;
@@ -73,9 +82,11 @@
LOG(ERROR, "No action, not waiting\n");
return;
}
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(10),
+ ::std::chrono::milliseconds(10) / 2);
while (true) {
// Poll the running bit and auto done bits.
- ::aos::time::PhasedLoopXMS(10, 5000);
+ phased_loop.SleepUntilNext();
if (!action->Running() || ShouldExitAuto()) {
return;
}
@@ -221,8 +232,10 @@
void WaitUntilClawDone() {
while (true) {
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(10),
+ ::std::chrono::milliseconds(10) / 2);
// Poll the running bit and auto done bits.
- ::aos::time::PhasedLoopXMS(10, 5000);
+ phased_loop.SleepUntilNext();
control_loops::claw_queue.status.FetchLatest();
control_loops::claw_queue.goal.FetchLatest();
if (ShouldExitAuto()) {
@@ -345,7 +358,7 @@
static const double kPickupDistance = 0.5;
static const double kTurnAngle = 0.3;
- ::aos::time::Time start_time = ::aos::time::Time::Now();
+ monotonic_clock::time_point start_time = monotonic_clock::now();
LOG(INFO, "Handling auto mode\n");
AutoVersion auto_version;
@@ -380,27 +393,27 @@
ResetDrivetrain();
- time::SleepFor(time::Time::InSeconds(0.1));
+ this_thread::sleep_for(chrono::milliseconds(100));
if (ShouldExitAuto()) return;
InitializeEncoders();
// Turn the claw on, keep it straight up until the ball has been grabbed.
LOG(INFO, "Claw going up at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
PositionClawVertically(12.0, 4.0);
SetShotPower(115.0);
// Wait for the ball to enter the claw.
- time::SleepFor(time::Time::InSeconds(0.25));
+ this_thread::sleep_for(chrono::milliseconds(250));
if (ShouldExitAuto()) return;
LOG(INFO, "Readying claw for shot at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
{
if (ShouldExitAuto()) return;
// Drive to the goal.
auto drivetrain_action = SetDriveGoal(-kShootDistance, drive_params);
- time::SleepFor(time::Time::InSeconds(0.75));
+ this_thread::sleep_for(chrono::milliseconds(750));
PositionClawForShot();
LOG(INFO, "Waiting until drivetrain is finished\n");
WaitUntilDoneOrCanceled(::std::move(drivetrain_action));
@@ -430,21 +443,20 @@
} else if (auto_version == AutoVersion::kSingleHot) {
do {
// TODO(brians): Wait for next message with timeout or something.
- ::aos::time::SleepFor(::aos::time::Time::InSeconds(0.003));
+ this_thread::sleep_for(chrono::milliseconds(3));
hot_goal_decoder.Update(false);
if (ShouldExitAuto()) return;
} while (!hot_goal_decoder.left_triggered() &&
- (::aos::time::Time::Now() - start_time) <
- ::aos::time::Time::InSeconds(9));
+ (monotonic_clock::now() - start_time) < chrono::seconds(9));
} else if (auto_version == AutoVersion::kStraight) {
- time::SleepFor(time::Time::InSeconds(0.4));
+ this_thread::sleep_for(chrono::milliseconds(400));
}
// Shoot.
LOG(INFO, "Shooting at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
Shoot();
- time::SleepFor(time::Time::InSeconds(0.05));
+ this_thread::sleep_for(chrono::milliseconds(50));
if (auto_version == AutoVersion::kDoubleHot) {
if (ShouldExitAuto()) return;
@@ -454,7 +466,7 @@
if (ShouldExitAuto()) return;
} else if (auto_version == AutoVersion::kSingleHot) {
LOG(INFO, "auto done at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
PositionClawVertically(0.0, 0.0);
return;
}
@@ -463,7 +475,7 @@
if (ShouldExitAuto()) return;
// Intake the new ball.
LOG(INFO, "Claw ready for intake at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
PositionClawBackIntake();
auto drivetrain_action =
SetDriveGoal(kShootDistance + kPickupDistance, drive_params);
@@ -471,7 +483,7 @@
WaitUntilDoneOrCanceled(::std::move(drivetrain_action));
if (ShouldExitAuto()) return;
LOG(INFO, "Wait for the claw at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
WaitUntilClawDone();
if (ShouldExitAuto()) return;
}
@@ -479,10 +491,10 @@
// Drive back.
{
LOG(INFO, "Driving back at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
auto drivetrain_action =
SetDriveGoal(-(kShootDistance + kPickupDistance), drive_params);
- time::SleepFor(time::Time::InSeconds(0.3));
+ this_thread::sleep_for(chrono::milliseconds(300));
hot_goal_decoder.ResetCounts();
if (ShouldExitAuto()) return;
PositionClawUpClosed();
@@ -515,17 +527,17 @@
WaitUntilDoneOrCanceled(::std::move(drivetrain_action));
if (ShouldExitAuto()) return;
} else if (auto_version == AutoVersion::kStraight) {
- time::SleepFor(time::Time::InSeconds(0.4));
+ this_thread::sleep_for(chrono::milliseconds(400));
}
LOG(INFO, "Shooting at %f\n",
- (::aos::time::Time::Now() - start_time).ToSeconds());
+ DoubleSeconds(monotonic_clock::now() - start_time));
// Shoot
Shoot();
if (ShouldExitAuto()) return;
// Get ready to zero when we come back up.
- time::SleepFor(time::Time::InSeconds(0.05));
+ this_thread::sleep_for(chrono::milliseconds(50));
PositionClawVertically(0.0, 0.0);
}
diff --git a/y2014/autonomous/auto_main.cc b/y2014/autonomous/auto_main.cc
index bf3acf8..747747a 100644
--- a/y2014/autonomous/auto_main.cc
+++ b/y2014/autonomous/auto_main.cc
@@ -6,8 +6,6 @@
#include "frc971/autonomous/auto.q.h"
#include "y2014/autonomous/auto.h"
-using ::aos::time::Time;
-
int main(int /*argc*/, char * /*argv*/[]) {
::aos::Init(-1);
@@ -24,12 +22,15 @@
LOG(INFO, "Got another auto packet\n");
}
LOG(INFO, "Starting auto mode\n");
- ::aos::time::Time start_time = ::aos::time::Time::Now();
+ ::aos::monotonic_clock::time_point start_time =
+ ::aos::monotonic_clock::now();
::y2014::autonomous::HandleAuto();
- ::aos::time::Time elapsed_time = ::aos::time::Time::Now() - start_time;
+ auto elapsed_time = ::aos::monotonic_clock::now() - start_time;
LOG(INFO, "Auto mode exited in %f, waiting for it to finish.\n",
- elapsed_time.ToSeconds());
+ ::std::chrono::duration_cast<::std::chrono::duration<double>>(
+ elapsed_time)
+ .count());
while (::frc971::autonomous::autonomous->run_auto) {
::frc971::autonomous::autonomous.FetchNextBlocking();
LOG(INFO, "Got another auto packet\n");
diff --git a/y2014/control_loops/claw/claw_lib_test.cc b/y2014/control_loops/claw/claw_lib_test.cc
index 8a92bce..4079da4 100644
--- a/y2014/control_loops/claw/claw_lib_test.cc
+++ b/y2014/control_loops/claw/claw_lib_test.cc
@@ -1,17 +1,15 @@
#include <unistd.h>
+#include <chrono>
#include <memory>
-#include "aos/common/network/team_number.h"
#include "aos/common/controls/control_loop_test.h"
-
-#include "y2014/control_loops/claw/claw.q.h"
-#include "y2014/control_loops/claw/claw.h"
-#include "y2014/constants.h"
-#include "y2014/control_loops/claw/claw_motor_plant.h"
-
+#include "aos/common/network/team_number.h"
#include "gtest/gtest.h"
-
+#include "y2014/constants.h"
+#include "y2014/control_loops/claw/claw.h"
+#include "y2014/control_loops/claw/claw.q.h"
+#include "y2014/control_loops/claw/claw_motor_plant.h"
namespace y2014 {
namespace control_loops {
@@ -20,6 +18,8 @@
using ::y2014::control_loops::claw::MakeClawPlant;
using ::frc971::HallEffectStruct;
using ::y2014::control_loops::HalfClawPosition;
+using ::aos::monotonic_clock;
+namespace chrono = ::std::chrono;
typedef enum {
TOP_CLAW = 0,
@@ -288,7 +288,8 @@
.bottom_angle(::std::nan(""))
.separation_angle(::std::nan(""))
.Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(5))) {
claw_motor_plant_.SendPositionMessage();
claw_motor_.Iterate();
claw_motor_plant_.Simulate();
@@ -302,7 +303,8 @@
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(5))) {
claw_motor_plant_.SendPositionMessage();
claw_motor_.Iterate();
claw_motor_plant_.Simulate();
@@ -400,7 +402,8 @@
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(7)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(7))) {
claw_motor_plant_.SendPositionMessage();
claw_motor_.Iterate();
claw_motor_plant_.Simulate();
@@ -511,15 +514,17 @@
class WindupClawTest : public ClawTest {
protected:
- void TestWindup(ClawMotor::CalibrationMode mode, ::aos::time::Time start_time, double offset) {
+ void TestWindup(ClawMotor::CalibrationMode mode,
+ monotonic_clock::time_point start_time, double offset) {
int capped_count = 0;
const constants::Values& values = constants::GetValues();
bool kicked = false;
bool measured = false;
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(7)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(7))) {
claw_motor_plant_.SendPositionMessage();
- if (::aos::time::Time::Now() >= start_time &&
- mode == claw_motor_.mode() && !kicked) {
+ if (monotonic_clock::now() >= start_time && mode == claw_motor_.mode() &&
+ !kicked) {
EXPECT_EQ(mode, claw_motor_.mode());
// Move the zeroing position far away and verify that it gets moved
// back.
@@ -578,8 +583,8 @@
.separation_angle(0.2)
.Send();
- TestWindup(ClawMotor::UNKNOWN_LOCATION, ::aos::time::Time::InSeconds(1.0),
- 971.0);
+ TestWindup(ClawMotor::UNKNOWN_LOCATION,
+ monotonic_clock::time_point(chrono::seconds(1)), 971.0);
VerifyNearGoal();
}
@@ -592,8 +597,8 @@
.separation_angle(0.2)
.Send();
- TestWindup(ClawMotor::UNKNOWN_LOCATION, ::aos::time::Time::InSeconds(1.0),
- -971.0);
+ TestWindup(ClawMotor::UNKNOWN_LOCATION,
+ monotonic_clock::time_point(chrono::seconds(1)), -971.0);
VerifyNearGoal();
}
@@ -606,8 +611,8 @@
.separation_angle(0.2)
.Send();
- TestWindup(ClawMotor::FINE_TUNE_BOTTOM, ::aos::time::Time::InSeconds(2.0),
- -971.0);
+ TestWindup(ClawMotor::FINE_TUNE_BOTTOM,
+ monotonic_clock::time_point(chrono::seconds(2)), -971.0);
VerifyNearGoal();
}
diff --git a/y2014/control_loops/shooter/shooter_lib_test.cc b/y2014/control_loops/shooter/shooter_lib_test.cc
index e1efc1c..9248725 100644
--- a/y2014/control_loops/shooter/shooter_lib_test.cc
+++ b/y2014/control_loops/shooter/shooter_lib_test.cc
@@ -11,9 +11,8 @@
#include "y2014/control_loops/shooter/unaugmented_shooter_motor_plant.h"
#include "y2014/constants.h"
-using ::aos::time::Time;
-
namespace chrono = ::std::chrono;
+using ::aos::monotonic_clock;
namespace y2014 {
namespace control_loops {
@@ -363,7 +362,8 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, GoesToValue) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(2)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(2))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -380,7 +380,8 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, Fire) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.2)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1200))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -393,7 +394,8 @@
.Send();
bool hit_fire = false;
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(5.2)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(5200))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -420,7 +422,8 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, FireLong) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -430,7 +433,8 @@
shooter_queue_.goal.MakeWithBuilder().shot_requested(true).Send();
bool hit_fire = false;
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(5.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(5500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -455,7 +459,8 @@
// power.
TEST_F(ShooterTest, LoadTooFar) {
shooter_queue_.goal.MakeWithBuilder().shot_power(500.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.6)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1600))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -470,7 +475,8 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, MoveGoal) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -479,7 +485,8 @@
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
shooter_queue_.goal.MakeWithBuilder().shot_power(14.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.0)) {
+ while (::aos::monotonic_clock::now() <
+ ::aos::monotonic_clock::time_point(chrono::seconds(1))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -496,7 +503,8 @@
TEST_F(ShooterTest, Unload) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -505,7 +513,8 @@
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
shooter_queue_.goal.MakeWithBuilder().unload_requested(true).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(8.0) &&
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(8)) &&
shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -521,7 +530,8 @@
// Tests that it rezeros while unloading.
TEST_F(ShooterTest, RezeroWhileUnloading) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -530,7 +540,8 @@
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
shooter_motor_.shooter_.offset_ += 0.01;
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(2.0)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(2))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -539,7 +550,8 @@
shooter_queue_.goal.MakeWithBuilder().unload_requested(true).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(10.0) &&
+ while (::aos::monotonic_clock::now() <
+ ::aos::monotonic_clock::time_point(chrono::seconds(10)) &&
shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -555,7 +567,8 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, UnloadWindupNegative) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -566,7 +579,8 @@
int kicked_delay = 20;
int capped_goal_count = 0;
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(9.5) &&
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(9500)) &&
shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -594,7 +608,8 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, UnloadWindupPositive) {
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(1.5)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(1500))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -605,7 +620,8 @@
int kicked_delay = 20;
int capped_goal_count = 0;
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(9.5) &&
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::milliseconds(9500)) &&
shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -638,7 +654,8 @@
TEST_F(ShooterTest, StartsOnDistal) {
Reinitialize(HallEffectMiddle(constants::GetValues().shooter.pusher_distal));
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(2.0)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(2))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -658,7 +675,8 @@
Reinitialize(
HallEffectMiddle(constants::GetValues().shooter.pusher_proximal));
shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(3.0)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(3))) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
shooter_motor_plant_.Simulate();
@@ -687,7 +705,8 @@
bool initialized = false;
Reinitialize(start_pos);
shooter_queue_.goal.MakeWithBuilder().shot_power(120.0).Send();
- while (::aos::time::Time::Now() < ::aos::time::Time::InSeconds(2.0)) {
+ while (monotonic_clock::now() <
+ monotonic_clock::time_point(chrono::seconds(2))) {
shooter_motor_plant_.SendPositionMessage(!initialized, plunger_back, latch, brake);
initialized = true;
shooter_motor_.Iterate();
diff --git a/y2014/hot_goal_reader.cc b/y2014/hot_goal_reader.cc
index 0b24f22..6c76c12 100644
--- a/y2014/hot_goal_reader.cc
+++ b/y2014/hot_goal_reader.cc
@@ -72,8 +72,9 @@
fd_set fds;
FD_ZERO(&fds);
FD_SET(connection, &fds);
- struct timeval timeout_timeval =
- ::aos::time::Time::InSeconds(1).ToTimeval();
+ struct timeval timeout_timeval;
+ timeout_timeval.tv_sec = 1;
+ timeout_timeval.tv_usec = 0;
switch (
select(connection + 1, &fds, nullptr, nullptr, &timeout_timeval)) {
case 1: {