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) { |
Sabina Leaver | 7d9220d | 2021-06-30 20:55:15 -0700 | [diff] [blame] | 13 | |
| 14 | // FIX HERE: Set the intake_voltage to 12 Volts when |
Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 15 | // intake is requested (via intake in goal). Make sure not to set |
| 16 | // the motor to anything but 0 V when the limit_sensor is pressed. |
| 17 | |
Sabina Leaver | 7d9220d | 2021-06-30 20:55:15 -0700 | [diff] [blame] | 18 | // This line tells the compiler to to ignore the fact that goal and |
| 19 | // position are not used in the code. You will need to read these messages |
| 20 | // and use their values to determine the necessary output and status. |
James Kuszmaul | 78e29ac | 2020-07-28 21:07:03 -0700 | [diff] [blame] | 21 | (void)goal, (void)position; |
| 22 | |
| 23 | if (output) { |
| 24 | Output::Builder builder = output->MakeBuilder<Output>(); |
Sabina Leaver | 7d9220d | 2021-06-30 20:55:15 -0700 | [diff] [blame] | 25 | |
| 26 | // FIX HERE: As of now, this sets the intake voltage to 0 in |
| 27 | // all circumstances. Add to this code to output a different |
| 28 | // intake voltage depending on the circumstances to make the |
| 29 | // tests pass. |
James Kuszmaul | 78e29ac | 2020-07-28 21:07:03 -0700 | [diff] [blame] | 30 | builder.add_intake_voltage(0.0); |
| 31 | |
| 32 | output->Send(builder.Finish()); |
| 33 | } |
| 34 | |
| 35 | if (status) { |
| 36 | Status::Builder builder = status->MakeBuilder<Status>(); |
Sabina Leaver | 7d9220d | 2021-06-30 20:55:15 -0700 | [diff] [blame] | 37 | // FIX HERE: Fill out the Status message! In order to fill the |
| 38 | // information in the message, use the add_<name of the field>() method |
| 39 | // on the builder, just like we do with the Output message above. |
| 40 | // Look at the definition of Status in basic_status.fbs to find |
| 41 | // the name of the field. |
James Kuszmaul | 78e29ac | 2020-07-28 21:07:03 -0700 | [diff] [blame] | 42 | |
| 43 | status->Send(builder.Finish()); |
| 44 | } |
Parker Schuh | 18dbbb4 | 2017-10-18 21:45:33 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | } // namespace codelab |
| 48 | } // namespace frc971 |