[wpimath] Make SimpleMotorFeedforward only support discrete feedforward (#6647)

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
Nicholas Armstrong
2024-07-16 20:23:11 -04:00
committed by GitHub
parent 5f261a88af
commit 30c7632ab8
31 changed files with 540 additions and 218 deletions

View File

@@ -40,8 +40,7 @@ class Robot : public frc::TimedRobot {
m_motor.SetSetpoint(
ExampleSmartMotorController::PIDMode::kPosition,
m_setpoint.position.value(),
m_feedforward.Calculate(m_setpoint.velocity, next.velocity, kDt) /
12_V);
m_feedforward.Calculate(m_setpoint.velocity, next.velocity) / 12_V);
m_setpoint = next;
}

View File

@@ -54,9 +54,10 @@ class Robot : public frc::TimedRobot {
// accelerate the shooter wheel
.IfHigh([&shooter = m_shooter, &controller = m_controller, &ff = m_ff,
&encoder = m_shooterEncoder] {
shooter.SetVoltage(units::volt_t{controller.Calculate(
encoder.GetRate(), SHOT_VELOCITY.value())} +
ff.Calculate(SHOT_VELOCITY));
shooter.SetVoltage(
units::volt_t{controller.Calculate(encoder.GetRate(),
SHOT_VELOCITY.value())} +
ff.Calculate(units::radians_per_second_t{SHOT_VELOCITY}));
});
// if not, stop
(!shootTrigger).IfHigh([&shooter = m_shooter] { shooter.Set(0.0); });

View File

@@ -11,6 +11,7 @@
#include <frc/simulation/EncoderSim.h>
#include <frc/simulation/FlywheelSim.h>
#include <frc/smartdashboard/SmartDashboard.h>
#include <frc/system/plant/LinearSystemId.h>
#include <units/moment_of_inertia.h>
/**

View File

@@ -5,6 +5,7 @@
#include "subsystems/ShooterSubsystem.h"
#include <frc/controller/PIDController.h>
#include <units/angular_velocity.h>
#include "Constants.h"