blob: 9576e6b0a2db5c4c2e91febba352c48e0f40572f [file] [log] [blame]
Parker Schuh18dbbb42017-10-18 21:45:33 -07001#include "frc971/codelab/basic.h"
2
Stephan Pleinesf63bde82024-01-13 15:59:33 -08003namespace frc971::codelab {
Parker Schuh18dbbb42017-10-18 21:45:33 -07004
Austin Schuh55a13dc2019-01-27 22:39:03 -08005Basic::Basic(::aos::EventLoop *event_loop, const ::std::string &name)
Nikolai Sohmersc933f512024-06-08 13:57:05 -07006 : frc971::controls::ControlLoop<Goal, Position, StatusStatic, OutputStatic>(
7 event_loop, name) {}
Parker Schuh18dbbb42017-10-18 21:45:33 -07008
Alex Perrycb7da4b2019-08-28 19:35:56 -07009void Basic::RunIteration(const Goal *goal, const Position *position,
Nikolai Sohmersc933f512024-06-08 13:57:05 -070010 aos::Sender<OutputStatic>::StaticBuilder *output,
11 aos::Sender<StatusStatic>::StaticBuilder *status) {
Sabina Leaver7d9220d2021-06-30 20:55:15 -070012 // FIX HERE: Set the intake_voltage to 12 Volts when
Parker Schuh18dbbb42017-10-18 21:45:33 -070013 // intake is requested (via intake in goal). Make sure not to set
14 // the motor to anything but 0 V when the limit_sensor is pressed.
15
Jim Ostrowskie1db69f2022-07-02 15:49:43 -070016 // This line tells the compiler to ignore the fact that goal and
Sabina Leaver7d9220d2021-06-30 20:55:15 -070017 // position are not used in the code. You will need to read these messages
18 // and use their values to determine the necessary output and status.
James Kuszmaul78e29ac2020-07-28 21:07:03 -070019 (void)goal, (void)position;
20
Jim Ostrowskie1db69f2022-07-02 15:49:43 -070021 if (output != nullptr) {
Sabina Leaver7d9220d2021-06-30 20:55:15 -070022 // FIX HERE: As of now, this sets the intake voltage to 0 in
23 // all circumstances. Add to this code to output a different
24 // intake voltage depending on the circumstances to make the
25 // tests pass.
Nikolai Sohmersc933f512024-06-08 13:57:05 -070026 output->get()->set_intake_voltage(0.0);
James Kuszmaul78e29ac2020-07-28 21:07:03 -070027
milind1f1dca32021-07-03 13:50:07 -070028 // Ignore the return value of Send
Nikolai Sohmersc933f512024-06-08 13:57:05 -070029 (void)output->CheckOk(output->Send());
James Kuszmaul78e29ac2020-07-28 21:07:03 -070030 }
31
Jim Ostrowskie1db69f2022-07-02 15:49:43 -070032 if (status != nullptr) {
Nikolai Sohmersc933f512024-06-08 13:57:05 -070033 (void)status;
Sabina Leaver7d9220d2021-06-30 20:55:15 -070034 // FIX HERE: Fill out the Status message! In order to fill the
35 // information in the message, use the add_<name of the field>() method
36 // on the builder, just like we do with the Output message above.
37 // Look at the definition of Status in basic_status.fbs to find
38 // the name of the field.
James Kuszmaul78e29ac2020-07-28 21:07:03 -070039
milind1f1dca32021-07-03 13:50:07 -070040 // Ignore the return value of Send
James Kuszmaul78e29ac2020-07-28 21:07:03 -070041 }
Parker Schuh18dbbb42017-10-18 21:45:33 -070042}
43
Stephan Pleinesf63bde82024-01-13 15:59:33 -080044} // namespace frc971::codelab