From 02525a112b122f0025c651a5f7ad8ab2a4223ff3 Mon Sep 17 00:00:00 2001 From: 5690Progammers <5690programmers@gmail.com> Date: Sat, 15 Feb 2025 13:58:41 -0600 Subject: [PATCH 1/2] Add logging and update brake mode with tuner --- lib/cpp/subzero/motor/PidMotorController.cpp | 2 ++ lib/include/subzero/motor/PidMotorController.h | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cpp/subzero/motor/PidMotorController.cpp b/lib/cpp/subzero/motor/PidMotorController.cpp index fd2bfa8..e7d6788 100644 --- a/lib/cpp/subzero/motor/PidMotorController.cpp +++ b/lib/cpp/subzero/motor/PidMotorController.cpp @@ -182,6 +182,8 @@ void PidMotorController &controller) : m_controller{controller} { + frc::SmartDashboard::PutNumber(m_controller.m_name + " P Gain", m_controller.GetPidSettings().p); frc::SmartDashboard::PutNumber(m_controller.m_name + " I Gain", @@ -199,8 +200,9 @@ class PidMotorControllerTuner { /** * @brief Call this within the Periodic method of the encapsulating subsystem - * + * Note: You must enable submit button to work in Elastic */ + void UpdateFromShuffleboard() { double tP = frc::SmartDashboard::GetNumber(m_controller.m_name + " P Gain", m_controller.GetPidSettings().p); @@ -215,12 +217,12 @@ class PidMotorControllerTuner { m_controller.GetPidSettings().ff); m_controller.UpdatePidSettings( - {.p = tP, .i = tI, .d = tD, .iZone = tIZone, .ff = tFeedForward}); + {.p = tP, .i = tI, .d = tD, .iZone = tIZone, .ff = tFeedForward, .isIdleModeBrake = m_controller.GetPidSettings().isIdleModeBrake}); } private: PidMotorController &m_controller; + TPidConfig> &m_controller; }; class RevPidMotorController From 9aab48896b0afb2a51fa36af8635e9764472e7d4 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sat, 15 Feb 2025 20:00:14 +0000 Subject: [PATCH 2/2] Fix code style issues with clang_format --- lib/include/subzero/motor/PidMotorController.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/include/subzero/motor/PidMotorController.h b/lib/include/subzero/motor/PidMotorController.h index 8d5e3ea..5a1f495 100644 --- a/lib/include/subzero/motor/PidMotorController.h +++ b/lib/include/subzero/motor/PidMotorController.h @@ -217,12 +217,17 @@ class PidMotorControllerTuner { m_controller.GetPidSettings().ff); m_controller.UpdatePidSettings( - {.p = tP, .i = tI, .d = tD, .iZone = tIZone, .ff = tFeedForward, .isIdleModeBrake = m_controller.GetPidSettings().isIdleModeBrake}); + {.p = tP, + .i = tI, + .d = tD, + .iZone = tIZone, + .ff = tFeedForward, + .isIdleModeBrake = m_controller.GetPidSettings().isIdleModeBrake}); } private: PidMotorController &m_controller; + TPidConfig> &m_controller; }; class RevPidMotorController