s/change_/mutable_/g
diff --git a/frc971/control_loops/claw/claw.cc b/frc971/control_loops/claw/claw.cc
index 80f471c..b4be917 100644
--- a/frc971/control_loops/claw/claw.cc
+++ b/frc971/control_loops/claw/claw.cc
@@ -177,7 +177,7 @@
}
LOG_MATRIX(DEBUG, "adjusted_pos_error", adjusted_pos_error);
- change_U() = velocity_K * velocity_error + position_K * adjusted_pos_error;
+ mutable_U() = velocity_K * velocity_error + position_K * adjusted_pos_error;
LOG_MATRIX(DEBUG, "U is now", U());
{
@@ -185,20 +185,20 @@
if (top_known_) {
if (X_hat(0) + X_hat(1) > values.upper_claw.upper_limit && U(1) > 0) {
LOG(WARNING, "upper claw too high and moving up\n");
- change_U(1) = 0;
+ mutable_U(1) = 0;
} else if (X_hat(0) + X_hat(1) < values.upper_claw.lower_limit &&
U(1) < 0) {
LOG(WARNING, "upper claw too low and moving down\n");
- change_U(1) = 0;
+ mutable_U(1) = 0;
}
}
if (bottom_known_) {
if (X_hat(0) > values.lower_claw.upper_limit && U(0) > 0) {
LOG(WARNING, "lower claw too high and moving up\n");
- change_U(0) = 0;
+ mutable_U(0) = 0;
} else if (X_hat(0) < values.lower_claw.lower_limit && U(0) < 0) {
LOG(WARNING, "lower claw too low and moving down\n");
- change_U(0) = 0;
+ mutable_U(0) = 0;
}
}
}
@@ -504,14 +504,14 @@
}
void ClawLimitedLoop::ChangeTopOffset(double doffset) {
- change_Y()(1) += doffset;
- change_X_hat()(1) += doffset;
+ mutable_Y()(1) += doffset;
+ mutable_X_hat()(1) += doffset;
LOG(INFO, "Changing top offset by %f\n", doffset);
}
void ClawLimitedLoop::ChangeBottomOffset(double doffset) {
- change_Y()(0) += doffset;
- change_X_hat()(0) += doffset;
- change_X_hat()(1) -= doffset;
+ mutable_Y()(0) += doffset;
+ mutable_X_hat()(0) += doffset;
+ mutable_X_hat()(1) -= doffset;
LOG(INFO, "Changing bottom offset by %f\n", doffset);
}
@@ -863,7 +863,7 @@
bottom_claw_.zeroing_state() !=
ZeroedStateFeedbackLoop::UNKNOWN_POSITION);
if (has_top_claw_goal_ && has_bottom_claw_goal_) {
- claw_.change_R() << bottom_claw_goal_, top_claw_goal_ - bottom_claw_goal_,
+ claw_.mutable_R() << bottom_claw_goal_, top_claw_goal_ - bottom_claw_goal_,
bottom_claw_velocity_, top_claw_velocity_ - bottom_claw_velocity_;
LOG_MATRIX(DEBUG, "actual goal", claw_.R());
@@ -898,7 +898,7 @@
Eigen::Matrix<double, 4, 1> R;
R << bottom_claw_goal_, top_claw_goal_ - bottom_claw_goal_, claw_.R(2),
claw_.R(3);
- claw_.change_U() = claw_.K() * (R - claw_.X_hat());
+ claw_.mutable_U() = claw_.K() * (R - claw_.X_hat());
capped_goal_ = true;
LOG(DEBUG, "Moving the goal by %f to prevent windup."
" Uncapped is %f, max is %f, difference is %f\n",
@@ -920,7 +920,7 @@
Eigen::Matrix<double, 4, 1> R;
R << bottom_claw_goal_, top_claw_goal_ - bottom_claw_goal_, claw_.R(2),
claw_.R(3);
- claw_.change_U() = claw_.K() * (R - claw_.X_hat());
+ claw_.mutable_U() = claw_.K() * (R - claw_.X_hat());
capped_goal_ = true;
LOG(DEBUG, "Moving the goal by %f to prevent windup\n", dx);
}
diff --git a/frc971/control_loops/claw/claw_lib_test.cc b/frc971/control_loops/claw/claw_lib_test.cc
index 7d1fbc6..7881203 100644
--- a/frc971/control_loops/claw/claw_lib_test.cc
+++ b/frc971/control_loops/claw/claw_lib_test.cc
@@ -54,11 +54,11 @@
double initial_bottom_position) {
LOG(INFO, "Reinitializing to {top: %f, bottom: %f}\n", initial_top_position,
initial_bottom_position);
- claw_plant_->change_X(0) = initial_bottom_position;
- claw_plant_->change_X(1) = initial_top_position - initial_bottom_position;
- claw_plant_->change_X(2) = 0.0;
- claw_plant_->change_X(3) = 0.0;
- claw_plant_->change_Y() = claw_plant_->C() * claw_plant_->X();
+ claw_plant_->mutable_X(0) = initial_bottom_position;
+ claw_plant_->mutable_X(1) = initial_top_position - initial_bottom_position;
+ claw_plant_->mutable_X(2) = 0.0;
+ claw_plant_->mutable_X(3) = 0.0;
+ claw_plant_->mutable_Y() = claw_plant_->C() * claw_plant_->X();
ReinitializePartial(TOP_CLAW, initial_top_position);
ReinitializePartial(BOTTOM_CLAW, initial_bottom_position);
@@ -214,7 +214,7 @@
const frc971::constants::Values& v = constants::GetValues();
EXPECT_TRUE(claw_queue_group.output.FetchLatest());
- claw_plant_->change_U() << claw_queue_group.output->bottom_claw_voltage,
+ claw_plant_->mutable_U() << claw_queue_group.output->bottom_claw_voltage,
claw_queue_group.output->top_claw_voltage;
claw_plant_->Update();
diff --git a/frc971/control_loops/drivetrain/drivetrain.cc b/frc971/control_loops/drivetrain/drivetrain.cc
index 2bf5621..701ea1b 100644
--- a/frc971/control_loops/drivetrain/drivetrain.cc
+++ b/frc971/control_loops/drivetrain/drivetrain.cc
@@ -118,7 +118,7 @@
}
LOG_MATRIX(DEBUG, "adjusted_pos_error", adjusted_pos_error);
- change_U() =
+ mutable_U() =
velocity_K * velocity_error + position_K * T * adjusted_pos_error;
LOG_MATRIX(DEBUG, "U is now", U());
} else {
@@ -148,7 +148,7 @@
double right_velocity) {
left_goal_ = left;
right_goal_ = right;
- loop_->change_R() << left, left_velocity, right, right_velocity;
+ loop_->mutable_R() << left, left_velocity, right, right_velocity;
}
void SetRawPosition(double left, double right) {
raw_right_ = right;
@@ -167,7 +167,7 @@
}
void SetExternalMotors(double left_voltage, double right_voltage) {
- loop_->change_U() << left_voltage, right_voltage;
+ loop_->mutable_U() << left_voltage, right_voltage;
}
void Update(bool stop_motors, bool enable_control_loop) {
@@ -175,8 +175,8 @@
loop_->Update(stop_motors);
} else {
if (stop_motors) {
- loop_->change_U().setZero();
- loop_->change_U_uncapped().setZero();
+ loop_->mutable_U().setZero();
+ loop_->mutable_U_uncapped().setZero();
}
loop_->UpdateObserver();
}
@@ -564,7 +564,7 @@
// Integrate velocity to get the position.
// This position is used to get integral control.
- loop_->change_R() << left_velocity, right_velocity;
+ loop_->mutable_R() << left_velocity, right_velocity;
if (!quickturn_) {
// K * R = w
@@ -578,7 +578,7 @@
U_Poly_.k() + U_Poly_.H() * loop_->K() * loop_->X_hat());
// Limit R back inside the box.
- loop_->change_R() =
+ loop_->mutable_R() =
CoerceGoal(R_poly, equality_k, equality_w, loop_->R());
}
@@ -587,12 +587,12 @@
loop_->K() * (loop_->R() - loop_->X_hat()) + FF_volts;
for (int i = 0; i < 2; i++) {
- loop_->change_U()[i] = ::aos::Clip(U_ideal[i], -12, 12);
+ loop_->mutable_U()[i] = ::aos::Clip(U_ideal[i], -12, 12);
}
// TODO(austin): Model this better.
// TODO(austin): Feed back?
- loop_->change_X_hat() =
+ loop_->mutable_X_hat() =
loop_->A() * loop_->X_hat() + loop_->B() * loop_->U();
} else {
// Any motor is not in gear. Speed match.
@@ -604,13 +604,13 @@
const double wiggle =
(static_cast<double>((counter_ % 20) / 10) - 0.5) * 5.0;
- loop_->change_U(0) = ::aos::Clip(
+ loop_->mutable_U(0) = ::aos::Clip(
(R_left / Kv)(0, 0) + (IsInGear(left_gear_) ? 0 : wiggle),
-12.0, 12.0);
- loop_->change_U(1) = ::aos::Clip(
+ loop_->mutable_U(1) = ::aos::Clip(
(R_right / Kv)(0, 0) + (IsInGear(right_gear_) ? 0 : wiggle),
-12.0, 12.0);
- loop_->change_U() *= 12.0 / position_.battery_voltage;
+ loop_->mutable_U() *= 12.0 / position_.battery_voltage;
}
}
diff --git a/frc971/control_loops/drivetrain/drivetrain_lib_test.cc b/frc971/control_loops/drivetrain/drivetrain_lib_test.cc
index a307388..548bd06 100644
--- a/frc971/control_loops/drivetrain/drivetrain_lib_test.cc
+++ b/frc971/control_loops/drivetrain/drivetrain_lib_test.cc
@@ -59,9 +59,9 @@
// Resets the plant.
void Reinitialize() {
- drivetrain_plant_->change_X(0) = 0.0;
- drivetrain_plant_->change_X(1) = 0.0;
- drivetrain_plant_->change_Y() =
+ drivetrain_plant_->mutable_X(0) = 0.0;
+ drivetrain_plant_->mutable_X(1) = 0.0;
+ drivetrain_plant_->mutable_Y() =
drivetrain_plant_->C() * drivetrain_plant_->X();
last_left_position_ = drivetrain_plant_->Y(0);
last_right_position_ = drivetrain_plant_->Y(1);
@@ -88,7 +88,7 @@
last_left_position_ = drivetrain_plant_->Y(0);
last_right_position_ = drivetrain_plant_->Y(1);
EXPECT_TRUE(my_drivetrain_loop_.output.FetchLatest());
- drivetrain_plant_->change_U() << my_drivetrain_loop_.output->left_voltage,
+ drivetrain_plant_->mutable_U() << my_drivetrain_loop_.output->left_voltage,
my_drivetrain_loop_.output->right_voltage;
drivetrain_plant_->Update();
}
diff --git a/frc971/control_loops/shooter/shooter.cc b/frc971/control_loops/shooter/shooter.cc
index c4d183a..2d8df35 100755
--- a/frc971/control_loops/shooter/shooter.cc
+++ b/frc971/control_loops/shooter/shooter.cc
@@ -35,7 +35,7 @@
voltage_ = std::min(max_voltage_, voltage_);
voltage_ = std::max(-max_voltage_, voltage_);
- change_U(0) = voltage_ - old_voltage;
+ mutable_U(0) = voltage_ - old_voltage;
LOG_STRUCT(DEBUG, "output", ShooterVoltageToLog(X_hat(2), voltage_));
@@ -49,11 +49,11 @@
if (controller_index() == 0) {
dx = (uncapped_voltage() - max_voltage_) /
(K(0, 0) - A(1, 0) * K(0, 2) / A(1, 2));
- change_R(0) -= dx;
- change_R(2) -= -A(1, 0) / A(1, 2) * dx;
+ mutable_R(0) -= dx;
+ mutable_R(2) -= -A(1, 0) / A(1, 2) * dx;
} else {
dx = (uncapped_voltage() - max_voltage_) / K(0, 0);
- change_R(0) -= dx;
+ mutable_R(0) -= dx;
}
capped_goal_ = true;
LOG_STRUCT(DEBUG, "to prevent windup", ShooterMovingGoal(dx));
@@ -62,11 +62,11 @@
if (controller_index() == 0) {
dx = (uncapped_voltage() + max_voltage_) /
(K(0, 0) - A(1, 0) * K(0, 2) / A(1, 2));
- change_R(0) -= dx;
- change_R(2) -= -A(1, 0) / A(1, 2) * dx;
+ mutable_R(0) -= dx;
+ mutable_R(2) -= -A(1, 0) / A(1, 2) * dx;
} else {
dx = (uncapped_voltage() + max_voltage_) / K(0, 0);
- change_R(0) -= dx;
+ mutable_R(0) -= dx;
}
capped_goal_ = true;
LOG_STRUCT(DEBUG, "to prevent windup", ShooterMovingGoal(dx));
@@ -77,9 +77,9 @@
void ZeroedStateFeedbackLoop::RecalculatePowerGoal() {
if (controller_index() == 0) {
- change_R(2) = (-A(1, 0) / A(1, 2) * R(0) - A(1, 1) / A(1, 2) * R(1));
+ mutable_R(2) = (-A(1, 0) / A(1, 2) * R(0) - A(1, 1) / A(1, 2) * R(1));
} else {
- change_R(2) = -A(1, 1) / A(1, 2) * R(1);
+ mutable_R(2) = -A(1, 1) / A(1, 2) * R(1);
}
}
@@ -89,15 +89,15 @@
double previous_offset = offset_;
offset_ = known_position - encoder_val;
double doffset = offset_ - previous_offset;
- change_X_hat(0) += doffset;
+ mutable_X_hat(0) += doffset;
// Offset our measurements because the offset is baked into them.
// This is safe because if we got here, it means position != nullptr, which
// means we already set Y to something and it won't just get overwritten.
- change_Y(0) += doffset;
+ mutable_Y(0) += doffset;
// Offset the goal so we don't move.
- change_R(0) += doffset;
+ mutable_R(0) += doffset;
if (controller_index() == 0) {
- change_R(2) += -A(1, 0) / A(1, 2) * (doffset);
+ mutable_R(2) += -A(1, 0) / A(1, 2) * (doffset);
}
LOG_STRUCT(
DEBUG, "sensor edge (fake?)",
diff --git a/frc971/control_loops/shooter/shooter.h b/frc971/control_loops/shooter/shooter.h
index 7816c8e..71c1fa4 100755
--- a/frc971/control_loops/shooter/shooter.h
+++ b/frc971/control_loops/shooter/shooter.h
@@ -74,14 +74,14 @@
double goal_position() const { return R(0) + kPositionOffset; }
double goal_velocity() const { return R(1); }
void InitializeState(double position) {
- change_X_hat(0) = position - kPositionOffset;
+ mutable_X_hat(0) = position - kPositionOffset;
}
void SetGoalPosition(double desired_position, double desired_velocity) {
LOG(DEBUG, "Goal position: %f Goal velocity: %f\n", desired_position,
desired_velocity);
- change_R() << desired_position - kPositionOffset, desired_velocity,
+ mutable_R() << desired_position - kPositionOffset, desired_velocity,
(-A(1, 0) / A(1, 2) * (desired_position - kPositionOffset) -
A(1, 1) / A(1, 2) * desired_velocity);
}
diff --git a/frc971/control_loops/shooter/shooter_lib_test.cc b/frc971/control_loops/shooter/shooter_lib_test.cc
index f1beafe..49263c7 100755
--- a/frc971/control_loops/shooter/shooter_lib_test.cc
+++ b/frc971/control_loops/shooter/shooter_lib_test.cc
@@ -55,9 +55,9 @@
LOG(INFO, "Reinitializing to {pos: %f}\n", initial_position);
StateFeedbackPlant<2, 1, 1> *plant = shooter_plant_.get();
initial_position_ = initial_position;
- plant->change_X(0) = initial_position_ - kPositionOffset;
- plant->change_X(1) = 0.0;
- plant->change_Y() = plant->C() * plant->X();
+ plant->mutable_X(0) = initial_position_ - kPositionOffset;
+ plant->mutable_X(1) = 0.0;
+ plant->mutable_Y() = plant->C() * plant->X();
last_voltage_ = 0.0;
last_plant_position_ = 0.0;
SetPhysicalSensors(&last_position_message_);
@@ -213,12 +213,12 @@
}
if (brake_piston_state_) {
- shooter_plant_->change_U() << 0.0;
- shooter_plant_->change_X(1) = 0.0;
- shooter_plant_->change_Y() = shooter_plant_->C() * shooter_plant_->X() +
+ shooter_plant_->mutable_U() << 0.0;
+ shooter_plant_->mutable_X(1) = 0.0;
+ shooter_plant_->mutable_Y() = shooter_plant_->C() * shooter_plant_->X() +
shooter_plant_->D() * shooter_plant_->U();
} else {
- shooter_plant_->change_U() << last_voltage_;
+ shooter_plant_->mutable_U() << last_voltage_;
//shooter_plant_->U << shooter_queue_group_.output->voltage;
shooter_plant_->Update();
}
@@ -246,7 +246,7 @@
plunger_latched_ = false;
// TODO(austin): The brake should be set for a number of cycles after
// this as well.
- shooter_plant_->change_X(0) += 0.005;
+ shooter_plant_->mutable_X(0) += 0.005;
}
latch_delay_count_++;
}
@@ -534,7 +534,7 @@
LOG(DEBUG, "State is UnloadMove\n");
--kicked_delay;
if (kicked_delay == 0) {
- shooter_motor_.shooter_.change_R(0) -= 100;
+ shooter_motor_.shooter_.mutable_R(0) -= 100;
}
}
if (shooter_motor_.capped_goal() && kicked_delay < 0) {
@@ -574,7 +574,7 @@
LOG(DEBUG, "State is UnloadMove\n");
--kicked_delay;
if (kicked_delay == 0) {
- shooter_motor_.shooter_.change_R(0) += 0.1;
+ shooter_motor_.shooter_.mutable_R(0) += 0.1;
}
}
if (shooter_motor_.capped_goal() && kicked_delay < 0) {
diff --git a/frc971/control_loops/state_feedback_loop.h b/frc971/control_loops/state_feedback_loop.h
index aa3f9a1..9bd0165 100644
--- a/frc971/control_loops/state_feedback_loop.h
+++ b/frc971/control_loops/state_feedback_loop.h
@@ -137,12 +137,12 @@
const Eigen::Matrix<double, number_of_inputs, 1> &U() const { return U_; }
double U(int i) const { return X()(i, 0); }
- Eigen::Matrix<double, number_of_states, 1> &change_X() { return X_; }
- double &change_X(int i) { return change_X()(i, 0); }
- Eigen::Matrix<double, number_of_outputs, 1> &change_Y() { return Y_; }
- double &change_Y(int i) { return change_Y()(i, 0); }
- Eigen::Matrix<double, number_of_inputs, 1> &change_U() { return U_; }
- double &change_U(int i) { return change_U()(i, 0); }
+ Eigen::Matrix<double, number_of_states, 1> &mutable_X() { return X_; }
+ double &mutable_X(int i) { return mutable_X()(i, 0); }
+ Eigen::Matrix<double, number_of_outputs, 1> &mutable_Y() { return Y_; }
+ double &mutable_Y(int i) { return mutable_Y()(i, 0); }
+ Eigen::Matrix<double, number_of_inputs, 1> &mutable_U() { return U_; }
+ double &mutable_U(int i) { return mutable_U()(i, 0); }
const StateFeedbackPlantCoefficients<
number_of_states, number_of_inputs, number_of_outputs>
@@ -324,18 +324,18 @@
const Eigen::Matrix<double, number_of_outputs, 1> &Y() const { return Y_; }
double Y(int i) const { return Y()(i, 0); }
- Eigen::Matrix<double, number_of_states, 1> &change_X_hat() { return X_hat_; }
- double &change_X_hat(int i) { return change_X_hat()(i, 0); }
- Eigen::Matrix<double, number_of_states, 1> &change_R() { return R_; }
- double &change_R(int i) { return change_R()(i, 0); }
- Eigen::Matrix<double, number_of_inputs, 1> &change_U() { return U_; }
- double &change_U(int i) { return change_U()(i, 0); }
- Eigen::Matrix<double, number_of_inputs, 1> &change_U_uncapped() {
+ Eigen::Matrix<double, number_of_states, 1> &mutable_X_hat() { return X_hat_; }
+ double &mutable_X_hat(int i) { return mutable_X_hat()(i, 0); }
+ Eigen::Matrix<double, number_of_states, 1> &mutable_R() { return R_; }
+ double &mutable_R(int i) { return mutable_R()(i, 0); }
+ Eigen::Matrix<double, number_of_inputs, 1> &mutable_U() { return U_; }
+ double &mutable_U(int i) { return mutable_U()(i, 0); }
+ Eigen::Matrix<double, number_of_inputs, 1> &mutable_U_uncapped() {
return U_uncapped_;
}
- double &change_U_uncapped(int i) { return change_U_uncapped()(i, 0); }
- Eigen::Matrix<double, number_of_outputs, 1> &change_Y() { return Y_; }
- double &change_Y(int i) { return change_Y()(i, 0); }
+ double &mutable_U_uncapped(int i) { return mutable_U_uncapped()(i, 0); }
+ Eigen::Matrix<double, number_of_outputs, 1> &mutable_Y() { return Y_; }
+ double &mutable_Y(int i) { return mutable_Y()(i, 0); }
const StateFeedbackController<number_of_states, number_of_inputs,
number_of_outputs> &controller() const {