Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 1 | #include <math.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <unistd.h> |
Tyler Chatow | 4fedeea | 2019-03-10 15:33:36 -0700 | [diff] [blame] | 5 | #include <chrono> |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 6 | |
| 7 | #include "aos/actions/actions.h" |
| 8 | #include "aos/init.h" |
| 9 | #include "aos/input/action_joystick_input.h" |
| 10 | #include "aos/input/driver_station_data.h" |
| 11 | #include "aos/input/drivetrain_input.h" |
| 12 | #include "aos/input/joystick_input.h" |
| 13 | #include "aos/logging/logging.h" |
| 14 | #include "aos/logging/logging.h" |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 15 | #include "aos/network/team_number.h" |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 16 | #include "aos/util/log_interval.h" |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 17 | #include "aos/vision/events/udp.h" |
| 18 | #include "external/com_google_protobuf/src/google/protobuf/stubs/stringprintf.h" |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 19 | #include "frc971/autonomous/auto.q.h" |
| 20 | #include "frc971/autonomous/base_autonomous_actor.h" |
| 21 | #include "frc971/control_loops/drivetrain/drivetrain.q.h" |
James Kuszmaul | d8deb68 | 2019-03-10 10:38:42 -0700 | [diff] [blame] | 22 | #include "frc971/control_loops/drivetrain/localizer.q.h" |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 23 | |
| 24 | #include "y2019/control_loops/drivetrain/drivetrain_base.h" |
James Kuszmaul | 7d1ef44 | 2019-03-23 20:20:50 -0700 | [diff] [blame] | 25 | #include "y2019/control_loops/drivetrain/target_selector.q.h" |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 26 | #include "y2019/control_loops/superstructure/superstructure.q.h" |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 27 | #include "y2019/status_light.q.h" |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 28 | #include "y2019/vision.pb.h" |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 29 | |
| 30 | using ::y2019::control_loops::superstructure::superstructure_queue; |
| 31 | using ::aos::input::driver_station::ButtonLocation; |
| 32 | using ::aos::input::driver_station::ControlBit; |
| 33 | using ::aos::input::driver_station::JoystickAxis; |
| 34 | using ::aos::input::driver_station::POVLocation; |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 35 | using ::aos::events::ProtoTXUdpSocket; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 36 | |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 37 | namespace chrono = ::std::chrono; |
| 38 | |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 39 | namespace y2019 { |
| 40 | namespace input { |
| 41 | namespace joysticks { |
| 42 | |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 43 | using google::protobuf::StringPrintf; |
| 44 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 45 | struct ElevatorWristPosition { |
| 46 | double elevator; |
| 47 | double wrist; |
| 48 | }; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 49 | |
Tyler Chatow | 5eeee90 | 2019-04-12 20:47:48 -0700 | [diff] [blame] | 50 | const ButtonLocation kSuctionBall(4, 2); |
| 51 | const ButtonLocation kSuctionHatch(3, 15); |
| 52 | const ButtonLocation kDeployStilt(4, 1); |
| 53 | const ButtonLocation kHalfStilt(4, 3); |
| 54 | const ButtonLocation kFallOver(3, 16); |
| 55 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 56 | const ButtonLocation kRocketForwardLower(5, 1); |
| 57 | const ButtonLocation kRocketForwardMiddle(5, 2); |
| 58 | const ButtonLocation kRocketForwardUpper(5, 4); |
| 59 | const ButtonLocation kCargoForward(5, 3); |
| 60 | |
| 61 | const POVLocation kRocketBackwardUnpressed(5, -1); |
| 62 | const POVLocation kRocketBackwardLower(5, 180); |
| 63 | const POVLocation kRocketBackwardMiddle(5, 90); |
| 64 | const POVLocation kRocketBackwardUpper(5, 0); |
| 65 | const POVLocation kCargoBackward(5, 270); |
| 66 | |
| 67 | const ButtonLocation kPanelSwitch(5, 7); |
| 68 | const ButtonLocation kCargoSwitch(5, 8); |
| 69 | |
| 70 | const ButtonLocation kBallHPIntakeForward(5, 6); |
| 71 | const ButtonLocation kBallHPIntakeBackward(5, 5); |
| 72 | const JoystickAxis kBallOutake(5, 3); |
| 73 | const JoystickAxis kBallIntake(5, 4); |
| 74 | |
| 75 | const ButtonLocation kPanelHPIntakeForward(5, 6); |
| 76 | const ButtonLocation kPanelHPIntakeBackward(5, 5); |
| 77 | |
| 78 | const ButtonLocation kRelease(2, 4); |
James Kuszmaul | ccc368b | 2019-04-11 20:00:07 -0700 | [diff] [blame] | 79 | // Reuse quickturn for the cancel button. |
| 80 | const ButtonLocation kCancelAutoMode(2, 3); |
Tyler Chatow | 5eeee90 | 2019-04-12 20:47:48 -0700 | [diff] [blame] | 81 | const ButtonLocation kReleaseButtonBoard(3, 4); |
| 82 | const ButtonLocation kResetLocalizerLeftForwards(3, 10); |
| 83 | const ButtonLocation kResetLocalizerLeftBackwards(3, 9); |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 84 | |
Tyler Chatow | 5eeee90 | 2019-04-12 20:47:48 -0700 | [diff] [blame] | 85 | const ButtonLocation kResetLocalizerRightForwards(3, 8); |
| 86 | const ButtonLocation kResetLocalizerRightBackwards(3, 7); |
Tyler Chatow | 07c906b | 2019-03-09 21:29:06 -0800 | [diff] [blame] | 87 | |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 88 | const ButtonLocation kResetLocalizerLeft(3, 11); |
| 89 | const ButtonLocation kResetLocalizerRight(3, 13); |
| 90 | |
Tyler Chatow | 5eeee90 | 2019-04-12 20:47:48 -0700 | [diff] [blame] | 91 | const ButtonLocation kNearCargoHint(3, 3); |
| 92 | const ButtonLocation kMidCargoHint(3, 5); |
| 93 | const ButtonLocation kFarCargoHint(3, 6); |
James Kuszmaul | 7d1ef44 | 2019-03-23 20:20:50 -0700 | [diff] [blame] | 94 | |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 95 | const JoystickAxis kCargoSelectorY(5, 6); |
| 96 | const JoystickAxis kCargoSelectorX(5, 5); |
| 97 | |
Tyler Chatow | 5eeee90 | 2019-04-12 20:47:48 -0700 | [diff] [blame] | 98 | const ButtonLocation kCameraLog(3, 14); |
Austin Schuh | 4e2629d | 2019-03-28 14:44:37 -0700 | [diff] [blame] | 99 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 100 | const ElevatorWristPosition kStowPos{0.36, 0.0}; |
Austin Schuh | 02be8b9 | 2019-03-24 16:04:14 -0700 | [diff] [blame] | 101 | const ElevatorWristPosition kClimbPos{0.0, M_PI / 4.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 102 | |
Austin Schuh | 139f59d | 2019-03-17 18:16:13 -0700 | [diff] [blame] | 103 | const ElevatorWristPosition kPanelHPIntakeForwrdPos{0.01, M_PI / 2.0}; |
| 104 | const ElevatorWristPosition kPanelHPIntakeBackwardPos{0.015, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 105 | |
| 106 | const ElevatorWristPosition kPanelForwardLowerPos{0.0, M_PI / 2.0}; |
| 107 | const ElevatorWristPosition kPanelBackwardLowerPos{0.0, -M_PI / 2.0}; |
| 108 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 109 | const ElevatorWristPosition kPanelForwardMiddlePos{0.75, M_PI / 2.0}; |
| 110 | const ElevatorWristPosition kPanelBackwardMiddlePos{0.78, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 111 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 112 | const ElevatorWristPosition kPanelForwardUpperPos{1.51, M_PI / 2.0}; |
| 113 | const ElevatorWristPosition kPanelBackwardUpperPos{1.50, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 114 | |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 115 | const ElevatorWristPosition kPanelCargoForwardPos{0.0, M_PI / 2.0}; |
| 116 | const ElevatorWristPosition kPanelCargoBackwardPos{0.0, -M_PI / 2.0}; |
| 117 | |
Austin Schuh | 6c5deb1 | 2019-03-24 16:48:32 -0700 | [diff] [blame] | 118 | const ElevatorWristPosition kBallForwardLowerPos{0.21, 1.27}; |
Austin Schuh | 20dc050 | 2019-03-30 07:24:07 -0700 | [diff] [blame] | 119 | const ElevatorWristPosition kBallBackwardLowerPos{0.43, -1.99}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 120 | |
Austin Schuh | 20dc050 | 2019-03-30 07:24:07 -0700 | [diff] [blame] | 121 | const ElevatorWristPosition kBallForwardMiddlePos{0.925, 1.21}; |
| 122 | const ElevatorWristPosition kBallBackwardMiddlePos{1.19, -1.98}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 123 | |
Austin Schuh | 139f59d | 2019-03-17 18:16:13 -0700 | [diff] [blame] | 124 | const ElevatorWristPosition kBallForwardUpperPos{1.51, 0.961}; |
| 125 | const ElevatorWristPosition kBallBackwardUpperPos{1.44, -1.217}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 126 | |
Austin Schuh | 20dc050 | 2019-03-30 07:24:07 -0700 | [diff] [blame] | 127 | const ElevatorWristPosition kBallCargoForwardPos{0.59, 1.2}; |
| 128 | const ElevatorWristPosition kBallCargoBackwardPos{0.868265, -2.1}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 129 | |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 130 | const ElevatorWristPosition kBallHPIntakeForwardPos{0.55, 1.097}; |
| 131 | const ElevatorWristPosition kBallHPIntakeBackwardPos{0.89, -2.018}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 132 | |
Austin Schuh | 20dc050 | 2019-03-30 07:24:07 -0700 | [diff] [blame] | 133 | const ElevatorWristPosition kBallIntakePos{0.309, 2.13}; |
Austin Schuh | 2cf16b8 | 2019-02-15 23:23:22 -0800 | [diff] [blame] | 134 | |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 135 | class Reader : public ::aos::input::ActionJoystickInput { |
| 136 | public: |
| 137 | Reader(::aos::EventLoop *event_loop) |
| 138 | : ::aos::input::ActionJoystickInput( |
| 139 | event_loop, |
James Kuszmaul | ccc368b | 2019-04-11 20:00:07 -0700 | [diff] [blame] | 140 | ::y2019::control_loops::drivetrain::GetDrivetrainConfig(), |
Austin Schuh | bfb0412 | 2019-05-22 21:16:51 -0700 | [diff] [blame^] | 141 | ::aos::input::DrivetrainInputReader::InputType::kPistol, |
James Kuszmaul | ccc368b | 2019-04-11 20:00:07 -0700 | [diff] [blame] | 142 | {.run_teleop_in_auto = true, |
Austin Schuh | c087b10 | 2019-05-12 15:33:12 -0700 | [diff] [blame] | 143 | .cancel_auto_button = kCancelAutoMode}), |
| 144 | target_selector_hint_sender_( |
| 145 | event_loop->MakeSender< |
| 146 | ::y2019::control_loops::drivetrain::TargetSelectorHint>( |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 147 | ".y2019.control_loops.drivetrain.target_selector_hint")), |
| 148 | localizer_control_sender_( |
| 149 | event_loop->MakeSender< |
| 150 | ::frc971::control_loops::drivetrain::LocalizerControl>( |
Austin Schuh | 5671a8c | 2019-05-19 17:01:04 -0700 | [diff] [blame] | 151 | ".frc971.control_loops.drivetrain.localizer_control")), |
| 152 | camera_log_sender_( |
| 153 | event_loop->MakeSender<::y2019::CameraLog>(".y2019.camera_log")) { |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 154 | const uint16_t team = ::aos::network::GetTeamNumber(); |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 155 | superstructure_queue.goal.FetchLatest(); |
| 156 | if (superstructure_queue.goal.get()) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 157 | grab_piece_ = superstructure_queue.goal->suction.grab_piece; |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 158 | switch_ball_ = superstructure_queue.goal->suction.gamepiece_mode == 0; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 159 | } |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 160 | video_tx_.reset(new ProtoTXUdpSocket<VisionControl>( |
| 161 | StringPrintf("10.%d.%d.179", team / 100, team % 100), 5000)); |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 162 | } |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 163 | |
Austin Schuh | a78857f | 2019-03-13 22:43:41 -0700 | [diff] [blame] | 164 | void AutoEnded() override { |
| 165 | LOG(INFO, "Auto ended, assuming disc and have piece\n"); |
| 166 | grab_piece_ = true; |
| 167 | switch_ball_ = false; |
| 168 | } |
| 169 | |
| 170 | void HandleTeleop(const ::aos::input::driver_station::Data &data) override { |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 171 | ::aos::monotonic_clock::time_point monotonic_now = |
| 172 | ::aos::monotonic_clock::now(); |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 173 | superstructure_queue.position.FetchLatest(); |
| 174 | superstructure_queue.status.FetchLatest(); |
| 175 | if (!superstructure_queue.status.get() || |
| 176 | !superstructure_queue.position.get()) { |
Austin Schuh | e2f2248 | 2019-04-13 23:05:43 -0700 | [diff] [blame] | 177 | LOG(ERROR, "Got no superstructure status or position packet.\n"); |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 178 | return; |
| 179 | } |
| 180 | |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 181 | if (!superstructure_queue.status->has_piece) { |
| 182 | last_not_has_piece_ = monotonic_now; |
| 183 | } |
| 184 | |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 185 | auto new_superstructure_goal = superstructure_queue.goal.MakeMessage(); |
| 186 | |
James Kuszmaul | 7d1ef44 | 2019-03-23 20:20:50 -0700 | [diff] [blame] | 187 | { |
Austin Schuh | c087b10 | 2019-05-12 15:33:12 -0700 | [diff] [blame] | 188 | auto target_hint = target_selector_hint_sender_.MakeMessage(); |
James Kuszmaul | 7d1ef44 | 2019-03-23 20:20:50 -0700 | [diff] [blame] | 189 | if (data.IsPressed(kNearCargoHint)) { |
| 190 | target_hint->suggested_target = 1; |
| 191 | } else if (data.IsPressed(kMidCargoHint)) { |
| 192 | target_hint->suggested_target = 2; |
| 193 | } else if (data.IsPressed(kFarCargoHint)) { |
| 194 | target_hint->suggested_target = 3; |
| 195 | } else { |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 196 | const double cargo_joy_y = data.GetAxis(kCargoSelectorY); |
| 197 | const double cargo_joy_x = data.GetAxis(kCargoSelectorX); |
| 198 | if (cargo_joy_y > 0.5) { |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 199 | target_hint->suggested_target = 1; |
James Kuszmaul | 1b822b4 | 2019-04-14 14:27:35 -0700 | [diff] [blame] | 200 | } else if (cargo_joy_y < -0.5) { |
| 201 | target_hint->suggested_target = 3; |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 202 | } else if (::std::abs(cargo_joy_x) > 0.5) { |
| 203 | target_hint->suggested_target = 2; |
| 204 | } else { |
| 205 | target_hint->suggested_target = 0; |
| 206 | } |
James Kuszmaul | 7d1ef44 | 2019-03-23 20:20:50 -0700 | [diff] [blame] | 207 | } |
| 208 | if (!target_hint.Send()) { |
| 209 | LOG(ERROR, "Failed to send target selector hint.\n"); |
| 210 | } |
| 211 | } |
| 212 | |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 213 | if (data.PosEdge(kResetLocalizerLeft)) { |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 214 | auto localizer_resetter = localizer_control_sender_.MakeMessage(); |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 215 | // Start at the left feeder station. |
| 216 | localizer_resetter->x = 0.6; |
| 217 | localizer_resetter->y = 3.4; |
| 218 | localizer_resetter->keep_current_theta = true; |
| 219 | |
| 220 | if (!localizer_resetter.Send()) { |
| 221 | LOG(ERROR, "Failed to reset localizer.\n"); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | if (data.PosEdge(kResetLocalizerRight)) { |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 226 | auto localizer_resetter = localizer_control_sender_.MakeMessage(); |
James Kuszmaul | 518640d | 2019-04-13 15:50:50 -0700 | [diff] [blame] | 227 | // Start at the left feeder station. |
| 228 | localizer_resetter->x = 0.6; |
| 229 | localizer_resetter->y = -3.4; |
| 230 | localizer_resetter->keep_current_theta = true; |
| 231 | |
| 232 | if (!localizer_resetter.Send()) { |
| 233 | LOG(ERROR, "Failed to reset localizer.\n"); |
| 234 | } |
| 235 | } |
| 236 | |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 237 | if (data.PosEdge(kResetLocalizerLeftForwards)) { |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 238 | auto localizer_resetter = localizer_control_sender_.MakeMessage(); |
Austin Schuh | 3632f8d | 2019-03-22 21:14:14 -0700 | [diff] [blame] | 239 | // Start at the left feeder station. |
James Kuszmaul | d8deb68 | 2019-03-10 10:38:42 -0700 | [diff] [blame] | 240 | localizer_resetter->x = 0.4; |
| 241 | localizer_resetter->y = 3.4; |
| 242 | localizer_resetter->theta = 0.0; |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 243 | |
| 244 | if (!localizer_resetter.Send()) { |
| 245 | LOG(ERROR, "Failed to reset localizer.\n"); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if (data.PosEdge(kResetLocalizerLeftBackwards)) { |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 250 | auto localizer_resetter = localizer_control_sender_.MakeMessage(); |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 251 | // Start at the left feeder station. |
| 252 | localizer_resetter->x = 0.4; |
| 253 | localizer_resetter->y = 3.4; |
| 254 | localizer_resetter->theta = M_PI; |
| 255 | |
| 256 | if (!localizer_resetter.Send()) { |
| 257 | LOG(ERROR, "Failed to reset localizer.\n"); |
| 258 | } |
| 259 | } |
| 260 | |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 261 | if (data.PosEdge(kResetLocalizerRightForwards)) { |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 262 | auto localizer_resetter = localizer_control_sender_.MakeMessage(); |
Austin Schuh | 3632f8d | 2019-03-22 21:14:14 -0700 | [diff] [blame] | 263 | // Start at the right feeder station. |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 264 | localizer_resetter->x = 0.4; |
| 265 | localizer_resetter->y = -3.4; |
| 266 | localizer_resetter->theta = 0.0; |
| 267 | |
| 268 | if (!localizer_resetter.Send()) { |
| 269 | LOG(ERROR, "Failed to reset localizer.\n"); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | if (data.PosEdge(kResetLocalizerRightBackwards)) { |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 274 | auto localizer_resetter = localizer_control_sender_.MakeMessage(); |
Austin Schuh | 3632f8d | 2019-03-22 21:14:14 -0700 | [diff] [blame] | 275 | // Start at the right feeder station. |
Austin Schuh | bb1df6f | 2019-03-17 18:15:43 -0700 | [diff] [blame] | 276 | localizer_resetter->x = 0.4; |
| 277 | localizer_resetter->y = -3.4; |
| 278 | localizer_resetter->theta = M_PI; |
| 279 | |
James Kuszmaul | d8deb68 | 2019-03-10 10:38:42 -0700 | [diff] [blame] | 280 | if (!localizer_resetter.Send()) { |
| 281 | LOG(ERROR, "Failed to reset localizer.\n"); |
| 282 | } |
| 283 | } |
| 284 | |
James Kuszmaul | 1373886 | 2019-04-14 10:48:00 -0700 | [diff] [blame] | 285 | if (data.PosEdge(kRelease) && |
| 286 | monotonic_now > |
| 287 | last_release_button_press_ + ::std::chrono::milliseconds(500)) { |
| 288 | if (superstructure_queue.status->has_piece) { |
| 289 | release_mode_ = ReleaseButtonMode::kRelease; |
| 290 | } else { |
| 291 | release_mode_ = ReleaseButtonMode::kBallIntake; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | if (data.IsPressed(kRelease)) { |
| 296 | last_release_button_press_ = monotonic_now; |
| 297 | } |
| 298 | |
Austin Schuh | 1a8fb57 | 2019-05-08 20:07:58 -0700 | [diff] [blame] | 299 | LOG(INFO, "has_piece: %d\n", superstructure_queue.status->has_piece); |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 300 | if (data.IsPressed(kSuctionBall)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 301 | grab_piece_ = true; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 302 | } else if (data.IsPressed(kSuctionHatch)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 303 | grab_piece_ = true; |
James Kuszmaul | 1373886 | 2019-04-14 10:48:00 -0700 | [diff] [blame] | 304 | } else if ((release_mode_ == ReleaseButtonMode::kRelease && |
| 305 | data.IsPressed(kRelease)) || |
Tyler Chatow | 5eeee90 | 2019-04-12 20:47:48 -0700 | [diff] [blame] | 306 | data.IsPressed(kReleaseButtonBoard) || |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 307 | !superstructure_queue.status->has_piece) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 308 | grab_piece_ = false; |
Austin Schuh | 1a8fb57 | 2019-05-08 20:07:58 -0700 | [diff] [blame] | 309 | LOG(INFO, "releasing due to other thing\n"); |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 310 | } |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 311 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 312 | if (data.IsPressed(kRocketBackwardUnpressed)) { |
| 313 | elevator_wrist_pos_ = kStowPos; |
| 314 | } |
| 315 | new_superstructure_goal->intake.unsafe_goal = -1.2; |
| 316 | new_superstructure_goal->roller_voltage = 0.0; |
| 317 | |
James Kuszmaul | 1373886 | 2019-04-14 10:48:00 -0700 | [diff] [blame] | 318 | const bool kDoBallIntake = |
| 319 | (!climbed_ && release_mode_ == ReleaseButtonMode::kBallIntake && |
| 320 | data.IsPressed(kRelease)) || |
| 321 | data.GetAxis(kBallIntake) > 0.9; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 322 | const bool kDoBallOutake = data.GetAxis(kBallOutake) > 0.9; |
| 323 | |
| 324 | if (data.IsPressed(kPanelSwitch)) { |
| 325 | switch_ball_ = false; |
| 326 | } else if (data.IsPressed(kCargoSwitch)) { |
| 327 | switch_ball_ = true; |
| 328 | } |
| 329 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 330 | if (switch_ball_) { |
| 331 | if (superstructure_queue.status->has_piece) { |
| 332 | new_superstructure_goal->wrist.profile_params.max_acceleration = 20; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 333 | } |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 334 | |
| 335 | // Go to intake position and apply vacuum |
| 336 | if (data.IsPressed(kBallHPIntakeForward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 337 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 338 | elevator_wrist_pos_ = kBallHPIntakeForwardPos; |
| 339 | } else if (data.IsPressed(kBallHPIntakeBackward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 340 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 341 | elevator_wrist_pos_ = kBallHPIntakeBackwardPos; |
| 342 | } |
| 343 | |
| 344 | // Go to elevator/wrist position. Overrides intake position if pressed so |
| 345 | // we can re-grab the ball. |
| 346 | if (data.IsPressed(kRocketForwardLower)) { |
| 347 | elevator_wrist_pos_ = kBallForwardLowerPos; |
| 348 | } else if (data.IsPressed(kRocketBackwardLower)) { |
| 349 | elevator_wrist_pos_ = kBallBackwardLowerPos; |
| 350 | } else if (data.IsPressed(kRocketForwardMiddle)) { |
| 351 | elevator_wrist_pos_ = kBallForwardMiddlePos; |
| 352 | } else if (data.IsPressed(kRocketBackwardMiddle)) { |
| 353 | elevator_wrist_pos_ = kBallBackwardMiddlePos; |
| 354 | } else if (data.IsPressed(kRocketForwardUpper)) { |
| 355 | elevator_wrist_pos_ = kBallForwardUpperPos; |
| 356 | } else if (data.IsPressed(kRocketBackwardUpper)) { |
| 357 | elevator_wrist_pos_ = kBallBackwardUpperPos; |
| 358 | } else if (data.IsPressed(kCargoForward)) { |
| 359 | elevator_wrist_pos_ = kBallCargoForwardPos; |
| 360 | } else if (data.IsPressed(kCargoBackward)) { |
| 361 | elevator_wrist_pos_ = kBallCargoBackwardPos; |
| 362 | } |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 363 | } else { |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 364 | if (data.IsPressed(kPanelHPIntakeForward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 365 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 366 | elevator_wrist_pos_ = kPanelHPIntakeForwrdPos; |
| 367 | } else if (data.IsPressed(kPanelHPIntakeBackward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 368 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 369 | elevator_wrist_pos_ = kPanelHPIntakeBackwardPos; |
| 370 | } |
| 371 | |
| 372 | // Go to elevator/wrist position. Overrides intake position if pressed so |
| 373 | // we can re-grab the panel. |
| 374 | if (data.IsPressed(kRocketForwardLower)) { |
| 375 | elevator_wrist_pos_ = kPanelForwardLowerPos; |
| 376 | } else if (data.IsPressed(kRocketBackwardLower)) { |
| 377 | elevator_wrist_pos_ = kPanelBackwardLowerPos; |
| 378 | } else if (data.IsPressed(kRocketForwardMiddle)) { |
| 379 | elevator_wrist_pos_ = kPanelForwardMiddlePos; |
| 380 | } else if (data.IsPressed(kRocketBackwardMiddle)) { |
| 381 | elevator_wrist_pos_ = kPanelBackwardMiddlePos; |
| 382 | } else if (data.IsPressed(kRocketForwardUpper)) { |
| 383 | elevator_wrist_pos_ = kPanelForwardUpperPos; |
| 384 | } else if (data.IsPressed(kRocketBackwardUpper)) { |
| 385 | elevator_wrist_pos_ = kPanelBackwardUpperPos; |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 386 | } else if (data.IsPressed(kCargoForward)) { |
| 387 | elevator_wrist_pos_ = kPanelCargoForwardPos; |
| 388 | } else if (data.IsPressed(kCargoBackward)) { |
| 389 | elevator_wrist_pos_ = kPanelCargoBackwardPos; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 390 | } |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 393 | if (switch_ball_) { |
| 394 | if (kDoBallOutake || |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 395 | (kDoBallIntake && |
Austin Schuh | 20dc050 | 2019-03-30 07:24:07 -0700 | [diff] [blame] | 396 | monotonic_now < last_not_has_piece_ + chrono::milliseconds(200))) { |
Austin Schuh | d8098b4 | 2019-05-08 20:48:17 -0700 | [diff] [blame] | 397 | new_superstructure_goal->intake.unsafe_goal = 0.83; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 398 | } |
Austin Schuh | 23a5163 | 2019-02-19 16:50:36 -0800 | [diff] [blame] | 399 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 400 | if (kDoBallIntake && !superstructure_queue.status->has_piece) { |
| 401 | elevator_wrist_pos_ = kBallIntakePos; |
| 402 | new_superstructure_goal->roller_voltage = 9.0; |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 403 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 404 | } else { |
| 405 | if (kDoBallOutake) { |
| 406 | new_superstructure_goal->roller_voltage = -6.0; |
| 407 | } else { |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 408 | new_superstructure_goal->roller_voltage = 0.0; |
| 409 | } |
| 410 | } |
Austin Schuh | 23a5163 | 2019-02-19 16:50:36 -0800 | [diff] [blame] | 411 | } |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 412 | |
Austin Schuh | 457bde3 | 2019-03-17 18:16:41 -0700 | [diff] [blame] | 413 | constexpr double kDeployStiltPosition = 0.5; |
| 414 | |
Austin Schuh | 457bde3 | 2019-03-17 18:16:41 -0700 | [diff] [blame] | 415 | if (data.IsPressed(kFallOver)) { |
| 416 | new_superstructure_goal->stilts.unsafe_goal = 0.71; |
| 417 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
| 418 | new_superstructure_goal->stilts.profile_params.max_acceleration = 1.25; |
Austin Schuh | e2f2248 | 2019-04-13 23:05:43 -0700 | [diff] [blame] | 419 | } else if (data.IsPressed(kHalfStilt)) { |
| 420 | was_above_ = false; |
| 421 | new_superstructure_goal->stilts.unsafe_goal = 0.345; |
| 422 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
| 423 | } else if (data.IsPressed(kDeployStilt) || was_above_) { |
Austin Schuh | 457bde3 | 2019-03-17 18:16:41 -0700 | [diff] [blame] | 424 | new_superstructure_goal->stilts.unsafe_goal = kDeployStiltPosition; |
| 425 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
| 426 | new_superstructure_goal->stilts.profile_params.max_acceleration = 2.0; |
Austin Schuh | 457bde3 | 2019-03-17 18:16:41 -0700 | [diff] [blame] | 427 | } else { |
| 428 | new_superstructure_goal->stilts.unsafe_goal = 0.005; |
| 429 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
| 430 | new_superstructure_goal->stilts.profile_params.max_acceleration = 2.0; |
| 431 | } |
| 432 | |
James Kuszmaul | 0448f14 | 2019-03-24 16:22:34 -0700 | [diff] [blame] | 433 | if (superstructure_queue.status->stilts.position > 0.1) { |
Austin Schuh | 02be8b9 | 2019-03-24 16:04:14 -0700 | [diff] [blame] | 434 | elevator_wrist_pos_ = kClimbPos; |
James Kuszmaul | 1373886 | 2019-04-14 10:48:00 -0700 | [diff] [blame] | 435 | climbed_ = true; |
Austin Schuh | d8a18bb | 2019-03-24 19:21:38 -0700 | [diff] [blame] | 436 | new_superstructure_goal->wrist.profile_params.max_acceleration = 10; |
| 437 | new_superstructure_goal->elevator.profile_params.max_acceleration = 6; |
Austin Schuh | 02be8b9 | 2019-03-24 16:04:14 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Austin Schuh | e2f2248 | 2019-04-13 23:05:43 -0700 | [diff] [blame] | 440 | // If we've been asked to go above deploy and made it up that high, latch |
| 441 | // was_above. |
| 442 | if (new_superstructure_goal->stilts.unsafe_goal > kDeployStiltPosition && |
| 443 | superstructure_queue.status->stilts.position >= kDeployStiltPosition) { |
| 444 | was_above_ = true; |
Austin Schuh | 255ff34 | 2019-04-14 19:56:12 -0700 | [diff] [blame] | 445 | } else if ((superstructure_queue.position->platform_left_detect && |
Austin Schuh | e2f2248 | 2019-04-13 23:05:43 -0700 | [diff] [blame] | 446 | superstructure_queue.position->platform_right_detect) && |
| 447 | !data.IsPressed(kDeployStilt) && !data.IsPressed(kFallOver)) { |
Austin Schuh | e2f2248 | 2019-04-13 23:05:43 -0700 | [diff] [blame] | 448 | was_above_ = false; |
| 449 | } |
| 450 | |
Austin Schuh | 457bde3 | 2019-03-17 18:16:41 -0700 | [diff] [blame] | 451 | if (superstructure_queue.status->stilts.position > kDeployStiltPosition && |
| 452 | new_superstructure_goal->stilts.unsafe_goal == kDeployStiltPosition) { |
| 453 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.30; |
| 454 | new_superstructure_goal->stilts.profile_params.max_acceleration = 0.75; |
| 455 | } |
| 456 | |
James Kuszmaul | 1373886 | 2019-04-14 10:48:00 -0700 | [diff] [blame] | 457 | if ((release_mode_ == ReleaseButtonMode::kRelease && |
| 458 | data.IsPressed(kRelease)) || |
| 459 | data.IsPressed(kReleaseButtonBoard)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 460 | grab_piece_ = false; |
Austin Schuh | 1a8fb57 | 2019-05-08 20:07:58 -0700 | [diff] [blame] | 461 | LOG(INFO, "Releasing due to button\n"); |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 462 | } |
| 463 | |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 464 | if (switch_ball_) { |
| 465 | new_superstructure_goal->suction.gamepiece_mode = 0; |
| 466 | } else { |
| 467 | new_superstructure_goal->suction.gamepiece_mode = 1; |
| 468 | } |
| 469 | |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 470 | vision_control_.set_flip_image(elevator_wrist_pos_.wrist < 0); |
| 471 | |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 472 | new_superstructure_goal->suction.grab_piece = grab_piece_; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 473 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 474 | new_superstructure_goal->elevator.unsafe_goal = |
| 475 | elevator_wrist_pos_.elevator; |
| 476 | new_superstructure_goal->wrist.unsafe_goal = elevator_wrist_pos_.wrist; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 477 | |
| 478 | LOG_STRUCT(DEBUG, "sending goal", *new_superstructure_goal); |
| 479 | if (!new_superstructure_goal.Send()) { |
| 480 | LOG(ERROR, "Sending superstructure goal failed.\n"); |
| 481 | } |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 482 | |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 483 | if (monotonic_now > |
| 484 | last_vision_control_ + ::std::chrono::milliseconds(50)) { |
Tyler Chatow | 4fedeea | 2019-03-10 15:33:36 -0700 | [diff] [blame] | 485 | video_tx_->Send(vision_control_); |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 486 | last_vision_control_ = monotonic_now; |
Tyler Chatow | 4fedeea | 2019-03-10 15:33:36 -0700 | [diff] [blame] | 487 | } |
Austin Schuh | 4e2629d | 2019-03-28 14:44:37 -0700 | [diff] [blame] | 488 | |
| 489 | { |
Austin Schuh | 5671a8c | 2019-05-19 17:01:04 -0700 | [diff] [blame] | 490 | auto camera_log_message = camera_log_sender_.MakeMessage(); |
Austin Schuh | 4e2629d | 2019-03-28 14:44:37 -0700 | [diff] [blame] | 491 | camera_log_message->log = data.IsPressed(kCameraLog); |
| 492 | LOG_STRUCT(DEBUG, "camera_log", *camera_log_message); |
| 493 | camera_log_message.Send(); |
| 494 | } |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | private: |
Austin Schuh | a964406 | 2019-03-28 14:31:52 -0700 | [diff] [blame] | 498 | uint32_t GetAutonomousMode() override { |
| 499 | ::frc971::autonomous::auto_mode.FetchLatest(); |
| 500 | if (::frc971::autonomous::auto_mode.get() == nullptr) { |
| 501 | LOG(WARNING, "no auto mode values\n"); |
| 502 | return 0; |
| 503 | } |
| 504 | return ::frc971::autonomous::auto_mode->mode; |
| 505 | } |
| 506 | |
Austin Schuh | c087b10 | 2019-05-12 15:33:12 -0700 | [diff] [blame] | 507 | ::aos::Sender<::y2019::control_loops::drivetrain::TargetSelectorHint> |
| 508 | target_selector_hint_sender_; |
| 509 | |
Austin Schuh | eb99d07 | 2019-05-12 21:03:38 -0700 | [diff] [blame] | 510 | ::aos::Sender<::frc971::control_loops::drivetrain::LocalizerControl> |
| 511 | localizer_control_sender_; |
| 512 | |
Austin Schuh | 5671a8c | 2019-05-19 17:01:04 -0700 | [diff] [blame] | 513 | ::aos::Sender<::y2019::CameraLog> camera_log_sender_; |
| 514 | |
Austin Schuh | e2f2248 | 2019-04-13 23:05:43 -0700 | [diff] [blame] | 515 | // Bool to track if we've been above the deploy position. Once this bool is |
| 516 | // set, don't let the stilts retract until we see the platform. |
| 517 | bool was_above_ = false; |
| 518 | |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 519 | // Current goals here. |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 520 | ElevatorWristPosition elevator_wrist_pos_ = kStowPos; |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 521 | bool grab_piece_ = false; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 522 | |
| 523 | bool switch_ball_ = false; |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 524 | |
James Kuszmaul | 1373886 | 2019-04-14 10:48:00 -0700 | [diff] [blame] | 525 | bool climbed_ = false; |
| 526 | |
| 527 | enum class ReleaseButtonMode { |
| 528 | kBallIntake, |
| 529 | kRelease, |
| 530 | }; |
| 531 | |
| 532 | ReleaseButtonMode release_mode_ = ReleaseButtonMode::kRelease; |
| 533 | aos::monotonic_clock::time_point last_release_button_press_ = |
| 534 | aos::monotonic_clock::min_time; |
| 535 | |
Tyler Chatow | e024145 | 2019-03-08 21:07:50 -0800 | [diff] [blame] | 536 | VisionControl vision_control_; |
| 537 | ::std::unique_ptr<ProtoTXUdpSocket<VisionControl>> video_tx_; |
Tyler Chatow | 4fedeea | 2019-03-10 15:33:36 -0700 | [diff] [blame] | 538 | ::aos::monotonic_clock::time_point last_vision_control_ = |
| 539 | ::aos::monotonic_clock::time_point::min(); |
Austin Schuh | aab7e16 | 2019-03-13 22:44:58 -0700 | [diff] [blame] | 540 | |
| 541 | // Time at which we last did not have a game piece. |
| 542 | ::aos::monotonic_clock::time_point last_not_has_piece_ = |
| 543 | ::aos::monotonic_clock::time_point::min(); |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 544 | }; |
| 545 | |
| 546 | } // namespace joysticks |
| 547 | } // namespace input |
| 548 | } // namespace y2019 |
| 549 | |
| 550 | int main() { |
| 551 | ::aos::Init(-1); |
| 552 | ::aos::ShmEventLoop event_loop; |
| 553 | ::y2019::input::joysticks::Reader reader(&event_loop); |
| 554 | reader.Run(); |
| 555 | ::aos::Cleanup(); |
| 556 | } |