actions and control loops: frc971 shall depend on aos
And not the other way around.
Define the loop frequency in actor.h and use that in
control_loop.h. Fix dependencies (and add missing dependency of
actor on event_loop).
Signed-off-by: Stephan Pleines <pleines.stephan@gmail.com>
Change-Id: Ieec0b3eb1c66737e1ed19e6bdee40655524f4016
diff --git a/frc971/autonomous/base_autonomous_actor.cc b/frc971/autonomous/base_autonomous_actor.cc
index 2156045..a8858ea 100644
--- a/frc971/autonomous/base_autonomous_actor.cc
+++ b/frc971/autonomous/base_autonomous_actor.cc
@@ -124,7 +124,7 @@
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
// Poll the running bit and see if we should cancel.
phased_loop.SleepUntilNext();
@@ -137,7 +137,7 @@
bool BaseAutonomousActor::WaitForDriveDone() {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (ShouldCancel()) {
@@ -197,7 +197,7 @@
bool BaseAutonomousActor::WaitForAboveAngle(double angle) {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (ShouldCancel()) {
return false;
@@ -218,7 +218,7 @@
bool BaseAutonomousActor::WaitForBelowAngle(double angle) {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (ShouldCancel()) {
return false;
@@ -239,7 +239,7 @@
bool BaseAutonomousActor::WaitForMaxBy(double angle) {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
double max_angle = -M_PI;
while (true) {
if (ShouldCancel()) {
@@ -264,7 +264,7 @@
bool BaseAutonomousActor::WaitForDriveNear(double distance, double angle) {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
constexpr double kPositionTolerance = 0.02;
constexpr double kProfileTolerance = 0.001;
@@ -333,7 +333,7 @@
bool BaseAutonomousActor::WaitForDriveProfileNear(double tolerance) {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (ShouldCancel()) {
return false;
@@ -370,7 +370,7 @@
bool BaseAutonomousActor::WaitForTurnProfileNear(double tolerance) {
::aos::time::PhasedLoop phased_loop(frc971::controls::kLoopFrequency,
event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (ShouldCancel()) {
return false;
@@ -483,7 +483,7 @@
::aos::time::PhasedLoop phased_loop(
frc971::controls::kLoopFrequency,
base_autonomous_actor_->event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (base_autonomous_actor_->ShouldCancel()) {
return false;
@@ -500,7 +500,7 @@
::aos::time::PhasedLoop phased_loop(
frc971::controls::kLoopFrequency,
base_autonomous_actor_->event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (base_autonomous_actor_->ShouldCancel()) {
return false;
@@ -615,7 +615,7 @@
::aos::time::PhasedLoop phased_loop(
frc971::controls::kLoopFrequency,
base_autonomous_actor_->event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (base_autonomous_actor_->ShouldCancel()) {
return false;
@@ -665,7 +665,7 @@
::aos::time::PhasedLoop phased_loop(
frc971::controls::kLoopFrequency,
base_autonomous_actor_->event_loop()->monotonic_now(),
- ActorBase::kLoopOffset);
+ aos::common::actions::kLoopOffset);
while (true) {
if (base_autonomous_actor_->ShouldCancel()) {
return false;
diff --git a/frc971/control_loops/BUILD b/frc971/control_loops/BUILD
index 1c1b797..925dd43 100644
--- a/frc971/control_loops/BUILD
+++ b/frc971/control_loops/BUILD
@@ -84,6 +84,7 @@
],
target_compatible_with = ["@platforms//os:linux"],
deps = [
+ "//aos/actions:action_lib",
"//aos/events:event_loop",
"//aos/events:shm_event_loop",
"//aos/logging",
diff --git a/frc971/control_loops/control_loop.h b/frc971/control_loops/control_loop.h
index c02d094..3430dbd 100644
--- a/frc971/control_loops/control_loop.h
+++ b/frc971/control_loops/control_loop.h
@@ -4,6 +4,7 @@
#include <atomic>
#include <cstring>
+#include "aos/actions/actor.h"
#include "aos/events/event_loop.h"
#include "aos/time/time.h"
#include "aos/util/log_interval.h"
@@ -15,7 +16,7 @@
// Control loops run this often, "starting" at time 0.
constexpr ::std::chrono::nanoseconds kLoopFrequency =
- ::std::chrono::milliseconds(5);
+ aos::common::actions::kLoopFrequency;
// Provides helper methods to assist in writing control loops.
// It will then call the RunIteration method every cycle that it has enough