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