diff --git a/sysid/src/main/native/cpp/analysis/AnalysisManager.cpp b/sysid/src/main/native/cpp/analysis/AnalysisManager.cpp index be88b5738c..4e396410f8 100644 --- a/sysid/src/main/native/cpp/analysis/AnalysisManager.cpp +++ b/sysid/src/main/native/cpp/analysis/AnalysisManager.cpp @@ -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; diff --git a/sysid/src/main/native/cpp/analysis/FeedbackAnalysis.cpp b/sysid/src/main/native/cpp/analysis/FeedbackAnalysis.cpp index 0691aaf6eb..7f8a3765e3 100644 --- a/sysid/src/main/native/cpp/analysis/FeedbackAnalysis.cpp +++ b/sysid/src/main/native/cpp/analysis/FeedbackAnalysis.cpp @@ -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( diff --git a/sysid/src/main/native/cpp/view/Analyzer.cpp b/sysid/src/main/native/cpp/view/Analyzer.cpp index f121ab51d8..467c0f611d 100644 --- a/sysid/src/main/native/cpp/view/Analyzer.cpp +++ b/sysid/src/main/native/cpp/view/Analyzer.cpp @@ -562,7 +562,6 @@ void Analyzer::DisplayFeedbackGains() { m_settings.type = FeedbackControllerLoopType::kVelocity; m_selectedLoopType = static_cast(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(); diff --git a/sysid/src/main/native/include/sysid/analysis/AnalysisManager.h b/sysid/src/main/native/include/sysid/analysis/AnalysisManager.h index d2c38e1aef..5ad2c87494 100644 --- a/sysid/src/main/native/include/sysid/analysis/AnalysisManager.h +++ b/sysid/src/main/native/include/sysid/analysis/AnalysisManager.h @@ -74,22 +74,6 @@ class AnalysisManager { * zero indicates it needs to be set to the default. */ units::second_t stepTestDuration = 0_s; - - /** - * The conversion factor of counts per revolution. - */ - int cpr = 1440; - - /** - * The conversion factor of gearing. - */ - double gearing = 1; - - /** - * Whether or not the gains should be in the encoder's units (mainly for use - * in a smart motor controller). - */ - bool convertGainsToEncTicks = false; }; /** diff --git a/sysid/src/main/native/include/sysid/analysis/FeedbackAnalysis.h b/sysid/src/main/native/include/sysid/analysis/FeedbackAnalysis.h index 51754a241d..397aa8797b 100644 --- a/sysid/src/main/native/include/sysid/analysis/FeedbackAnalysis.h +++ b/sysid/src/main/native/include/sysid/analysis/FeedbackAnalysis.h @@ -48,18 +48,14 @@ struct FeedbackGains { * Calculates position feedback gains for the given controller preset, LQR * controller gain parameters and feedforward gains. * - * @param preset The feedback controller preset. - * @param params The parameters for calculating optimal feedback - * gains. - * @param Kv Velocity feedforward gain. - * @param Ka Acceleration feedforward gain. - * @param encFactor The factor to convert the gains from output units to - * encoder units. This is usually encoder EPR * gearing - * * units per rotation. + * @param preset The feedback controller preset. + * @param params The parameters for calculating optimal feedback gains. + * @param Kv Velocity feedforward gain. + * @param Ka Acceleration feedforward gain. */ FeedbackGains CalculatePositionFeedbackGains( const FeedbackControllerPreset& preset, const LQRParameters& params, - double Kv, double Ka, double encFactor = 1.0); + double Kv, double Ka); /** * Calculates velocity feedback gains for the given controller preset, LQR diff --git a/sysid/src/main/native/include/sysid/view/Analyzer.h b/sysid/src/main/native/include/sysid/view/Analyzer.h index 7175cb9ca4..a3bbf91f68 100644 --- a/sysid/src/main/native/include/sysid/view/Analyzer.h +++ b/sysid/src/main/native/include/sysid/view/Analyzer.h @@ -227,9 +227,6 @@ class Analyzer : public glass::View { double m_threshold = 0.2; float m_stepTestDuration = 0; - double m_gearingNumerator = 1.0; - double m_gearingDenominator = 1.0; - bool combinedGraphFit = false; // Logger