[sysid] Remove unused "gains to encoder counts" checkbox (#6234)

This commit is contained in:
Tyler Veness
2024-01-15 22:40:45 -08:00
committed by GitHub
parent 6da21c4943
commit 97828bd325
6 changed files with 13 additions and 95 deletions

View File

@@ -218,15 +218,11 @@ sysid::FeedbackGains AnalysisManager::CalculateFeedback(
const auto& Ka = ff[2];
FeedbackGains fb;
if (m_settings.type == FeedbackControllerLoopType::kPosition) {
fb = sysid::CalculatePositionFeedbackGains(
m_settings.preset, m_settings.lqr, Kv, Ka,
m_settings.convertGainsToEncTicks ? m_settings.gearing * m_settings.cpr
: 1);
fb = sysid::CalculatePositionFeedbackGains(m_settings.preset,
m_settings.lqr, Kv, Ka);
} else {
fb = sysid::CalculateVelocityFeedbackGains(
m_settings.preset, m_settings.lqr, Kv, Ka,
m_settings.convertGainsToEncTicks ? m_settings.gearing * m_settings.cpr
: 1);
fb = sysid::CalculateVelocityFeedbackGains(m_settings.preset,
m_settings.lqr, Kv, Ka);
}
return fb;

View File

@@ -20,7 +20,7 @@ using Ka_t = decltype(1_V / 1_mps_sq);
FeedbackGains sysid::CalculatePositionFeedbackGains(
const FeedbackControllerPreset& preset, const LQRParameters& params,
double Kv, double Ka, double encFactor) {
double Kv, double Ka) {
// If acceleration requires no effort, velocity becomes an input for position
// control. We choose an appropriate model in this case to avoid numerical
// instabilities in the LQR.
@@ -34,9 +34,9 @@ FeedbackGains sysid::CalculatePositionFeedbackGains(
// Compensate for any latency from sensor measurements, filtering, etc.
controller.LatencyCompensate(system, preset.period, 0.0_s);
return {controller.K(0, 0) * preset.outputConversionFactor / encFactor,
return {controller.K(0, 0) * preset.outputConversionFactor,
controller.K(0, 1) * preset.outputConversionFactor /
(encFactor * (preset.normalized ? 1 : preset.period.value()))};
(preset.normalized ? 1 : preset.period.value())};
}
// This is our special model to avoid instabilities in the LQR.
@@ -49,8 +49,7 @@ FeedbackGains sysid::CalculatePositionFeedbackGains(
// Compensate for any latency from sensor measurements, filtering, etc.
controller.LatencyCompensate(system, preset.period, 0.0_s);
return {Kv * controller.K(0, 0) * preset.outputConversionFactor / encFactor,
0.0};
return {Kv * controller.K(0, 0) * preset.outputConversionFactor, 0.0};
}
FeedbackGains sysid::CalculateVelocityFeedbackGains(

View File

@@ -562,7 +562,6 @@ void Analyzer::DisplayFeedbackGains() {
m_settings.type = FeedbackControllerLoopType::kVelocity;
m_selectedLoopType =
static_cast<int>(FeedbackControllerLoopType::kVelocity);
m_settings.convertGainsToEncTicks = m_selectedPreset > 2;
UpdateFeedbackGains();
}
ImGui::SameLine();
@@ -646,59 +645,6 @@ void Analyzer::DisplayFeedbackGains() {
"accurate if the characteristic timescale of the mechanism "
"is small.");
// Add CPR and Gearing for converting Feedback Gains
ImGui::Separator();
ImGui::Spacing();
if (ImGui::Checkbox("Convert Gains to Encoder Counts",
&m_settings.convertGainsToEncTicks)) {
UpdateFeedbackGains();
}
sysid::CreateTooltip(
"Whether the feedback gains should be in terms of encoder counts or "
"output units. Because smart motor controllers usually don't have "
"direct access to the output units (i.e. m/s for a drivetrain), they "
"perform feedback on the encoder counts directly. If you are using a "
"PID Controller on the RoboRIO, you are probably performing feedback "
"on the output units directly.\n\nNote that if you have properly set "
"up position and velocity conversion factors with the SPARK MAX, you "
"can leave this box unchecked. The motor controller will perform "
"feedback on the output directly.");
if (m_settings.convertGainsToEncTicks) {
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 5);
if (ImGui::InputDouble("##Numerator", &m_gearingNumerator, 0.0, 0.0, "%.4f",
ImGuiInputTextFlags_EnterReturnsTrue) &&
m_gearingNumerator > 0) {
m_settings.gearing = m_gearingNumerator / m_gearingDenominator;
UpdateFeedbackGains();
}
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 5);
if (ImGui::InputDouble("##Denominator", &m_gearingDenominator, 0.0, 0.0,
"%.4f", ImGuiInputTextFlags_EnterReturnsTrue) &&
m_gearingDenominator > 0) {
m_settings.gearing = m_gearingNumerator / m_gearingDenominator;
UpdateFeedbackGains();
}
sysid::CreateTooltip(
"The gearing between the encoder and the motor shaft (# of encoder "
"turns / # of motor shaft turns).");
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 5);
if (ImGui::InputInt("CPR", &m_settings.cpr, 0, 0,
ImGuiInputTextFlags_EnterReturnsTrue) &&
m_settings.cpr > 0) {
UpdateFeedbackGains();
}
sysid::CreateTooltip(
"The counts per rotation of your encoder. This is the number of counts "
"reported in user code when the encoder is rotated exactly once. Some "
"common values for various motors/encoders are:\n\n"
"Falcon 500: 2048\nNEO: 1\nCTRE Mag Encoder / CANCoder: 4096\nREV "
"Through Bore Encoder: 8192\n");
}
ImGui::Separator();
ImGui::Spacing();