Converted PhasedLoop over to monotonic_clock.
Change-Id: Ic8857c4412abb7c19dd3df4aaa5f6c8aa74e9dc6
diff --git a/y2016/actors/autonomous_actor.cc b/y2016/actors/autonomous_actor.cc
index 199dda5..6636e77 100644
--- a/y2016/actors/autonomous_actor.cc
+++ b/y2016/actors/autonomous_actor.cc
@@ -2,6 +2,7 @@
#include <inttypes.h>
+#include <chrono>
#include <cmath>
#include "aos/common/util/phased_loop.h"
@@ -102,8 +103,8 @@
return;
}
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
// Poll the running bit and see if we should cancel.
phased_loop.SleepUntilNext();
@@ -116,8 +117,8 @@
constexpr double kDoNotTurnCare = 2.0;
bool AutonomousActor::WaitForDriveNear(double distance, double angle) {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
constexpr double kPositionTolerance = 0.02;
constexpr double kProfileTolerance = 0.001;
@@ -164,8 +165,8 @@
}
bool AutonomousActor::WaitForDriveProfileDone() {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
constexpr double kProfileTolerance = 0.001;
while (true) {
@@ -187,8 +188,8 @@
}
bool AutonomousActor::WaitForMaxBy(double angle) {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
double max_angle = -M_PI;
while (true) {
if (ShouldCancel()) {
@@ -211,8 +212,8 @@
}
bool AutonomousActor::WaitForAboveAngle(double angle) {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
if (ShouldCancel()) {
return false;
@@ -231,8 +232,8 @@
}
bool AutonomousActor::WaitForBelowAngle(double angle) {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
if (ShouldCancel()) {
return false;
@@ -276,8 +277,8 @@
}
bool AutonomousActor::WaitForDriveDone() {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
if (ShouldCancel()) {
@@ -397,8 +398,8 @@
LOG(ERROR, "Sending shooter goal failed.\n");
}
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
if (ShouldCancel()) return;
@@ -414,8 +415,8 @@
}
void AutonomousActor::WaitForShooterSpeed() {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
if (ShouldCancel()) return;
@@ -442,8 +443,8 @@
double last_angle = 0.0;
int ready_to_fire = 0;
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
::aos::time::Time end_time =
::aos::time::Time::Now() + align_duration;
while (end_time > ::aos::time::Time::Now()) {
@@ -783,8 +784,8 @@
}
void AutonomousActor::WaitForBallOrDriveDone() {
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
if (ShouldCancel()) {
return;
@@ -1164,8 +1165,8 @@
LOG(INFO, "Done %f\n", (aos::time::Time::Now() - start_time).ToSeconds());
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (!ShouldCancel()) {
phased_loop.SleepUntilNext();
diff --git a/y2016/actors/vision_align_actor.cc b/y2016/actors/vision_align_actor.cc
index 00695f0..9491cd4 100644
--- a/y2016/actors/vision_align_actor.cc
+++ b/y2016/actors/vision_align_actor.cc
@@ -1,5 +1,6 @@
#include "y2016/actors/vision_align_actor.h"
+#include <chrono>
#include <functional>
#include <numeric>
@@ -28,8 +29,8 @@
const actors::VisionAlignActionParams & /*params*/) {
const double robot_radius =
control_loops::drivetrain::GetDrivetrainConfig().robot_radius;
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(5) / 2);
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(5) / 2);
while (true) {
const int iterations = phased_loop.SleepUntilNext();
if (iterations != 1) {
diff --git a/y2016/wpilib/wpilib_interface.cc b/y2016/wpilib/wpilib_interface.cc
index acf820f..d7fc261 100644
--- a/y2016/wpilib/wpilib_interface.cc
+++ b/y2016/wpilib/wpilib_interface.cc
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <inttypes.h>
+#include <chrono>
#include <thread>
#include <mutex>
#include <functional>
@@ -282,8 +283,8 @@
dma_synchronizer_->Start();
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
- ::aos::time::Time::InMS(4));
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(5),
+ ::std::chrono::milliseconds(4));
::aos::SetCurrentThreadRealtimePriority(40);
while (run_) {
@@ -472,8 +473,8 @@
::aos::SetCurrentThreadName("Solenoids");
::aos::SetCurrentThreadRealtimePriority(27);
- ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(20),
- ::aos::time::Time::InMS(1));
+ ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(20),
+ ::std::chrono::milliseconds(1));
while (run_) {
{