Port y2014 bot3 to new control system.
Change-Id: I894277089335e36ea95b52e033056b1a8fb4ca30
diff --git a/y2014_bot3/control_loops/rollers/BUILD b/y2014_bot3/control_loops/rollers/BUILD
new file mode 100644
index 0000000..e3526ac
--- /dev/null
+++ b/y2014_bot3/control_loops/rollers/BUILD
@@ -0,0 +1,40 @@
+package(default_visibility = ['//visibility:public'])
+
+load('/aos/build/queues', 'queue_library')
+
+queue_library(
+ name = 'rollers_queue',
+ srcs = [
+ 'rollers.q',
+ ],
+ deps = [
+ '//aos/common/controls:control_loop_queues',
+ '//frc971/control_loops:queues',
+ ],
+)
+
+cc_library(
+ name = 'rollers_lib',
+ hdrs = [
+ 'rollers.h',
+ ],
+ srcs = [
+ 'rollers.cc',
+ ],
+ deps = [
+ ':rollers_queue',
+ '//aos/common/logging',
+ '//aos/common/controls:control_loop',
+ ],
+)
+
+cc_binary(
+ name = 'rollers',
+ srcs = [
+ 'rollers_main.cc',
+ ],
+ deps = [
+ ':rollers_lib',
+ '//aos/linux_code:init',
+ ],
+)
diff --git a/y2014_bot3/control_loops/rollers/rollers.cc b/y2014_bot3/control_loops/rollers/rollers.cc
index 8777549..ef895b3 100644
--- a/y2014_bot3/control_loops/rollers/rollers.cc
+++ b/y2014_bot3/control_loops/rollers/rollers.cc
@@ -1,40 +1,45 @@
-#include "bot3/control_loops/rollers/rollers.h"
-#include "bot3/control_loops/rollers/rollers.q.h"
+#include "y2014_bot3/control_loops/rollers/rollers.h"
-namespace bot3 {
+#include "aos/common/logging/logging.h"
+
+namespace y2014_bot3 {
namespace control_loops {
-void RollersLoop::RunIteration(const Rollers::Goal *goal,
- const Rollers::Position * /*position*/,
- Rollers::Output *output,
- Rollers::Status * /*status*/) {
- constexpr double kBot3IntakeForwardVoltage = 12.0;
- constexpr double kBot3IntakeBackwardVoltage = -12.0;
- constexpr double kBot3LowGoalForwardVoltage = 6.0;
- constexpr double kBot3LowGoalBackwardVoltage = -6.0;
+Rollers::Rollers(control_loops::RollersQueue *rollers)
+ : aos::controls::ControlLoop<control_loops::RollersQueue>(rollers) {}
+
+void Rollers::RunIteration(
+ const control_loops::RollersQueue::Goal *goal,
+ const control_loops::RollersQueue::Position * /*position*/,
+ control_loops::RollersQueue::Output *output,
+ control_loops::RollersQueue::Status * /*status*/) {
+ constexpr double k2014Bot3IntakeForwardVoltage = 12.0;
+ constexpr double k2014Bot3IntakeBackwardVoltage = -12.0;
+ constexpr double k2014Bot3LowGoalForwardVoltage = 6.0;
+ constexpr double k2014Bot3LowGoalBackwardVoltage = -6.0;
+
+ if (!output || !goal) {
+ return;
+ }
const int intake = goal->intake;
const int low_spit = goal->low_spit;
const bool human_player = goal->human_player;
- if (!output) {
- return;
- }
-
output->Zero();
switch (low_spit) {
case 1:
// Spit towards front
- output->low_goal_voltage = kBot3LowGoalBackwardVoltage;
- output->front_intake_voltage = kBot3IntakeBackwardVoltage;
- output->back_intake_voltage = -kBot3IntakeForwardVoltage;
+ output->low_goal_voltage = k2014Bot3LowGoalBackwardVoltage;
+ output->front_intake_voltage = k2014Bot3IntakeBackwardVoltage;
+ output->back_intake_voltage = -k2014Bot3IntakeForwardVoltage;
break;
case -1:
// Spit towards back
- output->low_goal_voltage = kBot3LowGoalForwardVoltage;
- output->back_intake_voltage = -kBot3IntakeBackwardVoltage;
- output->front_intake_voltage = kBot3IntakeForwardVoltage;
+ output->low_goal_voltage = k2014Bot3LowGoalForwardVoltage;
+ output->back_intake_voltage = -k2014Bot3IntakeBackwardVoltage;
+ output->front_intake_voltage = k2014Bot3IntakeForwardVoltage;
break;
default:
// Stationary
@@ -46,14 +51,14 @@
// Front intake.
output->front_extended = true;
output->back_extended = false;
- output->front_intake_voltage = kBot3IntakeForwardVoltage;
+ output->front_intake_voltage = k2014Bot3IntakeForwardVoltage;
output->back_intake_voltage = 0.0;
break;
case -1:
// Back intake.
output->back_extended = true;
output->front_extended = false;
- output->back_intake_voltage = -kBot3IntakeForwardVoltage;
+ output->back_intake_voltage = -k2014Bot3IntakeForwardVoltage;
output->front_intake_voltage = 0.0;
break;
default:
@@ -65,10 +70,10 @@
// Intake for human player.
output->front_extended = false;
output->back_extended = false;
- output->front_intake_voltage = kBot3IntakeForwardVoltage;
- output->back_intake_voltage = -kBot3IntakeForwardVoltage;
+ output->front_intake_voltage = k2014Bot3IntakeForwardVoltage;
+ output->back_intake_voltage = -k2014Bot3IntakeForwardVoltage;
}
}
} // namespace control_loops
-} // namespace bot3
+} // namespace y2014_bot3
diff --git a/y2014_bot3/control_loops/rollers/rollers.gyp b/y2014_bot3/control_loops/rollers/rollers.gyp
deleted file mode 100644
index e865ed8..0000000
--- a/y2014_bot3/control_loops/rollers/rollers.gyp
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- 'targets': [
- {
- 'target_name': 'rollers_loop',
- 'type': 'static_library',
- 'sources': ['rollers.q'],
- 'variables': {
- 'header_path': 'bot3/control_loops/rollers',
- },
- 'dependencies': [
- '<(AOS)/common/controls/controls.gyp:control_loop_queues',
- ],
- 'export_dependent_settings': [
- '<(AOS)/common/controls/controls.gyp:control_loop_queues',
- ],
- 'includes': ['../../../aos/build/queues.gypi'],
- },
- {
- 'target_name': 'rollers_lib',
- 'type': 'static_library',
- 'sources': [
- 'rollers.cc',
- ],
- 'dependencies': [
- 'rollers_loop',
- '<(AOS)/common/controls/controls.gyp:control_loop',
- ],
- 'export_dependent_settings': [
- 'rollers_loop',
- '<(AOS)/common/controls/controls.gyp:control_loop',
- ],
- },
- {
- 'target_name': 'rollers',
- 'type': 'executable',
- 'sources': [
- 'rollers_main.cc',
- ],
- 'dependencies': [
- 'rollers_lib',
- '<(AOS)/linux_code/linux_code.gyp:init'
- ],
- },
- ],
-}
diff --git a/y2014_bot3/control_loops/rollers/rollers.h b/y2014_bot3/control_loops/rollers/rollers.h
index f67b372..f0cae13 100644
--- a/y2014_bot3/control_loops/rollers/rollers.h
+++ b/y2014_bot3/control_loops/rollers/rollers.h
@@ -1,33 +1,29 @@
-#ifndef BOT3_CONTROL_LOOPS_ROLLERS_H_
-#define BOT3_CONTROL_LOOPS_ROLLERS_H_
+#ifndef Y2014_BOT3_CONTROL_LOOPS_ROLLERS_H_
+#define Y2014_BOT3_CONTROL_LOOPS_ROLLERS_H_
#include "aos/common/controls/control_loop.h"
-#include "bot3/control_loops/rollers/rollers.q.h"
-namespace bot3 {
+#include "y2014_bot3/control_loops/rollers/rollers.q.h"
+
+namespace y2014_bot3 {
namespace control_loops {
-class RollersLoop
- : public aos::controls::ControlLoop<control_loops::Rollers,
- false, false, true> {
+class Rollers : public aos::controls::ControlLoop<control_loops::RollersQueue> {
public:
// Constructs a control loops which can take a rollers or defaults to the
- // rollers at ::bot3::control_loops::rollers.
- explicit RollersLoop(
- control_loops::Rollers *my_rollers = &control_loops::rollers)
- : aos::controls::ControlLoop<control_loops::Rollers, false, false, true>(
- my_rollers) {}
+ // rollers at ::2014_bot3::control_loops::rollers.
+ explicit Rollers(control_loops::RollersQueue *rollers_queue =
+ &control_loops::rollers_queue);
protected:
// Executes one cycle of the control loop.
- virtual void RunIteration(
- const control_loops::Rollers::Goal *goal,
- const control_loops::Rollers::Position *position,
- control_loops::Rollers::Output *output,
- control_loops::Rollers::Status *status);
+ void RunIteration(const control_loops::RollersQueue::Goal *goal,
+ const control_loops::RollersQueue::Position *position,
+ control_loops::RollersQueue::Output *output,
+ control_loops::RollersQueue::Status *status) override;
};
} // namespace control_loops
-} // namespace bot3
+} // namespace y2014_bot3
-#endif // BOT3_CONTROL_LOOPS_ROLLERS_H_
+#endif // Y2014_BOT3_CONTROL_LOOPS_ROLLERS_H_
diff --git a/y2014_bot3/control_loops/rollers/rollers.q b/y2014_bot3/control_loops/rollers/rollers.q
index 5abb488..f218a41 100644
--- a/y2014_bot3/control_loops/rollers/rollers.q
+++ b/y2014_bot3/control_loops/rollers/rollers.q
@@ -1,8 +1,9 @@
-package bot3.control_loops;
+package y2014_bot3.control_loops;
import "aos/common/controls/control_loops.q";
+import "frc971/control_loops/control_loops.q";
-queue_group Rollers {
+queue_group RollersQueue {
implements aos.control_loops.ControlLoop;
message Goal {
@@ -37,4 +38,4 @@
queue Status status;
};
-queue_group Rollers rollers;
+queue_group RollersQueue rollers_queue;
diff --git a/y2014_bot3/control_loops/rollers/rollers_main.cc b/y2014_bot3/control_loops/rollers/rollers_main.cc
index 75d2cc6..4700a6e 100644
--- a/y2014_bot3/control_loops/rollers/rollers_main.cc
+++ b/y2014_bot3/control_loops/rollers/rollers_main.cc
@@ -1,10 +1,10 @@
-#include "bot3/control_loops/rollers/rollers.h"
+#include "y2014_bot3/control_loops/rollers/rollers.h"
#include "aos/linux_code/init.h"
int main() {
::aos::Init();
- bot3::control_loops::RollersLoop rollers;
+ ::y2014_bot3::control_loops::Rollers rollers;
rollers.Run();
::aos::Cleanup();
return 0;