Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 1 | #include "frc971/codelab/basic.h" |
| 2 | |
| 3 | namespace frc971 { |
| 4 | namespace codelab { |
| 5 | |
Austin Schuh | 55a13dc | 2019-01-27 22:39:03 -0800 | [diff] [blame] | 6 | Basic::Basic(::aos::EventLoop *event_loop, const ::std::string &name) |
James Kuszmaul | 6175066 | 2021-06-21 21:32:33 -0700 | [diff] [blame^] | 7 | : frc971::controls::ControlLoop<Goal, Position, Status, Output>(event_loop, |
| 8 | name) {} |
Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 9 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 10 | void Basic::RunIteration(const Goal *goal, const Position *position, |
| 11 | aos::Sender<Output>::Builder *output, |
| 12 | aos::Sender<Status>::Builder *status) { |
Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 13 | // TODO(you): Set the intake_voltage to 12 Volts when |
| 14 | // intake is requested (via intake in goal). Make sure not to set |
| 15 | // the motor to anything but 0 V when the limit_sensor is pressed. |
| 16 | |
| 17 | // Ignore: These are to avoid clang warnings. |
James Kuszmaul | 78e29ac | 2020-07-28 21:07:03 -0700 | [diff] [blame] | 18 | (void)goal, (void)position; |
| 19 | |
| 20 | if (output) { |
| 21 | Output::Builder builder = output->MakeBuilder<Output>(); |
| 22 | // TODO(you): Fill out the voltage with a real voltage based on the |
| 23 | // Goal/Position messages. |
| 24 | builder.add_intake_voltage(0.0); |
| 25 | |
| 26 | output->Send(builder.Finish()); |
| 27 | } |
| 28 | |
| 29 | if (status) { |
| 30 | Status::Builder builder = status->MakeBuilder<Status>(); |
| 31 | // TODO(you): Fill out the Status message! In order to populate fields, use |
| 32 | // the add_field_name() method on the builder, just like we do with the |
Austin Schuh | 4054640 | 2020-09-23 20:58:09 -0700 | [diff] [blame] | 33 | // Output message above. Look at the definition of Status in |
| 34 | // basic_status.fbs and populate the field according to the comments there. |
James Kuszmaul | 78e29ac | 2020-07-28 21:07:03 -0700 | [diff] [blame] | 35 | |
| 36 | status->Send(builder.Finish()); |
| 37 | } |
Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | } // namespace codelab |
| 41 | } // namespace frc971 |