blob: 6f33718d0e3e3064a5554c905d4dd28925baa39b [file] [log] [blame]
Parker Schuh18dbbb42017-10-18 21:45:33 -07001#ifndef FRC971_CODELAB_BASIC_H_
2#define FRC971_CODELAB_BASIC_H_
3
John Park33858a32018-09-28 23:05:48 -07004#include "aos/controls/control_loop.h"
5#include "aos/time/time.h"
Parker Schuh18dbbb42017-10-18 21:45:33 -07006
7#include "frc971/codelab/basic.q.h"
8
9namespace frc971 {
10namespace 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.
44class Basic : public ::aos::controls::ControlLoop<BasicQueue> {
45 public:
Austin Schuh55a13dc2019-01-27 22:39:03 -080046 explicit Basic(::aos::EventLoop *event_loop,
47 const ::std::string &name = ".frc971.codelab.basic_queue");
Parker Schuh18dbbb42017-10-18 21:45:33 -070048
49 protected:
50 void RunIteration(const BasicQueue::Goal *goal,
51 const BasicQueue::Position *position,
52 BasicQueue::Output *output,
53 BasicQueue::Status *status) override;
54};
55
56} // namespace codelab
57} // namespace frc971
58
59#endif // FRC971_CODELAB_BASIC_H_