diff --git a/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp b/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp index 9829a75d7c..f9ff4b8b24 100644 --- a/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp +++ b/wpilibc/src/main/native/cpp/motorcontrol/PWMMotorController.cpp @@ -42,6 +42,10 @@ int PWMMotorController::GetChannel() const { return m_pwm.GetChannel(); } +void PWMMotorController::EnableDeadbandElimination(bool eliminateDeadband) { + m_pwm.EnableDeadbandElimination(eliminateDeadband); +} + PWMMotorController::PWMMotorController(std::string_view name, int channel) : m_pwm(channel, false) { wpi::SendableRegistry::AddLW(this, name, channel); diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h index ac6ba4b035..7bb63fb945 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h @@ -61,6 +61,16 @@ class PWMMotorController : public MotorController, int GetChannel() const; + /** + * Optionally eliminate the deadband from a motor controller. + * + * @param eliminateDeadband If true, set the motor curve on the speed + * controller to eliminate the deadband in the middle + * of the range. Otherwise, keep the full range + * without modifying any values. + */ + void EnableDeadbandElimination(bool eliminateDeadband); + protected: /** * Constructor for a PWM Motor %Controller connected via PWM. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java index d33fb0133b..fe8ecbab45 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java @@ -104,6 +104,17 @@ public abstract class PWMMotorController extends MotorSafety return m_pwm.getChannel(); } + /** + * Optionally eliminate the deadband from a motor controller. + * + * @param eliminateDeadband If true, set the motor curve for the motor controller to eliminate the + * deadband in the middle of the range. Otherwise, keep the full range without modifying any + * values. + */ + public void enableDeadbandElimination(boolean eliminateDeadband) { + m_pwm.enableDeadbandElimination(eliminateDeadband); + } + @Override public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("Motor Controller");