Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <unistd.h> |
| 4 | #include <math.h> |
| 5 | |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 6 | #include "aos/common/actions/actions.h" |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 7 | #include "aos/common/input/driver_station_data.h" |
| 8 | #include "aos/common/logging/logging.h" |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 9 | #include "aos/common/time.h" |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 10 | #include "aos/common/util/log_interval.h" |
| 11 | #include "aos/input/joystick_input.h" |
| 12 | #include "aos/linux_code/init.h" |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 13 | #include "frc971/autonomous/auto.q.h" |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 14 | #include "frc971/autonomous/base_autonomous_actor.h" |
| 15 | #include "frc971/control_loops/drivetrain/drivetrain.q.h" |
| 16 | #include "y2017/constants.h" |
| 17 | #include "y2017/control_loops/superstructure/superstructure.q.h" |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 18 | |
| 19 | using ::frc971::control_loops::drivetrain_queue; |
| 20 | using ::y2017::control_loops::superstructure_queue; |
| 21 | |
| 22 | using ::aos::input::driver_station::ButtonLocation; |
| 23 | using ::aos::input::driver_station::ControlBit; |
| 24 | using ::aos::input::driver_station::JoystickAxis; |
| 25 | using ::aos::input::driver_station::POVLocation; |
| 26 | |
| 27 | namespace y2017 { |
| 28 | namespace input { |
| 29 | namespace joysticks { |
| 30 | |
| 31 | const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2); |
| 32 | const ButtonLocation kQuickTurn(1, 5); |
| 33 | |
| 34 | const ButtonLocation kTurn1(1, 7); |
| 35 | const ButtonLocation kTurn2(1, 11); |
| 36 | |
Austin Schuh | 55c8d30 | 2017-04-05 19:25:37 -0700 | [diff] [blame] | 37 | const ButtonLocation kGearSlotBack(2, 11); |
| 38 | |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 39 | const ButtonLocation kIntakeDown(3, 9); |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 40 | const POVLocation kIntakeUp(3, 90); |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 41 | const ButtonLocation kIntakeIn(3, 12); |
| 42 | const ButtonLocation kIntakeOut(3, 8); |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 43 | const ButtonLocation kFire(3, 3); |
| 44 | const ButtonLocation kCloseShot(3, 7); |
| 45 | const ButtonLocation kMiddleShot(3, 6); |
| 46 | const POVLocation kFarShot(3, 270); |
| 47 | |
| 48 | const ButtonLocation kVisionAlign(3, 5); |
| 49 | |
| 50 | const ButtonLocation kReverseIndexer(3, 4); |
| 51 | const ButtonLocation kExtra1(3, 11); |
| 52 | const ButtonLocation kExtra2(3, 10); |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 53 | const ButtonLocation kHang(3, 2); |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 54 | |
| 55 | class Reader : public ::aos::input::JoystickInput { |
| 56 | public: |
| 57 | Reader() {} |
| 58 | |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 59 | enum class ShotDistance { CLOSE_SHOT, MIDDLE_SHOT, FAR_SHOT }; |
| 60 | |
| 61 | ShotDistance last_shot_distance_ = ShotDistance::FAR_SHOT; |
| 62 | |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 63 | void RunIteration(const ::aos::input::driver_station::Data &data) override { |
| 64 | bool last_auto_running = auto_running_; |
| 65 | auto_running_ = data.GetControlBit(ControlBit::kAutonomous) && |
| 66 | data.GetControlBit(ControlBit::kEnabled); |
| 67 | if (auto_running_ != last_auto_running) { |
| 68 | if (auto_running_) { |
| 69 | StartAuto(); |
| 70 | } else { |
| 71 | StopAuto(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | vision_valid_ = false; |
| 76 | |
| 77 | if (!auto_running_) { |
| 78 | HandleDrivetrain(data); |
| 79 | HandleTeleop(data); |
| 80 | } |
| 81 | |
| 82 | // Process any pending actions. |
| 83 | action_queue_.Tick(); |
| 84 | was_running_ = action_queue_.Running(); |
| 85 | } |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 86 | int intake_accumulator_ = 0; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 87 | |
| 88 | void HandleDrivetrain(const ::aos::input::driver_station::Data &data) { |
| 89 | bool is_control_loop_driving = false; |
| 90 | |
| 91 | const double wheel = -data.GetAxis(kSteeringWheel); |
| 92 | const double throttle = -data.GetAxis(kDriveThrottle); |
| 93 | drivetrain_queue.status.FetchLatest(); |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 94 | if (drivetrain_queue.status.get()) { |
| 95 | robot_velocity_ = drivetrain_queue.status->robot_speed; |
| 96 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 97 | |
Austin Schuh | 55c8d30 | 2017-04-05 19:25:37 -0700 | [diff] [blame] | 98 | if (data.PosEdge(kTurn1) || data.PosEdge(kTurn2) || |
| 99 | data.PosEdge(kGearSlotBack)) { |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 100 | if (drivetrain_queue.status.get()) { |
| 101 | left_goal_ = drivetrain_queue.status->estimated_left_position; |
| 102 | right_goal_ = drivetrain_queue.status->estimated_right_position; |
| 103 | } |
| 104 | } |
Austin Schuh | 55c8d30 | 2017-04-05 19:25:37 -0700 | [diff] [blame] | 105 | double current_left_goal = left_goal_ - wheel * 0.5 + throttle * 0.3; |
| 106 | double current_right_goal = right_goal_ + wheel * 0.5 + throttle * 0.3; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 107 | if (data.IsPressed(kTurn1) || data.IsPressed(kTurn2)) { |
| 108 | is_control_loop_driving = true; |
| 109 | } |
Austin Schuh | 55c8d30 | 2017-04-05 19:25:37 -0700 | [diff] [blame] | 110 | if (data.IsPressed(kGearSlotBack)) { |
| 111 | is_control_loop_driving = true; |
| 112 | current_left_goal = left_goal_ - 0.03; |
| 113 | current_right_goal = right_goal_ - 0.03; |
| 114 | } |
| 115 | auto new_drivetrain_goal = drivetrain_queue.goal.MakeMessage(); |
| 116 | new_drivetrain_goal->steering = wheel; |
| 117 | new_drivetrain_goal->throttle = throttle; |
| 118 | new_drivetrain_goal->quickturn = data.IsPressed(kQuickTurn); |
| 119 | new_drivetrain_goal->control_loop_driving = is_control_loop_driving; |
| 120 | new_drivetrain_goal->left_goal = current_left_goal; |
| 121 | new_drivetrain_goal->right_goal = current_right_goal; |
| 122 | new_drivetrain_goal->left_velocity_goal = 0; |
| 123 | new_drivetrain_goal->right_velocity_goal = 0; |
| 124 | |
| 125 | new_drivetrain_goal->linear.max_velocity = 3.0; |
| 126 | new_drivetrain_goal->linear.max_acceleration = 20.0; |
| 127 | |
| 128 | if (!new_drivetrain_goal.Send()) { |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 129 | LOG(WARNING, "sending stick values failed\n"); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void HandleTeleop(const ::aos::input::driver_station::Data &data) { |
| 134 | // Default the intake to in. |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 135 | intake_goal_ = 0.07; |
Adam Snaider | e0554ef | 2017-03-11 23:02:45 -0800 | [diff] [blame] | 136 | bool lights_on = false; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 137 | bool vision_track = false; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 138 | |
| 139 | if (!data.GetControlBit(ControlBit::kEnabled)) { |
| 140 | action_queue_.CancelAllActions(); |
| 141 | LOG(DEBUG, "Canceling\n"); |
| 142 | } |
| 143 | |
| 144 | superstructure_queue.status.FetchLatest(); |
| 145 | if (!superstructure_queue.status.get()) { |
| 146 | LOG(ERROR, "Got no superstructure status packet.\n"); |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | if (data.IsPressed(kIntakeDown)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 151 | intake_goal_ = 0.235; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 152 | } |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 153 | if (data.IsPressed(kIntakeUp)) { |
| 154 | intake_goal_ = 0.0; |
| 155 | turret_goal_ = 0.0; |
| 156 | } |
| 157 | |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 158 | |
| 159 | if (data.IsPressed(kVisionAlign)) { |
| 160 | // Align shot using vision |
| 161 | // TODO(campbell): Add vision aligning. |
Adam Snaider | e0554ef | 2017-03-11 23:02:45 -0800 | [diff] [blame] | 162 | lights_on = true; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 163 | vision_track = true; |
| 164 | } |
| 165 | if (data.PosEdge(kMiddleShot)) { |
| 166 | turret_goal_ = -M_PI; |
| 167 | } |
| 168 | if (data.PosEdge(kFarShot)) { |
| 169 | turret_goal_ = 0.0; |
| 170 | } |
| 171 | |
| 172 | if (data.IsPressed(kCloseShot)) { |
| 173 | last_shot_distance_ = ShotDistance::CLOSE_SHOT; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 174 | } else if (data.IsPressed(kMiddleShot)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 175 | last_shot_distance_ = ShotDistance::MIDDLE_SHOT; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 176 | } else if (data.IsPressed(kFarShot)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 177 | last_shot_distance_ = ShotDistance::FAR_SHOT; |
| 178 | } |
| 179 | |
| 180 | if (data.IsPressed(kVisionAlign) || data.IsPressed(kCloseShot) || |
| 181 | data.IsPressed(kMiddleShot) || data.IsPressed(kFarShot) || |
| 182 | data.IsPressed(kFire)) { |
| 183 | switch (last_shot_distance_) { |
| 184 | case ShotDistance::CLOSE_SHOT: |
| 185 | hood_goal_ = 0.285; |
| 186 | shooter_velocity_ = 335.0; |
| 187 | break; |
| 188 | case ShotDistance::MIDDLE_SHOT: |
| 189 | hood_goal_ = 0.63; |
| 190 | shooter_velocity_ = 384.0; |
| 191 | break; |
| 192 | case ShotDistance::FAR_SHOT: |
| 193 | hood_goal_ = 0.63; |
| 194 | shooter_velocity_ = 378.0; |
| 195 | break; |
| 196 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 197 | } else { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 198 | //hood_goal_ = 0.15; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 199 | shooter_velocity_ = 0.0; |
| 200 | } |
| 201 | |
| 202 | if (data.IsPressed(kExtra1)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 203 | //turret_goal_ = -M_PI * 3.0 / 4.0; |
| 204 | turret_goal_ += 0.150; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 205 | } |
| 206 | if (data.IsPressed(kExtra2)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 207 | //turret_goal_ = M_PI * 3.0 / 4.0; |
| 208 | turret_goal_ -= 0.150; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 209 | } |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 210 | turret_goal_ = ::std::max(::std::min(turret_goal_, M_PI), -M_PI); |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 211 | |
| 212 | fire_ = data.IsPressed(kFire) && shooter_velocity_ != 0.0; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 213 | if (data.IsPressed(kVisionAlign)) { |
| 214 | fire_ = fire_ && superstructure_queue.status->turret.vision_tracking; |
| 215 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 216 | |
| 217 | auto new_superstructure_goal = superstructure_queue.goal.MakeMessage(); |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 218 | if (data.IsPressed(kHang)) { |
| 219 | intake_goal_ = 0.23; |
| 220 | } |
| 221 | |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 222 | new_superstructure_goal->intake.distance = intake_goal_; |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 223 | new_superstructure_goal->intake.disable_intake = false; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 224 | new_superstructure_goal->turret.angle = turret_goal_; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 225 | new_superstructure_goal->turret.track = vision_track; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 226 | new_superstructure_goal->hood.angle = hood_goal_; |
| 227 | new_superstructure_goal->shooter.angular_velocity = shooter_velocity_; |
| 228 | |
Austin Schuh | 6a8131b | 2017-04-08 15:39:22 -0700 | [diff] [blame^] | 229 | if (data.IsPressed(kIntakeUp)) { |
| 230 | new_superstructure_goal->intake.gear_servo = 0.37; |
| 231 | } else { |
| 232 | // Clamp the gear |
| 233 | new_superstructure_goal->intake.gear_servo = 0.64; |
| 234 | } |
| 235 | |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 236 | new_superstructure_goal->intake.profile_params.max_velocity = 0.50; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 237 | new_superstructure_goal->hood.profile_params.max_velocity = 5.0; |
| 238 | |
| 239 | new_superstructure_goal->intake.profile_params.max_acceleration = 5.0; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 240 | if (vision_track) { |
| 241 | new_superstructure_goal->turret.profile_params.max_acceleration = 35.0; |
| 242 | new_superstructure_goal->turret.profile_params.max_velocity = 10.0; |
| 243 | } else { |
| 244 | new_superstructure_goal->turret.profile_params.max_acceleration = 15.0; |
| 245 | new_superstructure_goal->turret.profile_params.max_velocity = 6.0; |
| 246 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 247 | new_superstructure_goal->hood.profile_params.max_acceleration = 25.0; |
| 248 | |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 249 | new_superstructure_goal->intake.voltage_rollers = 0.0; |
Adam Snaider | e0554ef | 2017-03-11 23:02:45 -0800 | [diff] [blame] | 250 | new_superstructure_goal->lights_on = lights_on; |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 251 | |
Austin Schuh | 8e4a7ee | 2017-04-05 19:26:06 -0700 | [diff] [blame] | 252 | if (superstructure_queue.status->intake.position > |
| 253 | superstructure_queue.status->intake.unprofiled_goal_position + 0.01) { |
| 254 | intake_accumulator_ = 10; |
| 255 | } |
| 256 | if (intake_accumulator_ > 0) { |
| 257 | --intake_accumulator_; |
| 258 | if (!superstructure_queue.status->intake.estopped) { |
| 259 | new_superstructure_goal->intake.voltage_rollers = 10.0; |
| 260 | } |
| 261 | } |
| 262 | |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 263 | if (data.IsPressed(kHang)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 264 | new_superstructure_goal->intake.voltage_rollers = -10.0; |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 265 | new_superstructure_goal->intake.disable_intake = true; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 266 | } else if (data.IsPressed(kIntakeIn) || data.IsPressed(kFire)) { |
| 267 | if (robot_velocity_ > 2.0) { |
| 268 | new_superstructure_goal->intake.voltage_rollers = 12.0; |
| 269 | } else { |
| 270 | new_superstructure_goal->intake.voltage_rollers = 10.0; |
| 271 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 272 | } else if (data.IsPressed(kIntakeOut)) { |
| 273 | new_superstructure_goal->intake.voltage_rollers = -8.0; |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 274 | } |
| 275 | if (intake_goal_ < 0.1) { |
| 276 | new_superstructure_goal->intake.voltage_rollers = |
| 277 | ::std::min(8.0, new_superstructure_goal->intake.voltage_rollers); |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | if (data.IsPressed(kReverseIndexer)) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 281 | new_superstructure_goal->indexer.voltage_rollers = -12.0; |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 282 | new_superstructure_goal->indexer.angular_velocity = 4.0; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 283 | new_superstructure_goal->indexer.angular_velocity = 1.0; |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 284 | } else if (fire_) { |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 285 | new_superstructure_goal->indexer.voltage_rollers = 12.0; |
| 286 | switch (last_shot_distance_) { |
| 287 | case ShotDistance::CLOSE_SHOT: |
| 288 | new_superstructure_goal->indexer.angular_velocity = -0.90 * M_PI; |
| 289 | break; |
| 290 | case ShotDistance::MIDDLE_SHOT: |
| 291 | case ShotDistance::FAR_SHOT: |
| 292 | new_superstructure_goal->indexer.angular_velocity = -2.25 * M_PI; |
| 293 | break; |
| 294 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 295 | } else { |
| 296 | new_superstructure_goal->indexer.voltage_rollers = 0.0; |
| 297 | new_superstructure_goal->indexer.angular_velocity = 0.0; |
| 298 | } |
| 299 | |
| 300 | LOG_STRUCT(DEBUG, "sending goal", *new_superstructure_goal); |
| 301 | if (!new_superstructure_goal.Send()) { |
| 302 | LOG(ERROR, "Sending superstructure goal failed.\n"); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | private: |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 307 | void StartAuto() { |
| 308 | LOG(INFO, "Starting auto mode\n"); |
| 309 | |
| 310 | ::frc971::autonomous::AutonomousActionParams params; |
| 311 | ::frc971::autonomous::auto_mode.FetchLatest(); |
| 312 | if (::frc971::autonomous::auto_mode.get() != nullptr) { |
| 313 | params.mode = ::frc971::autonomous::auto_mode->mode; |
| 314 | } else { |
| 315 | LOG(WARNING, "no auto mode values\n"); |
| 316 | params.mode = 0; |
| 317 | } |
| 318 | action_queue_.EnqueueAction( |
| 319 | ::frc971::autonomous::MakeAutonomousAction(params)); |
| 320 | } |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 321 | |
| 322 | void StopAuto() { |
| 323 | LOG(INFO, "Stopping auto mode\n"); |
| 324 | action_queue_.CancelAllActions(); |
| 325 | } |
| 326 | |
| 327 | // Current goals to send to the robot. |
| 328 | double intake_goal_ = 0.0; |
| 329 | double turret_goal_ = 0.0; |
| 330 | double hood_goal_ = 0.3; |
| 331 | double shooter_velocity_ = 0.0; |
| 332 | |
| 333 | // Goals to send to the drivetrain in closed loop mode. |
Austin Schuh | 3028b1d | 2017-03-11 22:12:13 -0800 | [diff] [blame] | 334 | double left_goal_ = 0.0; |
| 335 | double right_goal_ = 0.0; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 336 | |
| 337 | bool was_running_ = false; |
| 338 | bool auto_running_ = false; |
| 339 | |
| 340 | bool vision_valid_ = false; |
| 341 | |
| 342 | bool fire_ = false; |
Austin Schuh | d0629b1 | 2017-03-22 22:37:16 -0700 | [diff] [blame] | 343 | double robot_velocity_ = 0.0; |
Campbell Crowley | 71b5f13 | 2017-02-18 13:16:08 -0800 | [diff] [blame] | 344 | |
| 345 | ::aos::common::actions::ActionQueue action_queue_; |
| 346 | }; |
| 347 | |
| 348 | } // namespace joysticks |
| 349 | } // namespace input |
| 350 | } // namespace y2017 |
| 351 | |
| 352 | int main() { |
| 353 | ::aos::Init(-1); |
| 354 | ::y2017::input::joysticks::Reader reader; |
| 355 | reader.Run(); |
| 356 | ::aos::Cleanup(); |
| 357 | } |