Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 1 | #include "y2016/control_loops/superstructure/superstructure_controls.h" |
| 2 | |
| 3 | #include "aos/common/controls/control_loops.q.h" |
| 4 | #include "aos/common/logging/logging.h" |
| 5 | |
| 6 | #include "y2016/control_loops/superstructure/integral_intake_plant.h" |
| 7 | #include "y2016/control_loops/superstructure/integral_arm_plant.h" |
| 8 | |
| 9 | #include "y2016/constants.h" |
| 10 | |
| 11 | namespace y2016 { |
| 12 | namespace control_loops { |
| 13 | namespace superstructure { |
| 14 | |
| 15 | using ::frc971::PotAndIndexPosition; |
| 16 | using ::frc971::EstimatorState; |
| 17 | |
| 18 | namespace { |
| 19 | double UseUnlessZero(double target_value, double default_value) { |
| 20 | if (target_value != 0.0) { |
| 21 | return target_value; |
| 22 | } else { |
| 23 | return default_value; |
| 24 | } |
| 25 | } |
| 26 | } // namespace |
| 27 | |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 28 | // Intake |
| 29 | Intake::Intake() |
Brian Silverman | 2b1957a | 2016-02-14 20:29:57 -0500 | [diff] [blame] | 30 | : loop_(new ::frc971::control_loops::SimpleCappedStateFeedbackLoop<3, 1, 1>( |
| 31 | ::y2016::control_loops::superstructure::MakeIntegralIntakeLoop())), |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 32 | estimator_(constants::GetValues().intake.zeroing), |
| 33 | profile_(::aos::controls::kLoopFrequency) { |
| 34 | Y_.setZero(); |
| 35 | unprofiled_goal_.setZero(); |
| 36 | offset_.setZero(); |
| 37 | AdjustProfile(0.0, 0.0); |
| 38 | } |
| 39 | |
| 40 | void Intake::UpdateIntakeOffset(double offset) { |
| 41 | const double doffset = offset - offset_(0, 0); |
| 42 | LOG(INFO, "Adjusting Intake offset from %f to %f\n", offset_(0, 0), offset); |
| 43 | |
| 44 | loop_->mutable_X_hat()(0, 0) += doffset; |
| 45 | Y_(0, 0) += doffset; |
| 46 | loop_->mutable_R(0, 0) += doffset; |
| 47 | |
| 48 | profile_.MoveGoal(doffset); |
| 49 | offset_(0, 0) = offset; |
| 50 | |
| 51 | CapGoal("R", &loop_->mutable_R()); |
| 52 | } |
| 53 | |
| 54 | void Intake::Correct(PotAndIndexPosition position) { |
| 55 | estimator_.UpdateEstimate(position); |
| 56 | |
Diana Vandenberg | e2843c6 | 2016-02-13 17:44:20 -0800 | [diff] [blame] | 57 | if (estimator_.error()) { |
| 58 | LOG(ERROR, "zeroing error with intake_estimator\n"); |
| 59 | return; |
| 60 | } |
| 61 | |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 62 | if (!initialized_) { |
| 63 | if (estimator_.offset_ready()) { |
| 64 | UpdateIntakeOffset(estimator_.offset()); |
| 65 | initialized_ = true; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | if (!zeroed_ && estimator_.zeroed()) { |
| 70 | UpdateIntakeOffset(estimator_.offset()); |
| 71 | zeroed_ = true; |
| 72 | } |
| 73 | |
| 74 | Y_ << position.encoder; |
| 75 | Y_ += offset_; |
| 76 | loop_->Correct(Y_); |
| 77 | } |
| 78 | |
| 79 | void Intake::CapGoal(const char *name, Eigen::Matrix<double, 3, 1> *goal) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 80 | // Limit the goal to min/max allowable angles. |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 81 | if ((*goal)(0, 0) > constants::Values::kIntakeRange.upper) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 82 | LOG(WARNING, "Intake goal %s above limit, %f > %f\n", name, (*goal)(0, 0), |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 83 | constants::Values::kIntakeRange.upper); |
| 84 | (*goal)(0, 0) = constants::Values::kIntakeRange.upper; |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 85 | } |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 86 | if ((*goal)(0, 0) < constants::Values::kIntakeRange.lower) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 87 | LOG(WARNING, "Intake goal %s below limit, %f < %f\n", name, (*goal)(0, 0), |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 88 | constants::Values::kIntakeRange.lower); |
| 89 | (*goal)(0, 0) = constants::Values::kIntakeRange.lower; |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
| 93 | void Intake::ForceGoal(double goal) { |
| 94 | set_unprofiled_goal(goal); |
| 95 | loop_->mutable_R() = unprofiled_goal_; |
| 96 | loop_->mutable_next_R() = loop_->R(); |
| 97 | |
| 98 | profile_.MoveCurrentState(loop_->R().block<2, 1>(0, 0)); |
| 99 | } |
| 100 | |
| 101 | void Intake::set_unprofiled_goal(double unprofiled_goal) { |
| 102 | unprofiled_goal_(0, 0) = unprofiled_goal; |
| 103 | unprofiled_goal_(1, 0) = 0.0; |
| 104 | unprofiled_goal_(2, 0) = 0.0; |
| 105 | CapGoal("unprofiled R", &unprofiled_goal_); |
| 106 | } |
| 107 | |
| 108 | void Intake::Update(bool disable) { |
| 109 | if (!disable) { |
| 110 | ::Eigen::Matrix<double, 2, 1> goal_state = |
| 111 | profile_.Update(unprofiled_goal_(0, 0), unprofiled_goal_(1, 0)); |
| 112 | |
| 113 | loop_->mutable_next_R(0, 0) = goal_state(0, 0); |
| 114 | loop_->mutable_next_R(1, 0) = goal_state(1, 0); |
| 115 | loop_->mutable_next_R(2, 0) = 0.0; |
| 116 | CapGoal("next R", &loop_->mutable_next_R()); |
| 117 | } |
| 118 | |
| 119 | loop_->Update(disable); |
| 120 | |
| 121 | if (!disable && loop_->U(0, 0) != loop_->U_uncapped(0, 0)) { |
| 122 | profile_.MoveCurrentState(loop_->R().block<2, 1>(0, 0)); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | bool Intake::CheckHardLimits() { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 127 | // Returns whether hard limits have been exceeded. |
| 128 | |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 129 | if (angle() > constants::Values::kIntakeRange.upper_hard || |
| 130 | angle() < constants::Values::kIntakeRange.lower_hard) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 131 | LOG(ERROR, "Intake at %f out of bounds [%f, %f], ESTOPing\n", angle(), |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 132 | constants::Values::kIntakeRange.lower_hard, constants::Values::kIntakeRange.upper_hard); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 133 | return true; |
| 134 | } |
| 135 | |
| 136 | return false; |
| 137 | } |
| 138 | |
| 139 | void Intake::set_max_voltage(double voltage) { |
Brian Silverman | 2b1957a | 2016-02-14 20:29:57 -0500 | [diff] [blame] | 140 | loop_->set_max_voltages(voltage); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | void Intake::AdjustProfile(double max_angular_velocity, |
| 144 | double max_angular_acceleration) { |
| 145 | profile_.set_maximum_velocity(UseUnlessZero(max_angular_velocity, 10.0)); |
| 146 | profile_.set_maximum_acceleration( |
| 147 | UseUnlessZero(max_angular_acceleration, 10.0)); |
| 148 | } |
| 149 | |
| 150 | void Intake::Reset() { |
| 151 | estimator_.Reset(); |
| 152 | initialized_ = false; |
| 153 | zeroed_ = false; |
| 154 | } |
| 155 | |
| 156 | EstimatorState Intake::IntakeEstimatorState() { |
| 157 | EstimatorState estimator_state; |
| 158 | ::frc971::zeroing::PopulateEstimatorState(estimator_, &estimator_state); |
| 159 | |
| 160 | return estimator_state; |
| 161 | } |
| 162 | |
| 163 | Arm::Arm() |
Brian Silverman | 2b1957a | 2016-02-14 20:29:57 -0500 | [diff] [blame] | 164 | : loop_(new ::frc971::control_loops::SimpleCappedStateFeedbackLoop<6, 2, 2>( |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 165 | ::y2016::control_loops::superstructure::MakeIntegralArmLoop())), |
| 166 | shoulder_profile_(::aos::controls::kLoopFrequency), |
| 167 | wrist_profile_(::aos::controls::kLoopFrequency), |
| 168 | shoulder_estimator_(constants::GetValues().shoulder.zeroing), |
| 169 | wrist_estimator_(constants::GetValues().wrist.zeroing) { |
| 170 | Y_.setZero(); |
| 171 | offset_.setZero(); |
| 172 | unprofiled_goal_.setZero(); |
| 173 | AdjustProfile(0.0, 0.0, 0.0, 0.0); |
| 174 | } |
| 175 | |
| 176 | void Arm::UpdateWristOffset(double offset) { |
| 177 | const double doffset = offset - offset_(1, 0); |
| 178 | LOG(INFO, "Adjusting Wrist offset from %f to %f\n", offset_(1, 0), offset); |
| 179 | |
| 180 | loop_->mutable_X_hat()(2, 0) += doffset; |
| 181 | Y_(1, 0) += doffset; |
| 182 | loop_->mutable_R(2, 0) += doffset; |
| 183 | loop_->mutable_next_R(2, 0) += doffset; |
| 184 | unprofiled_goal_(2, 0) += doffset; |
| 185 | |
| 186 | wrist_profile_.MoveGoal(doffset); |
| 187 | offset_(1, 0) = offset; |
| 188 | |
| 189 | CapGoal("R", &loop_->mutable_R()); |
| 190 | CapGoal("unprofiled R", &loop_->mutable_next_R()); |
| 191 | } |
| 192 | |
| 193 | void Arm::UpdateShoulderOffset(double offset) { |
| 194 | const double doffset = offset - offset_(0, 0); |
| 195 | LOG(INFO, "Adjusting Shoulder offset from %f to %f\n", offset_(0, 0), offset); |
| 196 | |
| 197 | loop_->mutable_X_hat()(0, 0) += doffset; |
| 198 | loop_->mutable_X_hat()(2, 0) += doffset; |
| 199 | Y_(0, 0) += doffset; |
| 200 | loop_->mutable_R(0, 0) += doffset; |
| 201 | loop_->mutable_R(2, 0) += doffset; |
| 202 | loop_->mutable_next_R(0, 0) += doffset; |
| 203 | loop_->mutable_next_R(2, 0) += doffset; |
| 204 | unprofiled_goal_(0, 0) += doffset; |
| 205 | unprofiled_goal_(2, 0) += doffset; |
| 206 | |
| 207 | shoulder_profile_.MoveGoal(doffset); |
| 208 | wrist_profile_.MoveGoal(doffset); |
| 209 | offset_(0, 0) = offset; |
| 210 | |
| 211 | CapGoal("R", &loop_->mutable_R()); |
| 212 | CapGoal("unprofiled R", &loop_->mutable_next_R()); |
| 213 | } |
| 214 | |
| 215 | // TODO(austin): Handle zeroing errors. |
| 216 | |
| 217 | void Arm::Correct(PotAndIndexPosition position_shoulder, |
| 218 | PotAndIndexPosition position_wrist) { |
| 219 | shoulder_estimator_.UpdateEstimate(position_shoulder); |
| 220 | wrist_estimator_.UpdateEstimate(position_wrist); |
| 221 | |
Diana Vandenberg | e2843c6 | 2016-02-13 17:44:20 -0800 | [diff] [blame] | 222 | // Handle zeroing errors |
| 223 | if (shoulder_estimator_.error()) { |
| 224 | LOG(ERROR, "zeroing error with shoulder_estimator\n"); |
| 225 | return; |
| 226 | } |
| 227 | if (wrist_estimator_.error()) { |
| 228 | LOG(ERROR, "zeroing error with wrist_estimator\n"); |
| 229 | return; |
| 230 | } |
| 231 | |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 232 | if (!initialized_) { |
| 233 | if (shoulder_estimator_.offset_ready() && wrist_estimator_.offset_ready()) { |
| 234 | UpdateShoulderOffset(shoulder_estimator_.offset()); |
| 235 | UpdateWristOffset(wrist_estimator_.offset()); |
| 236 | initialized_ = true; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | if (!shoulder_zeroed_ && shoulder_estimator_.zeroed()) { |
| 241 | UpdateShoulderOffset(shoulder_estimator_.offset()); |
| 242 | shoulder_zeroed_ = true; |
| 243 | } |
| 244 | if (!wrist_zeroed_ && wrist_estimator_.zeroed()) { |
| 245 | UpdateWristOffset(wrist_estimator_.offset()); |
| 246 | wrist_zeroed_ = true; |
| 247 | } |
| 248 | |
| 249 | { |
| 250 | Y_ << position_shoulder.encoder, position_wrist.encoder; |
| 251 | Y_ += offset_; |
| 252 | loop_->Correct(Y_); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | void Arm::CapGoal(const char *name, Eigen::Matrix<double, 6, 1> *goal) { |
| 257 | // Limit the goals to min/max allowable angles. |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 258 | |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 259 | if ((*goal)(0, 0) > constants::Values::kShoulderRange.upper) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 260 | LOG(WARNING, "Shoulder goal %s above limit, %f > %f\n", name, (*goal)(0, 0), |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 261 | constants::Values::kShoulderRange.upper); |
| 262 | (*goal)(0, 0) = constants::Values::kShoulderRange.upper; |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 263 | } |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 264 | if ((*goal)(0, 0) < constants::Values::kShoulderRange.lower) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 265 | LOG(WARNING, "Shoulder goal %s below limit, %f < %f\n", name, (*goal)(0, 0), |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 266 | constants::Values::kShoulderRange.lower); |
| 267 | (*goal)(0, 0) = constants::Values::kShoulderRange.lower; |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | const double wrist_goal_angle_ungrounded = (*goal)(2, 0) - (*goal)(0, 0); |
| 271 | |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 272 | if (wrist_goal_angle_ungrounded > constants::Values::kWristRange.upper) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 273 | LOG(WARNING, "Wrist goal %s above limit, %f > %f\n", name, |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 274 | wrist_goal_angle_ungrounded, constants::Values::kWristRange.upper); |
| 275 | (*goal)(2, 0) = constants::Values::kWristRange.upper + (*goal)(0, 0); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 276 | } |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 277 | if (wrist_goal_angle_ungrounded < constants::Values::kWristRange.lower) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 278 | LOG(WARNING, "Wrist goal %s below limit, %f < %f\n", name, |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 279 | wrist_goal_angle_ungrounded, constants::Values::kWristRange.lower); |
| 280 | (*goal)(2, 0) = constants::Values::kWristRange.lower + (*goal)(0, 0); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | |
| 284 | void Arm::ForceGoal(double goal_shoulder, double goal_wrist) { |
| 285 | set_unprofiled_goal(goal_shoulder, goal_wrist); |
| 286 | loop_->mutable_R() = unprofiled_goal_; |
| 287 | loop_->mutable_next_R() = loop_->R(); |
| 288 | |
| 289 | shoulder_profile_.MoveCurrentState(loop_->R().block<2, 1>(0, 0)); |
| 290 | wrist_profile_.MoveCurrentState(loop_->R().block<2, 1>(2, 0)); |
| 291 | } |
| 292 | |
| 293 | void Arm::set_unprofiled_goal(double unprofiled_goal_shoulder, |
| 294 | double unprofiled_goal_wrist) { |
| 295 | unprofiled_goal_ << unprofiled_goal_shoulder, 0.0, unprofiled_goal_wrist, 0.0, |
| 296 | 0.0, 0.0; |
| 297 | CapGoal("unprofiled R", &unprofiled_goal_); |
| 298 | } |
| 299 | |
| 300 | void Arm::AdjustProfile(double max_angular_velocity_shoulder, |
| 301 | double max_angular_acceleration_shoulder, |
| 302 | double max_angular_velocity_wrist, |
| 303 | double max_angular_acceleration_wrist) { |
| 304 | shoulder_profile_.set_maximum_velocity( |
| 305 | UseUnlessZero(max_angular_velocity_shoulder, 10.0)); |
| 306 | shoulder_profile_.set_maximum_acceleration( |
| 307 | UseUnlessZero(max_angular_acceleration_shoulder, 10.0)); |
| 308 | wrist_profile_.set_maximum_velocity( |
| 309 | UseUnlessZero(max_angular_velocity_wrist, 10.0)); |
| 310 | wrist_profile_.set_maximum_acceleration( |
| 311 | UseUnlessZero(max_angular_acceleration_wrist, 10.0)); |
| 312 | } |
| 313 | |
| 314 | bool Arm::CheckHardLimits() { |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 315 | if (shoulder_angle() > constants::Values::kShoulderRange.upper_hard || |
| 316 | shoulder_angle() < constants::Values::kShoulderRange.lower_hard) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 317 | LOG(ERROR, "Shoulder at %f out of bounds [%f, %f], ESTOPing\n", |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 318 | shoulder_angle(), constants::Values::kShoulderRange.lower_hard, |
| 319 | constants::Values::kShoulderRange.upper_hard); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 320 | return true; |
| 321 | } |
| 322 | |
Austin Schuh | 3b0f364 | 2016-02-14 21:04:26 -0800 | [diff] [blame] | 323 | if (wrist_angle() - shoulder_angle() > constants::Values::kWristRange.upper_hard || |
| 324 | wrist_angle() - shoulder_angle() < constants::Values::kWristRange.lower_hard) { |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 325 | LOG(ERROR, "Wrist at %f out of bounds [%f, %f], ESTOPing\n", |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 326 | wrist_angle() - shoulder_angle(), constants::Values::kWristRange.lower_hard, |
| 327 | constants::Values::kWristRange.upper_hard); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 328 | return true; |
| 329 | } |
| 330 | |
| 331 | return false; |
| 332 | } |
| 333 | |
| 334 | void Arm::Update(bool disable) { |
| 335 | if (!disable) { |
| 336 | // Compute next goal. |
| 337 | ::Eigen::Matrix<double, 2, 1> goal_state_shoulder = |
| 338 | shoulder_profile_.Update(unprofiled_goal_(0, 0), |
| 339 | unprofiled_goal_(1, 0)); |
| 340 | loop_->mutable_next_R(0, 0) = goal_state_shoulder(0, 0); |
| 341 | loop_->mutable_next_R(1, 0) = goal_state_shoulder(1, 0); |
| 342 | |
| 343 | ::Eigen::Matrix<double, 2, 1> goal_state_wrist = |
| 344 | wrist_profile_.Update(unprofiled_goal_(2, 0), unprofiled_goal_(3, 0)); |
| 345 | loop_->mutable_next_R(2, 0) = goal_state_wrist(0, 0); |
| 346 | loop_->mutable_next_R(3, 0) = goal_state_wrist(1, 0); |
| 347 | |
| 348 | loop_->mutable_next_R(4, 0) = unprofiled_goal_(4, 0); |
| 349 | loop_->mutable_next_R(5, 0) = unprofiled_goal_(5, 0); |
| 350 | CapGoal("next R", &loop_->mutable_next_R()); |
| 351 | } |
| 352 | |
| 353 | // Move loop |
| 354 | loop_->Update(disable); |
| 355 | |
| 356 | // Shoulder saturated |
| 357 | if (!disable && loop_->U(0, 0) != loop_->U_uncapped(0, 0)) { |
| 358 | shoulder_profile_.MoveCurrentState(loop_->R().block<2, 1>(0, 0)); |
| 359 | } |
| 360 | |
| 361 | // Wrist saturated |
| 362 | if (!disable && loop_->U(1, 0) != loop_->U_uncapped(1, 0)) { |
| 363 | wrist_profile_.MoveCurrentState(loop_->R().block<2, 1>(2, 0)); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | void Arm::set_max_voltage(double shoulder_max_voltage, |
| 368 | double wrist_max_voltage) { |
Brian Silverman | 2b1957a | 2016-02-14 20:29:57 -0500 | [diff] [blame] | 369 | loop_->set_max_voltages(shoulder_max_voltage, wrist_max_voltage); |
Austin Schuh | 10c2d11 | 2016-02-14 13:42:28 -0800 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | void Arm::Reset() { |
| 373 | shoulder_estimator_.Reset(); |
| 374 | wrist_estimator_.Reset(); |
| 375 | initialized_ = false; |
| 376 | shoulder_zeroed_ = false; |
| 377 | wrist_zeroed_ = false; |
| 378 | } |
| 379 | |
| 380 | EstimatorState Arm::ShoulderEstimatorState() { |
| 381 | EstimatorState estimator_state; |
| 382 | ::frc971::zeroing::PopulateEstimatorState(shoulder_estimator_, |
| 383 | &estimator_state); |
| 384 | |
| 385 | return estimator_state; |
| 386 | } |
| 387 | |
| 388 | EstimatorState Arm::WristEstimatorState() { |
| 389 | EstimatorState estimator_state; |
| 390 | ::frc971::zeroing::PopulateEstimatorState(wrist_estimator_, &estimator_state); |
| 391 | |
| 392 | return estimator_state; |
| 393 | } |
| 394 | |
| 395 | } // namespace superstructure |
| 396 | } // namespace control_loops |
| 397 | } // namespace y2016 |