Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <unistd.h> |
| 4 | #include <math.h> |
| 5 | |
| 6 | #include "aos/linux_code/init.h" |
| 7 | #include "aos/input/joystick_input.h" |
| 8 | #include "aos/common/input/driver_station_data.h" |
| 9 | #include "aos/common/logging/logging.h" |
| 10 | #include "aos/common/util/log_interval.h" |
| 11 | #include "aos/common/time.h" |
| 12 | #include "aos/common/actions/actions.h" |
| 13 | |
| 14 | #include "frc971/control_loops/drivetrain/drivetrain.q.h" |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 15 | #include "y2016/control_loops/shooter/shooter.q.h" |
| 16 | #include "y2016/control_loops/superstructure/superstructure.q.h" |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 17 | #include "y2016/control_loops/superstructure/superstructure.h" |
Comran Morshed | aa0573c | 2016-03-05 19:05:54 +0000 | [diff] [blame] | 18 | #include "y2016/queues/ball_detector.q.h" |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 19 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 20 | #include "y2016/constants.h" |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 21 | #include "frc971/queues/gyro.q.h" |
| 22 | #include "frc971/autonomous/auto.q.h" |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 23 | #include "y2016/actors/autonomous_actor.h" |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 24 | |
| 25 | using ::frc971::control_loops::drivetrain_queue; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 26 | using ::y2016::control_loops::shooter::shooter_queue; |
| 27 | using ::y2016::control_loops::superstructure_queue; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 28 | |
| 29 | using ::aos::input::driver_station::ButtonLocation; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 30 | using ::aos::input::driver_station::ControlBit; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 31 | using ::aos::input::driver_station::JoystickAxis; |
| 32 | using ::aos::input::driver_station::POVLocation; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 33 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 34 | namespace y2016 { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 35 | namespace input { |
| 36 | namespace joysticks { |
| 37 | |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 38 | namespace { |
| 39 | |
| 40 | constexpr double kMaxIntakeAngleBeforeArmInterference = control_loops:: |
| 41 | superstructure::CollisionAvoidance::kMaxIntakeAngleBeforeArmInterference; |
| 42 | |
| 43 | } // namespace |
| 44 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 45 | const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2); |
Campbell Crowley | 5b27f02 | 2016-02-20 16:55:35 -0800 | [diff] [blame] | 46 | const ButtonLocation kShiftHigh(2, 3), kShiftHigh2(2, 2), kShiftLow(2, 1); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 47 | const ButtonLocation kQuickTurn(1, 5); |
| 48 | |
Austin Schuh | 781cdcc | 2016-03-12 13:03:12 -0800 | [diff] [blame] | 49 | const ButtonLocation kTurn1(1, 7); |
| 50 | const ButtonLocation kTurn2(1, 11); |
| 51 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 52 | // Buttons on the lexan driver station to get things running on bring-up day. |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 53 | const ButtonLocation kIntakeDown(3, 11); |
| 54 | const POVLocation kFrontLong(3, 180); |
| 55 | const POVLocation kBackLong(3, 0); |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 56 | const POVLocation kBackFender(3, 90); |
| 57 | const POVLocation kFrontFender(3, 270); |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 58 | const ButtonLocation kTest3(3, 7); |
| 59 | const ButtonLocation kIntakeIn(3, 12); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 60 | const ButtonLocation kTest5(3, 8); |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 61 | const ButtonLocation kFire(3, 3); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 62 | const ButtonLocation kTest7(3, 5); |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 63 | const ButtonLocation kIntakeOut(3, 9); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 64 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 65 | class Reader : public ::aos::input::JoystickInput { |
| 66 | public: |
| 67 | Reader() |
Austin Schuh | 94596dd | 2016-03-13 21:41:26 -0700 | [diff] [blame] | 68 | : is_high_gear_(true), |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 69 | intake_goal_(0.0), |
| 70 | shoulder_goal_(M_PI / 2.0), |
| 71 | wrist_goal_(0.0) {} |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 72 | |
| 73 | void RunIteration(const ::aos::input::driver_station::Data &data) override { |
| 74 | bool last_auto_running = auto_running_; |
| 75 | auto_running_ = data.GetControlBit(ControlBit::kAutonomous) && |
| 76 | data.GetControlBit(ControlBit::kEnabled); |
| 77 | if (auto_running_ != last_auto_running) { |
| 78 | if (auto_running_) { |
| 79 | StartAuto(); |
| 80 | } else { |
| 81 | StopAuto(); |
| 82 | } |
| 83 | } |
| 84 | |
Austin Schuh | 94596dd | 2016-03-13 21:41:26 -0700 | [diff] [blame] | 85 | if (!data.GetControlBit(ControlBit::kEnabled)) { |
| 86 | // If we are not enabled, reset the waiting for zero bit. |
| 87 | LOG(DEBUG, "Waiting for zero.\n"); |
| 88 | waiting_for_zero_ = true; |
| 89 | is_high_gear_ = true; |
| 90 | } |
| 91 | |
| 92 | if (!auto_running_) { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 93 | HandleDrivetrain(data); |
| 94 | HandleTeleop(data); |
| 95 | } |
Austin Schuh | 81d71db | 2016-03-15 20:56:24 -0700 | [diff] [blame] | 96 | |
| 97 | // Process any pending actions. |
| 98 | action_queue_.Tick(); |
| 99 | was_running_ = action_queue_.Running(); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void HandleDrivetrain(const ::aos::input::driver_station::Data &data) { |
| 103 | bool is_control_loop_driving = false; |
Austin Schuh | 781cdcc | 2016-03-12 13:03:12 -0800 | [diff] [blame] | 104 | static double left_goal = 0.0; |
| 105 | static double right_goal = 0.0; |
| 106 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 107 | const double wheel = -data.GetAxis(kSteeringWheel); |
| 108 | const double throttle = -data.GetAxis(kDriveThrottle); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 109 | |
Austin Schuh | 781cdcc | 2016-03-12 13:03:12 -0800 | [diff] [blame] | 110 | if (data.PosEdge(kTurn1) || data.PosEdge(kTurn2)) { |
| 111 | drivetrain_queue.status.FetchLatest(); |
| 112 | if (drivetrain_queue.status.get()) { |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 113 | left_goal = drivetrain_queue.status->estimated_left_position; |
| 114 | right_goal = drivetrain_queue.status->estimated_right_position; |
Austin Schuh | 781cdcc | 2016-03-12 13:03:12 -0800 | [diff] [blame] | 115 | } |
| 116 | } |
| 117 | if (data.IsPressed(kTurn1) || data.IsPressed(kTurn2)) { |
| 118 | is_control_loop_driving = true; |
| 119 | } |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 120 | if (!drivetrain_queue.goal.MakeWithBuilder() |
| 121 | .steering(wheel) |
| 122 | .throttle(throttle) |
| 123 | .highgear(is_high_gear_) |
| 124 | .quickturn(data.IsPressed(kQuickTurn)) |
| 125 | .control_loop_driving(is_control_loop_driving) |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 126 | .left_goal(left_goal - wheel * 0.5 + throttle * 0.3) |
| 127 | .right_goal(right_goal + wheel * 0.5 + throttle * 0.3) |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 128 | .left_velocity_goal(0) |
| 129 | .right_velocity_goal(0) |
| 130 | .Send()) { |
| 131 | LOG(WARNING, "sending stick values failed\n"); |
| 132 | } |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 133 | |
Campbell Crowley | 5b27f02 | 2016-02-20 16:55:35 -0800 | [diff] [blame] | 134 | if (data.PosEdge(kShiftLow)) { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 135 | is_high_gear_ = false; |
| 136 | } |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 137 | |
Campbell Crowley | 5b27f02 | 2016-02-20 16:55:35 -0800 | [diff] [blame] | 138 | if (data.PosEdge(kShiftHigh) || data.PosEdge(kShiftHigh2)) { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 139 | is_high_gear_ = true; |
| 140 | } |
| 141 | } |
| 142 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 143 | void HandleTeleop(const ::aos::input::driver_station::Data &data) { |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 144 | // Default the intake to up. |
| 145 | intake_goal_ = constants::Values::kIntakeRange.upper - 0.04; |
| 146 | |
| 147 | bool force_lights_on = false; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 148 | if (!data.GetControlBit(ControlBit::kEnabled)) { |
| 149 | action_queue_.CancelAllActions(); |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 150 | LOG(DEBUG, "Canceling\n"); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 153 | superstructure_queue.status.FetchLatest(); |
| 154 | if (!superstructure_queue.status.get()) { |
| 155 | LOG(ERROR, "Got no superstructure status packet.\n"); |
| 156 | } |
| 157 | |
| 158 | if (superstructure_queue.status.get() && |
| 159 | superstructure_queue.status->zeroed) { |
| 160 | if (waiting_for_zero_) { |
Austin Schuh | 94596dd | 2016-03-13 21:41:26 -0700 | [diff] [blame] | 161 | LOG(DEBUG, "Zeroed! Starting teleop mode.\n"); |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 162 | waiting_for_zero_ = false; |
| 163 | } |
| 164 | } else { |
| 165 | waiting_for_zero_ = true; |
| 166 | } |
| 167 | |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 168 | if (data.IsPressed(kFrontLong)) { |
| 169 | // Forwards shot |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 170 | shoulder_goal_ = M_PI / 2.0 - 0.2; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 171 | wrist_goal_ = M_PI + 0.42; |
| 172 | shooter_velocity_ = 640.0; |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 173 | intake_goal_ = kMaxIntakeAngleBeforeArmInterference; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 174 | } else if (data.IsPressed(kBackLong)) { |
| 175 | // Backwards shot |
| 176 | shoulder_goal_ = M_PI / 2.0 - 0.2; |
| 177 | wrist_goal_ = -0.59; |
| 178 | shooter_velocity_ = 640.0; |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 179 | intake_goal_ = kMaxIntakeAngleBeforeArmInterference; |
| 180 | } else if (data.IsPressed(kBackFender)) { |
| 181 | // Fender shot back |
| 182 | shoulder_goal_ = 0.65; |
| 183 | wrist_goal_ = -1.0; |
| 184 | shooter_velocity_ = 550.0; |
| 185 | intake_goal_ = kMaxIntakeAngleBeforeArmInterference; |
| 186 | } else if (data.IsPressed(kFrontFender)) { |
| 187 | // Fender shot back |
| 188 | shoulder_goal_ = 1.45; |
| 189 | wrist_goal_ = 2.5 + 1.7; |
| 190 | shooter_velocity_ = 550.0; |
| 191 | intake_goal_ = kMaxIntakeAngleBeforeArmInterference; |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 192 | } else { |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 193 | wrist_goal_ = 0.0; |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 194 | shoulder_goal_ = -0.010; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 195 | shooter_velocity_ = 0.0; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 198 | if (data.IsPressed(kTest3)) { |
| 199 | wrist_goal_ = 0.0; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Comran Morshed | aa0573c | 2016-03-05 19:05:54 +0000 | [diff] [blame] | 202 | bool ball_detected = false; |
| 203 | ::y2016::sensors::ball_detector.FetchLatest(); |
| 204 | if (::y2016::sensors::ball_detector.get()) { |
| 205 | ball_detected = ::y2016::sensors::ball_detector->voltage > 2.5; |
| 206 | } |
| 207 | if (data.PosEdge(kIntakeIn)) { |
| 208 | saw_ball_when_started_intaking_ = ball_detected; |
| 209 | } |
| 210 | |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 211 | if (data.IsPressed(kIntakeIn)) { |
| 212 | is_intaking_ = (!ball_detected || saw_ball_when_started_intaking_); |
| 213 | if (ball_detected) { |
| 214 | force_lights_on = true; |
| 215 | } |
| 216 | } else { |
| 217 | is_intaking_ = false; |
| 218 | } |
| 219 | |
| 220 | if (data.IsPressed(kIntakeDown)) { |
| 221 | if (is_intaking_) { |
| 222 | intake_goal_ = 0.1; |
| 223 | } else { |
| 224 | intake_goal_ = -0.05; |
| 225 | } |
| 226 | } |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 227 | |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 228 | if (data.IsPressed(kFire) && shooter_velocity_ != 0.0) { |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 229 | fire_ = true; |
| 230 | } else { |
| 231 | fire_ = false; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | if (data.PosEdge(kTest7)) { |
| 235 | } |
| 236 | |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 237 | is_outtaking_ = data.IsPressed(kIntakeOut); |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 238 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 239 | if (!waiting_for_zero_) { |
| 240 | if (!action_queue_.Running()) { |
| 241 | auto new_superstructure_goal = superstructure_queue.goal.MakeMessage(); |
| 242 | new_superstructure_goal->angle_intake = intake_goal_; |
| 243 | new_superstructure_goal->angle_shoulder = shoulder_goal_; |
| 244 | new_superstructure_goal->angle_wrist = wrist_goal_; |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 245 | |
| 246 | new_superstructure_goal->max_angular_velocity_intake = 7.0; |
| 247 | new_superstructure_goal->max_angular_velocity_shoulder = 4.0; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 248 | new_superstructure_goal->max_angular_velocity_wrist = 10.0; |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 249 | new_superstructure_goal->max_angular_acceleration_intake = 40.0; |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 250 | new_superstructure_goal->max_angular_acceleration_shoulder = 10.0; |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 251 | new_superstructure_goal->max_angular_acceleration_wrist = 25.0; |
| 252 | |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 253 | // Granny mode |
Austin Schuh | 4ea06c1 | 2016-03-12 17:54:31 -0800 | [diff] [blame] | 254 | /* |
Austin Schuh | 3f0b119 | 2016-03-12 13:03:56 -0800 | [diff] [blame] | 255 | new_superstructure_goal->max_angular_velocity_intake = 0.2; |
| 256 | new_superstructure_goal->max_angular_velocity_shoulder = 0.2; |
| 257 | new_superstructure_goal->max_angular_velocity_wrist = 0.2; |
| 258 | new_superstructure_goal->max_angular_acceleration_intake = 1.0; |
| 259 | new_superstructure_goal->max_angular_acceleration_shoulder = 1.0; |
| 260 | new_superstructure_goal->max_angular_acceleration_wrist = 1.0; |
| 261 | */ |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 262 | if (is_intaking_) { |
| 263 | new_superstructure_goal->voltage_top_rollers = 12.0; |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 264 | new_superstructure_goal->voltage_bottom_rollers = 12.0; |
| 265 | } else if (is_outtaking_) { |
| 266 | new_superstructure_goal->voltage_top_rollers = -12.0; |
| 267 | new_superstructure_goal->voltage_bottom_rollers = -7.0; |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 268 | } else { |
| 269 | new_superstructure_goal->voltage_top_rollers = 0.0; |
| 270 | new_superstructure_goal->voltage_bottom_rollers = 0.0; |
| 271 | } |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 272 | |
| 273 | if (!new_superstructure_goal.Send()) { |
| 274 | LOG(ERROR, "Sending superstructure goal failed.\n"); |
| 275 | } else { |
| 276 | LOG(DEBUG, "sending goals: intake: %f, shoulder: %f, wrist: %f\n", |
| 277 | intake_goal_, shoulder_goal_, wrist_goal_); |
| 278 | } |
| 279 | |
| 280 | if (!shooter_queue.goal.MakeWithBuilder() |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 281 | .angular_velocity(shooter_velocity_) |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 282 | .clamp_open(is_intaking_ || is_outtaking_) |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 283 | .push_to_shooter(fire_) |
Austin Schuh | 45d07f6 | 2016-03-13 15:33:31 -0700 | [diff] [blame] | 284 | .force_lights_on(force_lights_on) |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 285 | .Send()) { |
| 286 | LOG(ERROR, "Sending shooter goal failed.\n"); |
| 287 | } |
| 288 | } |
| 289 | } |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 290 | } |
| 291 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 292 | private: |
| 293 | void StartAuto() { |
| 294 | LOG(INFO, "Starting auto mode\n"); |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 295 | |
| 296 | actors::AutonomousActionParams params; |
| 297 | params.mode = 0; |
| 298 | action_queue_.EnqueueAction(actors::MakeAutonomousAction(params)); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | void StopAuto() { |
| 302 | LOG(INFO, "Stopping auto mode\n"); |
Comran Morshed | e68e373 | 2016-03-12 14:12:11 +0000 | [diff] [blame] | 303 | action_queue_.CancelAllActions(); |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | bool is_high_gear_; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 307 | // Whatever these are set to are our default goals to send out after zeroing. |
| 308 | double intake_goal_; |
| 309 | double shoulder_goal_; |
| 310 | double wrist_goal_; |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 311 | double shooter_velocity_ = 0.0; |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 312 | |
| 313 | bool was_running_ = false; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 314 | bool auto_running_ = false; |
| 315 | |
Comran Morshed | 200dd4b | 2016-02-16 17:54:58 +0000 | [diff] [blame] | 316 | // If we're waiting for the subsystems to zero. |
| 317 | bool waiting_for_zero_ = true; |
| 318 | |
Comran Morshed | aa0573c | 2016-03-05 19:05:54 +0000 | [diff] [blame] | 319 | // If true, the ball was present when the intaking button was pressed. |
| 320 | bool saw_ball_when_started_intaking_ = false; |
| 321 | |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 322 | bool is_intaking_ = false; |
Austin Schuh | 5a6db4d | 2016-02-28 22:02:42 -0800 | [diff] [blame] | 323 | bool is_outtaking_ = false; |
Austin Schuh | de802e9 | 2016-02-27 14:49:03 -0800 | [diff] [blame] | 324 | bool fire_ = false; |
| 325 | |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 326 | ::aos::common::actions::ActionQueue action_queue_; |
| 327 | |
| 328 | ::aos::util::SimpleLogInterval no_drivetrain_status_ = |
| 329 | ::aos::util::SimpleLogInterval(::aos::time::Time::InSeconds(0.2), WARNING, |
| 330 | "no drivetrain status"); |
| 331 | }; |
| 332 | |
| 333 | } // namespace joysticks |
| 334 | } // namespace input |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 335 | } // namespace y2016 |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 336 | |
| 337 | int main() { |
| 338 | ::aos::Init(-1); |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 339 | ::y2016::input::joysticks::Reader reader; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 340 | reader.Run(); |
| 341 | ::aos::Cleanup(); |
| 342 | } |