Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 1 | #include "frc971/control_loops/claw/claw.h" |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | #include <algorithm> |
| 6 | |
| 7 | #include "aos/common/control_loop/control_loops.q.h" |
| 8 | #include "aos/common/logging/logging.h" |
| 9 | |
| 10 | #include "frc971/constants.h" |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 11 | #include "frc971/control_loops/claw/claw_motor_plant.h" |
| 12 | |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 13 | // Zeroing plan. |
| 14 | // There are 2 types of zeros. Enabled and disabled ones. |
| 15 | // Disabled ones are only valid during auto mode, and can be used to speed up |
| 16 | // the enabled zero process. We need to re-zero during teleop in case the auto |
| 17 | // zero was poor and causes us to miss all our shots. |
| 18 | // |
| 19 | // We need to be able to zero manually while disabled by moving the joint over |
| 20 | // the zeros. |
| 21 | // Zero on the down edge when disabled (gravity in the direction of motion) |
| 22 | // |
| 23 | // When enabled, zero on the up edge (gravity opposing the direction of motion) |
| 24 | // The enabled sequence needs to work as follows. We can crash the claw if we |
| 25 | // bring them too close to each other or too far from each other. The only safe |
| 26 | // thing to do is to move them in unison. |
| 27 | // |
| 28 | // Start by moving them both towards the front of the bot to either find either |
| 29 | // the middle hall effect on either jaw, or the front hall effect on the bottom |
| 30 | // jaw. Any edge that isn't the desired edge will provide an approximate edge |
| 31 | // location that can be used for the fine tuning step. |
| 32 | // Once an edge is found on the front claw, move back the other way with both |
| 33 | // claws until an edge is found for the other claw. |
| 34 | // Now that we have an approximate zero, we can robustify the limits to keep |
| 35 | // both claws safe. Then, we can move both claws to a position that is the |
| 36 | // correct side of the zero and go zero. |
| 37 | |
| 38 | // Valid region plan. |
| 39 | // Difference between the arms has a range, and the values of each arm has a range. |
| 40 | // If a claw runs up against a static limit, don't let the goal change outside |
| 41 | // the limit. |
| 42 | // If a claw runs up against a movable limit, move both claws outwards to get |
| 43 | // out of the condition. |
| 44 | |
| 45 | namespace frc971 { |
| 46 | namespace control_loops { |
| 47 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 48 | void ClawLimitedLoop::CapU() { |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 49 | uncapped_average_voltage_ = U(0, 0) + U(1, 0) / 2.0; |
| 50 | if (is_zeroing_) { |
| 51 | const frc971::constants::Values &values = constants::GetValues(); |
| 52 | if (uncapped_average_voltage_ > values.claw.max_zeroing_voltage) { |
| 53 | const double difference = |
| 54 | uncapped_average_voltage_ - values.claw.max_zeroing_voltage; |
| 55 | U(0, 0) -= difference; |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 56 | } else if (uncapped_average_voltage_ < -values.claw.max_zeroing_voltage) { |
| 57 | const double difference = |
| 58 | -uncapped_average_voltage_ - values.claw.max_zeroing_voltage; |
| 59 | U(0, 0) += difference; |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | |
| 63 | double max_value = |
| 64 | ::std::max(::std::abs(U(0, 0)), ::std::abs(U(1, 0) + U(0, 0))); |
| 65 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 66 | if (max_value > 12.0) { |
| 67 | LOG(DEBUG, "Capping U because max is %f\n", max_value); |
| 68 | U = U * 12.0 / max_value; |
| 69 | LOG(DEBUG, "Capping U is now %f %f\n", U(0, 0), U(1, 0)); |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 70 | } |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 71 | } |
| 72 | |
Austin Schuh | cc0bf31 | 2014-02-09 00:39:29 -0800 | [diff] [blame] | 73 | ClawMotor::ClawMotor(control_loops::ClawGroup *my_claw) |
| 74 | : aos::control_loops::ControlLoop<control_loops::ClawGroup>(my_claw), |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 75 | has_top_claw_goal_(false), |
| 76 | top_claw_goal_(0.0), |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 77 | top_claw_(this), |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 78 | has_bottom_claw_goal_(false), |
| 79 | bottom_claw_goal_(0.0), |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 80 | bottom_claw_(this), |
| 81 | claw_(MakeClawLoop()), |
Ben Fredrickson | 9b38842 | 2014-02-13 06:15:31 +0000 | [diff] [blame] | 82 | was_enabled_(false), |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 83 | doing_calibration_fine_tune_(false), |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 84 | capped_goal_(false), |
| 85 | mode_(UNKNOWN_LOCATION) {} |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 86 | |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 87 | const int ZeroedStateFeedbackLoop::kZeroingMaxVoltage; |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 88 | |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 89 | bool ZeroedStateFeedbackLoop::GetPositionOfEdge( |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 90 | const constants::Values::Claws::Claw &claw_values, double *edge_encoder, |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 91 | double *edge_angle) { |
| 92 | |
| 93 | // TODO(austin): Validate that the hall effect edge makes sense. |
| 94 | // We must now be on the side of the edge that we expect to be, and the |
| 95 | // encoder must have been on either side of the edge before and after. |
| 96 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 97 | // TODO(austin): Compute the last off range min and max and compare the edge |
| 98 | // value to the middle of the range. This will be quite a bit more reliable. |
| 99 | |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 100 | if (front_hall_effect_posedge_count_changed()) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 101 | if (posedge_value_ - last_encoder() < 0) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 102 | *edge_angle = claw_values.front.upper_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 103 | LOG(INFO, "%s Posedge front upper edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 104 | } else { |
| 105 | *edge_angle = claw_values.front.lower_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 106 | LOG(INFO, "%s Posedge front lower edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 107 | } |
| 108 | *edge_encoder = posedge_value_; |
| 109 | return true; |
| 110 | } |
| 111 | if (front_hall_effect_negedge_count_changed()) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 112 | if (negedge_value_ - last_encoder() > 0) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 113 | *edge_angle = claw_values.front.upper_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 114 | LOG(INFO, "%s Negedge front upper edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 115 | } else { |
| 116 | *edge_angle = claw_values.front.lower_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 117 | LOG(INFO, "%s Negedge front lower edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 118 | } |
| 119 | *edge_encoder = negedge_value_; |
| 120 | return true; |
| 121 | } |
| 122 | if (calibration_hall_effect_posedge_count_changed()) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 123 | if (posedge_value_ - last_encoder() < 0) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 124 | *edge_angle = claw_values.calibration.upper_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 125 | LOG(INFO, "%s Posedge calibration upper edge -> %f\n", name_, |
| 126 | *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 127 | } else { |
| 128 | *edge_angle = claw_values.calibration.lower_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 129 | LOG(INFO, "%s Posedge calibration lower edge -> %f\n", name_, |
| 130 | *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 131 | } |
| 132 | *edge_encoder = posedge_value_; |
| 133 | return true; |
| 134 | } |
| 135 | if (calibration_hall_effect_negedge_count_changed()) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 136 | if (negedge_value_ - last_encoder() > 0) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 137 | *edge_angle = claw_values.calibration.upper_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 138 | LOG(INFO, "%s Negedge calibration upper edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 139 | } else { |
| 140 | *edge_angle = claw_values.calibration.lower_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 141 | LOG(INFO, "%s Negedge calibration lower edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 142 | } |
| 143 | *edge_encoder = negedge_value_; |
| 144 | return true; |
| 145 | } |
| 146 | if (back_hall_effect_posedge_count_changed()) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 147 | if (posedge_value_ - last_encoder() < 0) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 148 | *edge_angle = claw_values.back.upper_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 149 | LOG(INFO, "%s Posedge back upper edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 150 | } else { |
| 151 | *edge_angle = claw_values.back.lower_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 152 | LOG(INFO, "%s Posedge back lower edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 153 | } |
| 154 | *edge_encoder = posedge_value_; |
| 155 | return true; |
| 156 | } |
| 157 | if (back_hall_effect_negedge_count_changed()) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 158 | if (negedge_value_ - last_encoder() > 0) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 159 | *edge_angle = claw_values.back.upper_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 160 | LOG(INFO, "%s Negedge back upper edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 161 | } else { |
| 162 | *edge_angle = claw_values.back.lower_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 163 | LOG(INFO, "%s Negedge back lower edge -> %f\n", name_, *edge_angle); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 164 | } |
| 165 | *edge_encoder = negedge_value_; |
| 166 | return true; |
| 167 | } |
| 168 | return false; |
| 169 | } |
| 170 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 171 | void TopZeroedStateFeedbackLoop::SetCalibration(double edge_encoder, |
| 172 | double edge_angle) { |
| 173 | double old_offset = offset_; |
| 174 | offset_ = edge_angle - edge_encoder; |
| 175 | const double doffset = offset_ - old_offset; |
| 176 | motor_->ChangeTopOffset(doffset); |
| 177 | } |
| 178 | |
| 179 | void BottomZeroedStateFeedbackLoop::SetCalibration(double edge_encoder, |
| 180 | double edge_angle) { |
| 181 | double old_offset = offset_; |
| 182 | offset_ = edge_angle - edge_encoder; |
| 183 | const double doffset = offset_ - old_offset; |
| 184 | motor_->ChangeBottomOffset(doffset); |
| 185 | } |
| 186 | |
| 187 | void ClawMotor::ChangeTopOffset(double doffset) { |
| 188 | claw_.ChangeTopOffset(doffset); |
| 189 | if (has_top_claw_goal_) { |
| 190 | top_claw_goal_ += doffset; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | void ClawMotor::ChangeBottomOffset(double doffset) { |
| 195 | claw_.ChangeBottomOffset(doffset); |
| 196 | if (has_bottom_claw_goal_) { |
| 197 | bottom_claw_goal_ += doffset; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void ClawLimitedLoop::ChangeTopOffset(double doffset) { |
| 202 | Y_(1, 0) += doffset; |
| 203 | X_hat(1, 0) += doffset; |
| 204 | LOG(INFO, "Changing top offset by %f\n", doffset); |
| 205 | } |
| 206 | void ClawLimitedLoop::ChangeBottomOffset(double doffset) { |
| 207 | Y_(0, 0) += doffset; |
| 208 | X_hat(0, 0) += doffset; |
| 209 | X_hat(1, 0) -= doffset; |
| 210 | LOG(INFO, "Changing bottom offset by %f\n", doffset); |
| 211 | } |
| 212 | |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 213 | bool ClawMotor::is_ready() const { |
| 214 | return ( |
| 215 | (top_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED && |
| 216 | bottom_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED) || |
| 217 | (::aos::robot_state->autonomous && |
| 218 | ((top_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED || |
| 219 | top_claw_.zeroing_state() == |
| 220 | ZeroedStateFeedbackLoop::DISABLED_CALIBRATION) && |
| 221 | (bottom_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED || |
| 222 | bottom_claw_.zeroing_state() == |
| 223 | ZeroedStateFeedbackLoop::DISABLED_CALIBRATION)))); |
| 224 | } |
| 225 | |
| 226 | bool ClawMotor::is_zeroing() const { return !is_ready(); } |
| 227 | |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 228 | // Positive angle is up, and positive power is up. |
Austin Schuh | cc0bf31 | 2014-02-09 00:39:29 -0800 | [diff] [blame] | 229 | void ClawMotor::RunIteration(const control_loops::ClawGroup::Goal *goal, |
| 230 | const control_loops::ClawGroup::Position *position, |
| 231 | control_loops::ClawGroup::Output *output, |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 232 | ::aos::control_loops::Status *status) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 233 | constexpr double dt = 0.01; |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 234 | |
| 235 | // Disable the motors now so that all early returns will return with the |
| 236 | // motors disabled. |
| 237 | if (output) { |
| 238 | output->top_claw_voltage = 0; |
| 239 | output->bottom_claw_voltage = 0; |
| 240 | output->intake_voltage = 0; |
| 241 | } |
| 242 | |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 243 | // TODO(austin): Handle the disabled state and the disabled -> enabled |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 244 | // transition in all of these states. |
| 245 | // TODO(austin): Handle zeroing while disabled correctly (only use a single |
| 246 | // edge and direction when zeroing.) |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 247 | |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 248 | if (::aos::robot_state.get() == nullptr) { |
| 249 | return; |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 250 | } |
| 251 | |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 252 | const frc971::constants::Values &values = constants::GetValues(); |
| 253 | |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 254 | if (position) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 255 | Eigen::Matrix<double, 2, 1> Y; |
| 256 | Y << position->bottom.position + bottom_claw_.offset(), |
| 257 | position->top.position + top_claw_.offset(); |
| 258 | claw_.Correct(Y); |
| 259 | |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 260 | top_claw_.SetPositionValues(position->top); |
| 261 | bottom_claw_.SetPositionValues(position->bottom); |
| 262 | |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 263 | if (!has_top_claw_goal_) { |
| 264 | has_top_claw_goal_ = true; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 265 | top_claw_goal_ = top_claw_.absolute_position(); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 266 | initial_separation_ = |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 267 | top_claw_.absolute_position() - bottom_claw_.absolute_position(); |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 268 | } |
| 269 | if (!has_bottom_claw_goal_) { |
| 270 | has_bottom_claw_goal_ = true; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 271 | bottom_claw_goal_ = bottom_claw_.absolute_position(); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 272 | initial_separation_ = |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 273 | top_claw_.absolute_position() - bottom_claw_.absolute_position(); |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 274 | } |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 275 | LOG(DEBUG, "Claw position is (top: %f bottom: %f\n", |
| 276 | top_claw_.absolute_position(), bottom_claw_.absolute_position()); |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | bool autonomous = ::aos::robot_state->autonomous; |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 280 | bool enabled = ::aos::robot_state->enabled; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 281 | |
| 282 | if ((top_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED && |
| 283 | bottom_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED) || |
| 284 | (autonomous && |
| 285 | ((top_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED || |
| 286 | top_claw_.zeroing_state() == |
| 287 | ZeroedStateFeedbackLoop::DISABLED_CALIBRATION) && |
| 288 | (bottom_claw_.zeroing_state() == ZeroedStateFeedbackLoop::CALIBRATED || |
| 289 | bottom_claw_.zeroing_state() == |
| 290 | ZeroedStateFeedbackLoop::DISABLED_CALIBRATION)))) { |
| 291 | // Ready to use the claw. |
| 292 | // Limit the goals here. |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 293 | bottom_claw_goal_ = goal->bottom_angle; |
| 294 | top_claw_goal_ = goal->bottom_angle + goal->seperation_angle; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 295 | has_bottom_claw_goal_ = true; |
| 296 | has_top_claw_goal_ = true; |
| 297 | doing_calibration_fine_tune_ = false; |
| 298 | |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 299 | mode_ = READY; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 300 | } else if (top_claw_.zeroing_state() != |
| 301 | ZeroedStateFeedbackLoop::UNKNOWN_POSITION && |
| 302 | bottom_claw_.zeroing_state() != |
| 303 | ZeroedStateFeedbackLoop::UNKNOWN_POSITION) { |
| 304 | // Time to fine tune the zero. |
| 305 | // Limit the goals here. |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 306 | // TODO(austin): Handle disabled state here. |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 307 | if (bottom_claw_.zeroing_state() != ZeroedStateFeedbackLoop::CALIBRATED) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 308 | // always get the bottom claw to calibrated first |
| 309 | LOG(DEBUG, "Calibrating the bottom of the claw\n"); |
| 310 | if (!doing_calibration_fine_tune_) { |
| 311 | if (::std::abs(bottom_absolute_position() - |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 312 | values.claw.start_fine_tune_pos) < |
| 313 | values.claw.claw_unimportant_epsilon) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 314 | doing_calibration_fine_tune_ = true; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 315 | bottom_claw_goal_ += values.claw.claw_zeroing_speed * dt; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 316 | LOG(DEBUG, "Ready to fine tune the bottom\n"); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 317 | mode_ = FINE_TUNE_BOTTOM; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 318 | } else { |
| 319 | // send bottom to zeroing start |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 320 | bottom_claw_goal_ = values.claw.start_fine_tune_pos; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 321 | LOG(DEBUG, "Going to the start position for the bottom\n"); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 322 | mode_ = PREP_FINE_TUNE_BOTTOM; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 323 | } |
| 324 | } else { |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 325 | mode_ = FINE_TUNE_BOTTOM; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 326 | bottom_claw_goal_ += values.claw.claw_zeroing_speed * dt; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 327 | if (top_claw_.front_hall_effect() || top_claw_.back_hall_effect() || |
| 328 | bottom_claw_.front_hall_effect() || |
| 329 | bottom_claw_.back_hall_effect()) { |
| 330 | // We shouldn't hit a limit, but if we do, go back to the zeroing |
| 331 | // point and try again. |
| 332 | doing_calibration_fine_tune_ = false; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 333 | bottom_claw_goal_ = values.claw.start_fine_tune_pos; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 334 | LOG(DEBUG, "Found a limit, starting over.\n"); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 335 | mode_ = PREP_FINE_TUNE_BOTTOM; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 336 | } |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 337 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 338 | if (bottom_claw_.calibration_hall_effect()) { |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 339 | if (bottom_claw_.calibration_hall_effect_posedge_count_changed() && |
| 340 | position) { |
| 341 | // do calibration |
| 342 | bottom_claw_.SetCalibration( |
| 343 | position->bottom.posedge_value, |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 344 | values.claw.lower_claw.calibration.lower_angle); |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 345 | bottom_claw_.set_zeroing_state(ZeroedStateFeedbackLoop::CALIBRATED); |
| 346 | // calibrated so we are done fine tuning bottom |
| 347 | doing_calibration_fine_tune_ = false; |
| 348 | LOG(DEBUG, "Calibrated the bottom correctly!\n"); |
| 349 | } else { |
| 350 | doing_calibration_fine_tune_ = false; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 351 | bottom_claw_goal_ = values.claw.start_fine_tune_pos; |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 352 | mode_ = PREP_FINE_TUNE_BOTTOM; |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 353 | } |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 354 | } else { |
| 355 | LOG(DEBUG, "Fine tuning\n"); |
| 356 | } |
| 357 | } |
| 358 | // now set the top claw to track |
| 359 | |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 360 | top_claw_goal_ = bottom_claw_goal_ + values.claw.claw_zeroing_separation; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 361 | } else { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 362 | // bottom claw must be calibrated, start on the top |
| 363 | if (!doing_calibration_fine_tune_) { |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 364 | if (::std::abs(top_absolute_position() - |
| 365 | values.claw.start_fine_tune_pos) < |
| 366 | values.claw.claw_unimportant_epsilon) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 367 | doing_calibration_fine_tune_ = true; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 368 | top_claw_goal_ += values.claw.claw_zeroing_speed * dt; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 369 | LOG(DEBUG, "Ready to fine tune the top\n"); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 370 | mode_ = FINE_TUNE_TOP; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 371 | } else { |
| 372 | // send top to zeroing start |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 373 | top_claw_goal_ = values.claw.start_fine_tune_pos; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 374 | LOG(DEBUG, "Going to the start position for the top\n"); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 375 | mode_ = PREP_FINE_TUNE_TOP; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 376 | } |
| 377 | } else { |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 378 | mode_ = FINE_TUNE_TOP; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 379 | top_claw_goal_ += values.claw.claw_zeroing_speed * dt; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 380 | if (top_claw_.front_hall_effect() || top_claw_.back_hall_effect() || |
| 381 | bottom_claw_.front_hall_effect() || |
| 382 | bottom_claw_.back_hall_effect()) { |
| 383 | // this should not happen, but now we know it won't |
| 384 | doing_calibration_fine_tune_ = false; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 385 | top_claw_goal_ = values.claw.start_fine_tune_pos; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 386 | LOG(DEBUG, "Found a limit, starting over.\n"); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 387 | mode_ = PREP_FINE_TUNE_TOP; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 388 | } |
| 389 | if (top_claw_.calibration_hall_effect()) { |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 390 | if (top_claw_.calibration_hall_effect_posedge_count_changed() && |
| 391 | position) { |
| 392 | // do calibration |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 393 | top_claw_.SetCalibration( |
| 394 | position->top.posedge_value, |
| 395 | values.claw.upper_claw.calibration.lower_angle); |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 396 | top_claw_.set_zeroing_state(ZeroedStateFeedbackLoop::CALIBRATED); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 397 | // calibrated so we are done fine tuning top |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 398 | doing_calibration_fine_tune_ = false; |
| 399 | LOG(DEBUG, "Calibrated the top correctly!\n"); |
| 400 | } else { |
| 401 | doing_calibration_fine_tune_ = false; |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 402 | top_claw_goal_ = values.claw.start_fine_tune_pos; |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 403 | mode_ = PREP_FINE_TUNE_TOP; |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 404 | } |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 405 | } |
| 406 | } |
| 407 | // now set the bottom claw to track |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 408 | bottom_claw_goal_ = top_claw_goal_ - values.claw.claw_zeroing_separation; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 409 | } |
| 410 | } else { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 411 | doing_calibration_fine_tune_ = false; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 412 | if (!was_enabled_ && enabled) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 413 | if (position) { |
| 414 | top_claw_goal_ = position->top.position; |
| 415 | bottom_claw_goal_ = position->bottom.position; |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 416 | initial_separation_ = |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 417 | position->top.position - position->bottom.position; |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 418 | } else { |
| 419 | has_top_claw_goal_ = false; |
| 420 | has_bottom_claw_goal_ = false; |
| 421 | } |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 422 | } |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 423 | |
| 424 | // TODO(austin): Limit the goals here. |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 425 | |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 426 | if ((bottom_claw_.zeroing_state() != |
| 427 | ZeroedStateFeedbackLoop::UNKNOWN_POSITION || |
| 428 | bottom_claw_.front_hall_effect() || top_claw_.front_hall_effect()) && |
| 429 | !top_claw_.back_hall_effect() && !bottom_claw_.back_hall_effect()) { |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 430 | if (enabled) { |
| 431 | // Time to slowly move back up to find any position to narrow down the |
| 432 | // zero. |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 433 | top_claw_goal_ += values.claw.claw_zeroing_off_speed * dt; |
| 434 | bottom_claw_goal_ += values.claw.claw_zeroing_off_speed * dt; |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 435 | // TODO(austin): Goal velocity too! |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 436 | LOG(DEBUG, "Bottom is known.\n"); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 437 | } |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 438 | } else { |
| 439 | // We don't know where either claw is. Slowly start moving down to find |
| 440 | // any hall effect. |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 441 | if (enabled) { |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 442 | top_claw_goal_ -= values.claw.claw_zeroing_off_speed * dt; |
| 443 | bottom_claw_goal_ -= values.claw.claw_zeroing_off_speed * dt; |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 444 | // TODO(austin): Goal velocity too! |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 445 | LOG(DEBUG, "Both are unknown.\n"); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | |
| 449 | if (enabled) { |
| 450 | top_claw_.SetCalibrationOnEdge( |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 451 | values.claw.upper_claw, ZeroedStateFeedbackLoop::APPROXIMATE_CALIBRATION); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 452 | bottom_claw_.SetCalibrationOnEdge( |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 453 | values.claw.lower_claw, ZeroedStateFeedbackLoop::APPROXIMATE_CALIBRATION); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 454 | } else { |
| 455 | top_claw_.SetCalibrationOnEdge( |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 456 | values.claw.upper_claw, ZeroedStateFeedbackLoop::DISABLED_CALIBRATION); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 457 | bottom_claw_.SetCalibrationOnEdge( |
Austin Schuh | d27931c | 2014-02-16 19:18:20 -0800 | [diff] [blame] | 458 | values.claw.lower_claw, ZeroedStateFeedbackLoop::DISABLED_CALIBRATION); |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 459 | } |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 460 | mode_ = UNKNOWN_LOCATION; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 461 | } |
| 462 | |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 463 | if (has_top_claw_goal_ && has_bottom_claw_goal_) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 464 | claw_.R << bottom_claw_goal_, top_claw_goal_ - bottom_claw_goal_, 0, 0; |
| 465 | double separation = -971; |
| 466 | if (position != nullptr) { |
| 467 | separation = position->top.position - position->bottom.position; |
| 468 | } |
| 469 | LOG(DEBUG, "Goal is %f (bottom) %f, separation is %f\n", claw_.R(0, 0), |
| 470 | claw_.R(1, 0), separation); |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 471 | |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 472 | // Only cap power when one of the halves of the claw is unknown. |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 473 | claw_.set_is_zeroing(mode_ == UNKNOWN_LOCATION || mode_ == FINE_TUNE_TOP || |
| 474 | mode_ == FINE_TUNE_BOTTOM); |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 475 | claw_.Update(output == nullptr); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 476 | } else { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 477 | claw_.Update(true); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 478 | } |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 479 | |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 480 | capped_goal_ = false; |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 481 | switch (mode_) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 482 | case READY: |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 483 | case PREP_FINE_TUNE_TOP: |
| 484 | case PREP_FINE_TUNE_BOTTOM: |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 485 | break; |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 486 | case FINE_TUNE_BOTTOM: |
| 487 | case FINE_TUNE_TOP: |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 488 | case UNKNOWN_LOCATION: { |
| 489 | if (claw_.uncapped_average_voltage() > values.claw.max_zeroing_voltage) { |
| 490 | double dx = (claw_.uncapped_average_voltage() - |
| 491 | values.claw.max_zeroing_voltage) / |
| 492 | claw_.K(0, 0); |
| 493 | bottom_claw_goal_ -= dx; |
| 494 | top_claw_goal_ -= dx; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 495 | capped_goal_ = true; |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 496 | LOG(DEBUG, "Moving the goal by %f to prevent windup\n", dx); |
Austin Schuh | e7f90d1 | 2014-02-17 00:48:25 -0800 | [diff] [blame^] | 497 | LOG(DEBUG, "Uncapped is %f, max is %f, difference is %f\n", |
| 498 | claw_.uncapped_average_voltage(), values.claw.max_zeroing_voltage, |
| 499 | (claw_.uncapped_average_voltage() - |
| 500 | values.claw.max_zeroing_voltage)); |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 501 | } else if (claw_.uncapped_average_voltage() < |
| 502 | -values.claw.max_zeroing_voltage) { |
| 503 | double dx = (claw_.uncapped_average_voltage() + |
| 504 | values.claw.max_zeroing_voltage) / |
| 505 | claw_.K(0, 0); |
| 506 | bottom_claw_goal_ -= dx; |
| 507 | top_claw_goal_ -= dx; |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 508 | capped_goal_ = true; |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 509 | LOG(DEBUG, "Moving the goal by %f to prevent windup\n", dx); |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 510 | } |
Austin Schuh | 4cb047f | 2014-02-16 21:10:19 -0800 | [diff] [blame] | 511 | } break; |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | if (output) { |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 515 | output->top_claw_voltage = claw_.U(1, 0) + claw_.U(0, 0); |
| 516 | output->bottom_claw_voltage = claw_.U(0, 0); |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 517 | } |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 518 | status->done = false; |
Austin Schuh | 4b7b5d0 | 2014-02-10 21:20:34 -0800 | [diff] [blame] | 519 | |
| 520 | was_enabled_ = ::aos::robot_state->enabled; |
Austin Schuh | 3bb9a44 | 2014-02-02 16:01:45 -0800 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | } // namespace control_loops |
| 524 | } // namespace frc971 |