Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 1 | #include "y2017/control_loops/superstructure/superstructure.h" |
| 2 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 3 | #include "aos/logging/logging.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 4 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 5 | #include "y2017/constants.h" |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 6 | #include "y2017/control_loops/superstructure/column/column.h" |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 7 | #include "y2017/control_loops/superstructure/hood/hood.h" |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 8 | #include "y2017/control_loops/superstructure/intake/intake.h" |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 9 | #include "y2017/control_loops/superstructure/shooter/shooter.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 10 | #include "y2017/vision/vision_generated.h" |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 11 | |
| 12 | namespace y2017 { |
| 13 | namespace control_loops { |
| 14 | namespace superstructure { |
| 15 | |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 16 | namespace { |
| 17 | // The maximum voltage the intake roller will be allowed to use. |
| 18 | constexpr double kMaxIntakeRollerVoltage = 12.0; |
| 19 | constexpr double kMaxIndexerRollerVoltage = 12.0; |
| 20 | } // namespace |
| 21 | |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 22 | typedef ::y2017::constants::Values::ShotParams ShotParams; |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 23 | |
Austin Schuh | 55a13dc | 2019-01-27 22:39:03 -0800 | [diff] [blame] | 24 | Superstructure::Superstructure(::aos::EventLoop *event_loop, |
| 25 | const ::std::string &name) |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 26 | : aos::controls::ControlLoop<Goal, Position, Status, Output>(event_loop, |
| 27 | name), |
Austin Schuh | b6c5c85 | 2019-05-19 20:13:31 -0700 | [diff] [blame] | 28 | vision_status_fetcher_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 29 | event_loop->MakeFetcher<::y2017::vision::VisionStatus>("/vision")), |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 30 | drivetrain_status_fetcher_( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 31 | event_loop->MakeFetcher<::frc971::control_loops::drivetrain::Status>( |
| 32 | "/drivetrain")), |
Austin Schuh | b6c5c85 | 2019-05-19 20:13:31 -0700 | [diff] [blame] | 33 | column_(event_loop) { |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 34 | shot_interpolation_table_ = |
| 35 | ::frc971::shooter_interpolation::InterpolationTable<ShotParams>({ |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 36 | // { distance_to_target, { shot_angle, shot_power, indexer_velocity |
| 37 | // }}, |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 38 | {1.21, {0.29, 301.0, -1.0 * M_PI}}, // table entry |
Austin Schuh | 535a088 | 2017-06-24 13:33:45 -0700 | [diff] [blame] | 39 | {1.55, {0.305, 316.0, -1.1 * M_PI}}, // table entry |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 40 | {1.82, {0.33, 325.0, -1.3 * M_PI}}, // table entry |
| 41 | {2.00, {0.34, 328.0, -1.4 * M_PI}}, // table entry |
| 42 | {2.28, {0.36, 338.0, -1.5 * M_PI}}, // table entry |
| 43 | {2.55, {0.395, 342.0, -1.8 * M_PI}}, // table entry |
Austin Schuh | 535a088 | 2017-06-24 13:33:45 -0700 | [diff] [blame] | 44 | {2.81, {0.41, 354.0, -1.90 * M_PI}}, // table entry |
| 45 | // The following entry is wrong, but will make it so we keep shooting |
| 46 | // in auto. |
| 47 | {3.20, {0.41, 354.0, -1.90 * M_PI}}, // table entry |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 48 | }); |
| 49 | } |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 50 | |
| 51 | void Superstructure::RunIteration( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 52 | const Goal *unsafe_goal, |
| 53 | const Position *position, |
| 54 | aos::Sender<Output>::Builder *output, |
| 55 | aos::Sender<Status>::Builder *status) { |
| 56 | OutputT output_struct; |
Austin Schuh | 9271536 | 2019-07-07 20:47:45 -0700 | [diff] [blame] | 57 | const ::aos::monotonic_clock::time_point monotonic_now = |
| 58 | event_loop()->monotonic_now(); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 59 | if (WasReset()) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 60 | AOS_LOG(ERROR, "WPILib reset, restarting\n"); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 61 | hood_.Reset(); |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 62 | intake_.Reset(); |
Tyler Chatow | 2737d2a | 2017-02-08 21:20:51 -0800 | [diff] [blame] | 63 | shooter_.Reset(); |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 64 | column_.Reset(); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Philipp Schrader | 8e3ac0f | 2017-04-09 23:36:17 +0000 | [diff] [blame] | 67 | const vision::VisionStatus *vision_status = nullptr; |
Austin Schuh | b6c5c85 | 2019-05-19 20:13:31 -0700 | [diff] [blame] | 68 | if (vision_status_fetcher_.Fetch()) { |
| 69 | vision_status = vision_status_fetcher_.get(); |
Philipp Schrader | 8e3ac0f | 2017-04-09 23:36:17 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 72 | // Create a copy of the goals so that we can modify them. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 73 | double hood_goal_angle = 0.0; |
| 74 | ShooterGoalT shooter_goal; |
| 75 | IndexerGoalT indexer_goal; |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 76 | bool in_range = true; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 77 | double vision_distance = 0.0; |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 78 | if (unsafe_goal != nullptr) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 79 | hood_goal_angle = unsafe_goal->hood()->angle(); |
| 80 | shooter_goal.angular_velocity = unsafe_goal->shooter()->angular_velocity(); |
| 81 | indexer_goal.angular_velocity = unsafe_goal->indexer()->angular_velocity(); |
| 82 | indexer_goal.voltage_rollers = unsafe_goal->indexer()->voltage_rollers(); |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 83 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 84 | if (!unsafe_goal->use_vision_for_shots()) { |
Austin Schuh | d85c66e | 2017-04-16 10:50:33 -0700 | [diff] [blame] | 85 | distance_average_.Reset(); |
| 86 | } |
| 87 | |
Austin Schuh | 9271536 | 2019-07-07 20:47:45 -0700 | [diff] [blame] | 88 | distance_average_.Tick(monotonic_now, vision_status); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 89 | vision_distance = distance_average_.Get(); |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 90 | |
| 91 | // If we are moving too fast, disable shooting and clear the accumulator. |
| 92 | double robot_velocity = 0.0; |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 93 | drivetrain_status_fetcher_.Fetch(); |
| 94 | if (drivetrain_status_fetcher_.get()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 95 | robot_velocity = drivetrain_status_fetcher_->robot_speed(); |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | if (::std::abs(robot_velocity) > 0.2) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 99 | if (unsafe_goal->use_vision_for_shots()) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 100 | AOS_LOG(INFO, "Moving too fast, resetting\n"); |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 101 | } |
| 102 | distance_average_.Reset(); |
| 103 | } |
| 104 | if (distance_average_.Valid()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 105 | if (unsafe_goal->use_vision_for_shots()) { |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 106 | ShotParams shot_params; |
| 107 | if (shot_interpolation_table_.GetInRange( |
Parker Schuh | 94d5679 | 2017-04-13 20:32:50 -0700 | [diff] [blame] | 108 | distance_average_.Get(), &shot_params)) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 109 | hood_goal_angle = shot_params.angle; |
Parker Schuh | 94d5679 | 2017-04-13 20:32:50 -0700 | [diff] [blame] | 110 | shooter_goal.angular_velocity = shot_params.power; |
| 111 | if (indexer_goal.angular_velocity != 0.0) { |
| 112 | indexer_goal.angular_velocity = shot_params.indexer_velocity; |
| 113 | } |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 114 | } else { |
| 115 | in_range = false; |
Parker Schuh | 94d5679 | 2017-04-13 20:32:50 -0700 | [diff] [blame] | 116 | } |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 117 | } |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 118 | AOS_LOG( |
| 119 | DEBUG, "VisionDistance %f, hood %f shooter %f, indexer %f * M_PI\n", |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 120 | vision_distance, hood_goal_angle, |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 121 | shooter_goal.angular_velocity, indexer_goal.angular_velocity / M_PI); |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 122 | } else { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 123 | AOS_LOG(DEBUG, "VisionNotValid %f\n", vision_distance); |
| 124 | if (unsafe_goal->use_vision_for_shots()) { |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 125 | in_range = false; |
| 126 | indexer_goal.angular_velocity = 0.0; |
| 127 | } |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 131 | flatbuffers::Offset<frc971::control_loops::IndexProfiledJointStatus> |
| 132 | hood_offset = hood_.Iterate( |
| 133 | monotonic_now, unsafe_goal != nullptr ? &hood_goal_angle : nullptr, |
| 134 | unsafe_goal != nullptr ? unsafe_goal->hood()->profile_params() |
| 135 | : nullptr, |
| 136 | position->hood(), |
| 137 | output != nullptr ? &(output_struct.voltage_hood) : nullptr, |
| 138 | status->fbb()); |
| 139 | flatbuffers::Offset<ShooterStatus> shooter_offset = shooter_.Iterate( |
| 140 | unsafe_goal != nullptr ? &shooter_goal : nullptr, |
Austin Schuh | ad15482 | 2019-12-27 15:45:13 -0800 | [diff] [blame] | 141 | position->theta_shooter(), position_context().monotonic_event_time, |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 142 | output != nullptr ? &(output_struct.voltage_shooter) : nullptr, |
| 143 | status->fbb()); |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 144 | |
| 145 | // Implement collision avoidance by passing down a freeze or range restricting |
| 146 | // signal to the column and intake objects. |
| 147 | |
| 148 | // Wait until the column is ready before doing collision avoidance. |
| 149 | if (unsafe_goal && column_.state() == column::Column::State::RUNNING) { |
| 150 | if (!ignore_collisions_) { |
| 151 | // The turret is in a position (or wants to be in a position) where we |
| 152 | // need the intake out. Push it out. |
Austin Schuh | 3ae4743 | 2017-04-16 19:15:46 -0700 | [diff] [blame] | 153 | const bool column_goal_not_safe = |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 154 | unsafe_goal->turret()->angle() > column::Column::kTurretMax || |
| 155 | unsafe_goal->turret()->angle() < column::Column::kTurretMin; |
Austin Schuh | 3ae4743 | 2017-04-16 19:15:46 -0700 | [diff] [blame] | 156 | const bool column_position_not_safe = |
| 157 | column_.turret_position() > column::Column::kTurretMax || |
| 158 | column_.turret_position() < column::Column::kTurretMin; |
| 159 | |
| 160 | if (column_goal_not_safe || column_position_not_safe) { |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 161 | intake_.set_min_position(column::Column::kIntakeZeroingMinDistance); |
| 162 | } else { |
| 163 | intake_.clear_min_position(); |
| 164 | } |
| 165 | // The intake is in a position where it could hit. Don't move the turret. |
| 166 | if (intake_.position() < column::Column::kIntakeZeroingMinDistance - |
| 167 | column::Column::kIntakeTolerance && |
Austin Schuh | 3ae4743 | 2017-04-16 19:15:46 -0700 | [diff] [blame] | 168 | column_position_not_safe) { |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 169 | column_.set_freeze(true); |
| 170 | } else { |
| 171 | column_.set_freeze(false); |
| 172 | } |
| 173 | } else { |
| 174 | // If we are ignoring collisions, unfreeze and un-limit the min. |
| 175 | column_.set_freeze(false); |
| 176 | intake_.clear_min_position(); |
| 177 | } |
| 178 | } else { |
| 179 | column_.set_freeze(false); |
| 180 | } |
| 181 | |
| 182 | // Make some noise if someone left this set... |
| 183 | if (ignore_collisions_) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 184 | AOS_LOG(ERROR, "Collisions ignored\n"); |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 185 | } |
| 186 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 187 | flatbuffers::Offset< |
| 188 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus> |
| 189 | intake_offset = intake_.Iterate( |
| 190 | unsafe_goal != nullptr ? unsafe_goal->intake() : nullptr, |
| 191 | position->intake(), |
| 192 | output != nullptr ? &(output_struct.voltage_intake) : nullptr, |
| 193 | status->fbb()); |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 194 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 195 | std::pair<flatbuffers::Offset<IndexerStatus>, |
| 196 | flatbuffers::Offset<TurretProfiledSubsystemStatus>> |
| 197 | indexer_and_turret_offsets = column_.Iterate( |
| 198 | monotonic_now, unsafe_goal != nullptr ? &indexer_goal : nullptr, |
| 199 | unsafe_goal != nullptr ? unsafe_goal->turret() : nullptr, |
| 200 | position->column(), vision_status, |
| 201 | output != nullptr ? &(output_struct.voltage_indexer) : nullptr, |
| 202 | output != nullptr ? &(output_struct.voltage_turret) : nullptr, |
| 203 | status->fbb(), &intake_); |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 204 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 205 | const frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus |
| 206 | *temp_intake_status = GetTemporaryPointer(*status->fbb(), intake_offset); |
| 207 | const frc971::control_loops::IndexProfiledJointStatus *temp_hood_status = |
| 208 | GetTemporaryPointer(*status->fbb(), hood_offset); |
| 209 | const TurretProfiledSubsystemStatus *temp_turret_status = |
| 210 | GetTemporaryPointer(*status->fbb(), indexer_and_turret_offsets.second); |
Austin Schuh | c587c88 | 2017-03-29 21:33:10 -0700 | [diff] [blame] | 211 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 212 | const bool estopped = temp_intake_status->estopped() || |
| 213 | temp_hood_status->estopped() || |
| 214 | temp_turret_status->estopped(); |
| 215 | const bool zeroed = temp_intake_status->zeroed() && |
| 216 | temp_hood_status->zeroed() && |
| 217 | temp_turret_status->zeroed(); |
| 218 | const bool turret_vision_tracking = temp_turret_status->vision_tracking(); |
| 219 | |
| 220 | Status::Builder status_builder = status->MakeBuilder<Status>(); |
| 221 | status_builder.add_intake(intake_offset); |
| 222 | status_builder.add_hood(hood_offset); |
| 223 | status_builder.add_shooter(shooter_offset); |
| 224 | status_builder.add_turret(indexer_and_turret_offsets.second); |
| 225 | status_builder.add_indexer(indexer_and_turret_offsets.first); |
| 226 | |
| 227 | status_builder.add_estopped(estopped); |
| 228 | status_builder.add_zeroed(zeroed); |
| 229 | |
| 230 | status_builder.add_vision_distance(vision_distance); |
Austin Schuh | c587c88 | 2017-03-29 21:33:10 -0700 | [diff] [blame] | 231 | |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 232 | if (output && unsafe_goal) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 233 | output_struct.gear_servo = |
| 234 | ::std::min(1.0, ::std::max(0.0, unsafe_goal->intake()->gear_servo())); |
Austin Schuh | 6a8131b | 2017-04-08 15:39:22 -0700 | [diff] [blame] | 235 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 236 | output_struct.voltage_intake_rollers = |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 237 | ::std::max(-kMaxIntakeRollerVoltage, |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 238 | ::std::min(unsafe_goal->intake()->voltage_rollers(), |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 239 | kMaxIntakeRollerVoltage)); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 240 | output_struct.voltage_indexer_rollers = |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 241 | ::std::max(-kMaxIndexerRollerVoltage, |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 242 | ::std::min(unsafe_goal->indexer()->voltage_rollers(), |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 243 | kMaxIndexerRollerVoltage)); |
Adam Snaider | e0554ef | 2017-03-11 23:02:45 -0800 | [diff] [blame] | 244 | |
| 245 | // Set the lights on or off |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 246 | output_struct.lights_on = unsafe_goal->lights_on(); |
Austin Schuh | c587c88 | 2017-03-29 21:33:10 -0700 | [diff] [blame] | 247 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 248 | if (estopped) { |
| 249 | output_struct.red_light_on = true; |
| 250 | output_struct.green_light_on = false; |
| 251 | output_struct.blue_light_on = false; |
| 252 | } else if (!zeroed) { |
| 253 | output_struct.red_light_on = false; |
| 254 | output_struct.green_light_on = false; |
| 255 | output_struct.blue_light_on = true; |
| 256 | } else if (turret_vision_tracking && in_range) { |
| 257 | output_struct.red_light_on = false; |
| 258 | output_struct.green_light_on = true; |
| 259 | output_struct.blue_light_on = false; |
Austin Schuh | c587c88 | 2017-03-29 21:33:10 -0700 | [diff] [blame] | 260 | } |
Campbell Crowley | 651c4b4 | 2017-02-17 22:30:50 -0800 | [diff] [blame] | 261 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 262 | |
| 263 | if (output) { |
| 264 | output->Send(Output::Pack(*output->fbb(), &output_struct)); |
| 265 | } |
| 266 | |
| 267 | status->Send(status_builder.Finish()); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | } // namespace superstructure |
| 271 | } // namespace control_loops |
| 272 | } // namespace y2017 |