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> |
| 5 | |
| 6 | #include "aos/actions/actions.h" |
| 7 | #include "aos/init.h" |
| 8 | #include "aos/input/action_joystick_input.h" |
| 9 | #include "aos/input/driver_station_data.h" |
| 10 | #include "aos/input/drivetrain_input.h" |
| 11 | #include "aos/input/joystick_input.h" |
| 12 | #include "aos/logging/logging.h" |
| 13 | #include "aos/logging/logging.h" |
| 14 | #include "aos/util/log_interval.h" |
| 15 | #include "frc971/autonomous/auto.q.h" |
| 16 | #include "frc971/autonomous/base_autonomous_actor.h" |
| 17 | #include "frc971/control_loops/drivetrain/drivetrain.q.h" |
| 18 | |
| 19 | #include "y2019/control_loops/drivetrain/drivetrain_base.h" |
| 20 | #include "y2019/control_loops/superstructure/superstructure.q.h" |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 21 | #include "y2019/status_light.q.h" |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 22 | |
| 23 | using ::y2019::control_loops::superstructure::superstructure_queue; |
| 24 | using ::aos::input::driver_station::ButtonLocation; |
| 25 | using ::aos::input::driver_station::ControlBit; |
| 26 | using ::aos::input::driver_station::JoystickAxis; |
| 27 | using ::aos::input::driver_station::POVLocation; |
| 28 | |
| 29 | namespace y2019 { |
| 30 | namespace input { |
| 31 | namespace joysticks { |
| 32 | |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 33 | const ButtonLocation kSuctionBall(3, 13); |
| 34 | const ButtonLocation kSuctionHatch(3, 12); |
| 35 | const ButtonLocation kDeployStilt(3, 8); |
Sabina Davis | 069cbca | 2019-03-08 23:35:18 -0800 | [diff] [blame] | 36 | const ButtonLocation kHalfStilt(3, 6); |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 37 | const ButtonLocation kFallOver(3, 9); |
Austin Schuh | 2cf16b8 | 2019-02-15 23:23:22 -0800 | [diff] [blame] | 38 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 39 | struct ElevatorWristPosition { |
| 40 | double elevator; |
| 41 | double wrist; |
| 42 | }; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 43 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 44 | const ButtonLocation kRocketForwardLower(5, 1); |
| 45 | const ButtonLocation kRocketForwardMiddle(5, 2); |
| 46 | const ButtonLocation kRocketForwardUpper(5, 4); |
| 47 | const ButtonLocation kCargoForward(5, 3); |
| 48 | |
| 49 | const POVLocation kRocketBackwardUnpressed(5, -1); |
| 50 | const POVLocation kRocketBackwardLower(5, 180); |
| 51 | const POVLocation kRocketBackwardMiddle(5, 90); |
| 52 | const POVLocation kRocketBackwardUpper(5, 0); |
| 53 | const POVLocation kCargoBackward(5, 270); |
| 54 | |
| 55 | const ButtonLocation kPanelSwitch(5, 7); |
| 56 | const ButtonLocation kCargoSwitch(5, 8); |
| 57 | |
| 58 | const ButtonLocation kBallHPIntakeForward(5, 6); |
| 59 | const ButtonLocation kBallHPIntakeBackward(5, 5); |
| 60 | const JoystickAxis kBallOutake(5, 3); |
| 61 | const JoystickAxis kBallIntake(5, 4); |
| 62 | |
| 63 | const ButtonLocation kPanelHPIntakeForward(5, 6); |
| 64 | const ButtonLocation kPanelHPIntakeBackward(5, 5); |
| 65 | |
| 66 | const ButtonLocation kRelease(2, 4); |
| 67 | |
Tyler Chatow | 07c906b | 2019-03-09 21:29:06 -0800 | [diff] [blame^] | 68 | const ButtonLocation kAutoPanel(3, 10); |
| 69 | const ButtonLocation kAutoPanelIntermediate(4, 6); |
| 70 | |
| 71 | const ElevatorWristPosition kAutoPanelPos{0.0, -M_PI / 2.0}; |
| 72 | const ElevatorWristPosition kAutoPanelIntermediatePos{0.34, -M_PI / 2.0}; |
| 73 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 74 | const ElevatorWristPosition kStowPos{0.36, 0.0}; |
| 75 | |
| 76 | const ElevatorWristPosition kPanelHPIntakeForwrdPos{0.04, M_PI / 2.0}; |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 77 | const ElevatorWristPosition kPanelHPIntakeBackwardPos{0.05, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 78 | |
| 79 | const ElevatorWristPosition kPanelForwardLowerPos{0.0, M_PI / 2.0}; |
| 80 | const ElevatorWristPosition kPanelBackwardLowerPos{0.0, -M_PI / 2.0}; |
| 81 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 82 | const ElevatorWristPosition kPanelForwardMiddlePos{0.75, M_PI / 2.0}; |
| 83 | const ElevatorWristPosition kPanelBackwardMiddlePos{0.78, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 84 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 85 | const ElevatorWristPosition kPanelForwardUpperPos{1.51, M_PI / 2.0}; |
| 86 | const ElevatorWristPosition kPanelBackwardUpperPos{1.50, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 87 | |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 88 | const ElevatorWristPosition kPanelCargoForwardPos{0.0, M_PI / 2.0}; |
| 89 | const ElevatorWristPosition kPanelCargoBackwardPos{0.0, -M_PI / 2.0}; |
| 90 | |
| 91 | const ElevatorWristPosition kBallForwardLowerPos{0.46, M_PI / 2.0}; |
| 92 | const ElevatorWristPosition kBallBackwardLowerPos{0.15, -M_PI / 2.0}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 93 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 94 | const ElevatorWristPosition kBallForwardMiddlePos{1.16, 1.546}; |
| 95 | const ElevatorWristPosition kBallBackwardMiddlePos{0.876021, -1.546}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 96 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 97 | const ElevatorWristPosition kBallForwardUpperPos{1.50, 0.961}; |
| 98 | const ElevatorWristPosition kBallBackwardUpperPos{1.41, -1.217}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 99 | |
Sabina Davis | e48004f | 2019-03-02 23:15:24 -0800 | [diff] [blame] | 100 | const ElevatorWristPosition kBallCargoForwardPos{0.699044, 1.353}; |
| 101 | const ElevatorWristPosition kBallCargoBackwardPos{0.828265, -1.999}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 102 | |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 103 | const ElevatorWristPosition kBallHPIntakeForwardPos{0.55, 1.097}; |
| 104 | const ElevatorWristPosition kBallHPIntakeBackwardPos{0.89, -2.018}; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 105 | |
| 106 | const ElevatorWristPosition kBallIntakePos{0.29, 2.14}; |
Austin Schuh | 2cf16b8 | 2019-02-15 23:23:22 -0800 | [diff] [blame] | 107 | |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 108 | class Reader : public ::aos::input::ActionJoystickInput { |
| 109 | public: |
| 110 | Reader(::aos::EventLoop *event_loop) |
| 111 | : ::aos::input::ActionJoystickInput( |
| 112 | event_loop, |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 113 | ::y2019::control_loops::drivetrain::GetDrivetrainConfig()) { |
| 114 | superstructure_queue.goal.FetchLatest(); |
| 115 | if (superstructure_queue.goal.get()) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 116 | grab_piece_ = superstructure_queue.goal->suction.grab_piece; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 117 | } |
| 118 | } |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 119 | |
| 120 | void HandleTeleop(const ::aos::input::driver_station::Data &data) { |
| 121 | superstructure_queue.position.FetchLatest(); |
| 122 | superstructure_queue.status.FetchLatest(); |
| 123 | if (!superstructure_queue.status.get() || |
| 124 | !superstructure_queue.position.get()) { |
| 125 | LOG(ERROR, "Got no superstructure status packet.\n"); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | auto new_superstructure_goal = superstructure_queue.goal.MakeMessage(); |
| 130 | |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 131 | if (data.IsPressed(kSuctionBall)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 132 | grab_piece_ = true; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 133 | } else if (data.IsPressed(kSuctionHatch)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 134 | grab_piece_ = true; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 135 | } else if (data.IsPressed(kRelease) || |
| 136 | !superstructure_queue.status->has_piece) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 137 | grab_piece_ = false; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 138 | } |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 139 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 140 | if (data.IsPressed(kRocketBackwardUnpressed)) { |
| 141 | elevator_wrist_pos_ = kStowPos; |
| 142 | } |
| 143 | new_superstructure_goal->intake.unsafe_goal = -1.2; |
| 144 | new_superstructure_goal->roller_voltage = 0.0; |
| 145 | |
| 146 | const bool kDoBallIntake = data.GetAxis(kBallIntake) > 0.9; |
| 147 | const bool kDoBallOutake = data.GetAxis(kBallOutake) > 0.9; |
| 148 | |
| 149 | if (data.IsPressed(kPanelSwitch)) { |
| 150 | switch_ball_ = false; |
| 151 | } else if (data.IsPressed(kCargoSwitch)) { |
| 152 | switch_ball_ = true; |
| 153 | } |
| 154 | |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 155 | // TODO(sabina): max height please? |
Austin Schuh | 77ac321 | 2019-02-19 16:50:14 -0800 | [diff] [blame] | 156 | if (data.IsPressed(kFallOver)) { |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 157 | new_superstructure_goal->stilts.unsafe_goal = 0.71; |
Michael Schuh | 587dcb5 | 2019-02-28 21:31:03 -0800 | [diff] [blame] | 158 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 159 | new_superstructure_goal->stilts.profile_params.max_acceleration = 2.0; |
Austin Schuh | 77ac321 | 2019-02-19 16:50:14 -0800 | [diff] [blame] | 160 | } else if (data.IsPressed(kDeployStilt)) { |
| 161 | new_superstructure_goal->stilts.unsafe_goal = 0.50; |
Michael Schuh | 587dcb5 | 2019-02-28 21:31:03 -0800 | [diff] [blame] | 162 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 163 | if (stilts_was_above_) { |
| 164 | new_superstructure_goal->stilts.profile_params.max_acceleration = 0.75; |
| 165 | } else { |
| 166 | new_superstructure_goal->stilts.profile_params.max_acceleration = 2.0; |
| 167 | } |
Sabina Davis | 069cbca | 2019-03-08 23:35:18 -0800 | [diff] [blame] | 168 | } else if (data.IsPressed(kHalfStilt)) { |
| 169 | new_superstructure_goal->stilts.unsafe_goal = 0.345; |
| 170 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.65; |
| 171 | new_superstructure_goal->stilts.profile_params.max_acceleration = 0.75; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 172 | } else { |
Sabina Davis | bfdeb36 | 2019-03-09 16:20:01 -0800 | [diff] [blame] | 173 | new_superstructure_goal->stilts.unsafe_goal = 0.005; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 174 | new_superstructure_goal->stilts.profile_params.max_velocity = 0.25; |
| 175 | new_superstructure_goal->stilts.profile_params.max_acceleration = 2.0; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 176 | } |
| 177 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 178 | if (superstructure_queue.status->stilts.position > 0.65) { |
| 179 | stilts_was_above_ = true; |
| 180 | } else if (superstructure_queue.status->stilts.position < 0.1) { |
| 181 | stilts_was_above_ = false; |
Austin Schuh | 2cf16b8 | 2019-02-15 23:23:22 -0800 | [diff] [blame] | 182 | } |
| 183 | |
Tyler Chatow | 07c906b | 2019-03-09 21:29:06 -0800 | [diff] [blame^] | 184 | if (data.IsPressed(kAutoPanel)) { |
| 185 | elevator_wrist_pos_ = kAutoPanelPos; |
| 186 | } else if (data.IsPressed(kAutoPanelIntermediate)) { |
| 187 | elevator_wrist_pos_ = kAutoPanelIntermediatePos; |
| 188 | } |
| 189 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 190 | if (switch_ball_) { |
| 191 | if (superstructure_queue.status->has_piece) { |
| 192 | new_superstructure_goal->wrist.profile_params.max_acceleration = 20; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 193 | } |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 194 | |
| 195 | // Go to intake position and apply vacuum |
| 196 | if (data.IsPressed(kBallHPIntakeForward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 197 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 198 | elevator_wrist_pos_ = kBallHPIntakeForwardPos; |
| 199 | } else if (data.IsPressed(kBallHPIntakeBackward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 200 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 201 | elevator_wrist_pos_ = kBallHPIntakeBackwardPos; |
| 202 | } |
| 203 | |
| 204 | // Go to elevator/wrist position. Overrides intake position if pressed so |
| 205 | // we can re-grab the ball. |
| 206 | if (data.IsPressed(kRocketForwardLower)) { |
| 207 | elevator_wrist_pos_ = kBallForwardLowerPos; |
| 208 | } else if (data.IsPressed(kRocketBackwardLower)) { |
| 209 | elevator_wrist_pos_ = kBallBackwardLowerPos; |
| 210 | } else if (data.IsPressed(kRocketForwardMiddle)) { |
| 211 | elevator_wrist_pos_ = kBallForwardMiddlePos; |
| 212 | } else if (data.IsPressed(kRocketBackwardMiddle)) { |
| 213 | elevator_wrist_pos_ = kBallBackwardMiddlePos; |
| 214 | } else if (data.IsPressed(kRocketForwardUpper)) { |
| 215 | elevator_wrist_pos_ = kBallForwardUpperPos; |
| 216 | } else if (data.IsPressed(kRocketBackwardUpper)) { |
| 217 | elevator_wrist_pos_ = kBallBackwardUpperPos; |
| 218 | } else if (data.IsPressed(kCargoForward)) { |
| 219 | elevator_wrist_pos_ = kBallCargoForwardPos; |
| 220 | } else if (data.IsPressed(kCargoBackward)) { |
| 221 | elevator_wrist_pos_ = kBallCargoBackwardPos; |
| 222 | } |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 223 | } else { |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 224 | if (data.IsPressed(kPanelHPIntakeForward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 225 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 226 | elevator_wrist_pos_ = kPanelHPIntakeForwrdPos; |
| 227 | } else if (data.IsPressed(kPanelHPIntakeBackward)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 228 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 229 | elevator_wrist_pos_ = kPanelHPIntakeBackwardPos; |
| 230 | } |
| 231 | |
| 232 | // Go to elevator/wrist position. Overrides intake position if pressed so |
| 233 | // we can re-grab the panel. |
| 234 | if (data.IsPressed(kRocketForwardLower)) { |
| 235 | elevator_wrist_pos_ = kPanelForwardLowerPos; |
| 236 | } else if (data.IsPressed(kRocketBackwardLower)) { |
| 237 | elevator_wrist_pos_ = kPanelBackwardLowerPos; |
| 238 | } else if (data.IsPressed(kRocketForwardMiddle)) { |
| 239 | elevator_wrist_pos_ = kPanelForwardMiddlePos; |
| 240 | } else if (data.IsPressed(kRocketBackwardMiddle)) { |
| 241 | elevator_wrist_pos_ = kPanelBackwardMiddlePos; |
| 242 | } else if (data.IsPressed(kRocketForwardUpper)) { |
| 243 | elevator_wrist_pos_ = kPanelForwardUpperPos; |
| 244 | } else if (data.IsPressed(kRocketBackwardUpper)) { |
| 245 | elevator_wrist_pos_ = kPanelBackwardUpperPos; |
Sabina Davis | e6fe6c5 | 2019-03-03 15:48:51 -0800 | [diff] [blame] | 246 | } else if (data.IsPressed(kCargoForward)) { |
| 247 | elevator_wrist_pos_ = kPanelCargoForwardPos; |
| 248 | } else if (data.IsPressed(kCargoBackward)) { |
| 249 | elevator_wrist_pos_ = kPanelCargoBackwardPos; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 250 | } |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 251 | } |
| 252 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 253 | if (switch_ball_) { |
| 254 | if (kDoBallOutake || |
| 255 | (kDoBallIntake && !superstructure_queue.status->has_piece)) { |
| 256 | new_superstructure_goal->intake.unsafe_goal = 0.959327; |
| 257 | } |
Austin Schuh | 23a5163 | 2019-02-19 16:50:36 -0800 | [diff] [blame] | 258 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 259 | if (kDoBallIntake && !superstructure_queue.status->has_piece) { |
| 260 | elevator_wrist_pos_ = kBallIntakePos; |
| 261 | new_superstructure_goal->roller_voltage = 9.0; |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 262 | grab_piece_ = true; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 263 | } else { |
| 264 | if (kDoBallOutake) { |
| 265 | new_superstructure_goal->roller_voltage = -6.0; |
| 266 | } else { |
| 267 | new_superstructure_goal->intake.unsafe_goal = -1.2; |
| 268 | new_superstructure_goal->roller_voltage = 0.0; |
| 269 | } |
| 270 | } |
Austin Schuh | 23a5163 | 2019-02-19 16:50:36 -0800 | [diff] [blame] | 271 | } |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 272 | |
| 273 | if (data.IsPressed(kRelease)) { |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 274 | grab_piece_ = false; |
Austin Schuh | 1a17e13 | 2019-02-17 15:05:06 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 277 | if (switch_ball_) { |
| 278 | new_superstructure_goal->suction.gamepiece_mode = 0; |
| 279 | } else { |
| 280 | new_superstructure_goal->suction.gamepiece_mode = 1; |
| 281 | } |
| 282 | |
| 283 | new_superstructure_goal->suction.grab_piece = grab_piece_; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 284 | |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 285 | new_superstructure_goal->elevator.unsafe_goal = |
| 286 | elevator_wrist_pos_.elevator; |
| 287 | new_superstructure_goal->wrist.unsafe_goal = elevator_wrist_pos_.wrist; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 288 | |
| 289 | LOG_STRUCT(DEBUG, "sending goal", *new_superstructure_goal); |
| 290 | if (!new_superstructure_goal.Send()) { |
| 291 | LOG(ERROR, "Sending superstructure goal failed.\n"); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | private: |
| 296 | // Current goals here. |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 297 | ElevatorWristPosition elevator_wrist_pos_ = kStowPos; |
Sabina Davis | c632934 | 2019-03-01 20:44:42 -0800 | [diff] [blame] | 298 | bool grab_piece_ = false; |
Tyler Chatow | 7bcb52f | 2019-02-24 00:16:54 -0800 | [diff] [blame] | 299 | |
| 300 | bool switch_ball_ = false; |
| 301 | bool stilts_was_above_ = false; |
Sabina Davis | 91b2360 | 2019-01-21 00:06:01 -0800 | [diff] [blame] | 302 | }; |
| 303 | |
| 304 | } // namespace joysticks |
| 305 | } // namespace input |
| 306 | } // namespace y2019 |
| 307 | |
| 308 | int main() { |
| 309 | ::aos::Init(-1); |
| 310 | ::aos::ShmEventLoop event_loop; |
| 311 | ::y2019::input::joysticks::Reader reader(&event_loop); |
| 312 | reader.Run(); |
| 313 | ::aos::Cleanup(); |
| 314 | } |