Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 1 | #ifndef FRC971_CODELAB_BASIC_H_ |
| 2 | #define FRC971_CODELAB_BASIC_H_ |
| 3 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 4 | #include "aos/controls/control_loop.h" |
| 5 | #include "aos/time/time.h" |
Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 6 | |
| 7 | #include "frc971/codelab/basic.q.h" |
| 8 | |
| 9 | namespace frc971 { |
| 10 | namespace codelab { |
| 11 | |
| 12 | // This codelab helps build basic knowledge of how to use 971 control loop |
| 13 | // primatives. |
| 14 | // |
| 15 | // The meat of the task is to make the tests pass. |
| 16 | // |
| 17 | // Run the tests with: |
| 18 | // $ bazel run //frc971/codelab:basic_test -- --gtest_color=yes |
| 19 | // |
| 20 | // Control loops all follow the same convention: |
| 21 | // There are 4 queues (goal, position, status, output). |
| 22 | // |
| 23 | // 2 queues are input queues: goal, position. |
| 24 | // 2 queues are output queues: output, status. |
| 25 | // |
| 26 | // ::aos::controls::ControlLoop is a helper class that takes |
| 27 | // a queue_group type from a .h file, and organizes to call |
| 28 | // RunIteration() at a consistent interval. It will fetch from |
| 29 | // goal and position messages from the goal and position queue, |
| 30 | // and publish an output and status result to the output and status |
| 31 | // queues. |
| 32 | // |
| 33 | // The basic.q file will construct boilerplate c++ code for the |
| 34 | // Goal, Position, Status, Message |
| 35 | // types, and construct static variables for fetching these named queues. |
| 36 | // Inquisitive souls can check out: |
| 37 | // $ bazel build //frc971/codelab:basic_queue |
| 38 | // $ vim bazel-genfiles/frc971/codelab/basic.q.{cc,h} -o |
| 39 | // from the 971-Robot-Code directory. |
| 40 | // |
| 41 | // Order of approaching this should be: |
| 42 | // - Read the BUILD file and learn about what code is being generated. |
| 43 | // - Read basic.q, and familiarize yourself on the inputs and types involved. |
| 44 | class Basic : public ::aos::controls::ControlLoop<BasicQueue> { |
| 45 | public: |
| 46 | explicit Basic(BasicQueue *my_basic_queue = &basic_queue); |
| 47 | |
| 48 | protected: |
| 49 | void RunIteration(const BasicQueue::Goal *goal, |
| 50 | const BasicQueue::Position *position, |
| 51 | BasicQueue::Output *output, |
| 52 | BasicQueue::Status *status) override; |
| 53 | }; |
| 54 | |
| 55 | } // namespace codelab |
| 56 | } // namespace frc971 |
| 57 | |
| 58 | #endif // FRC971_CODELAB_BASIC_H_ |