mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpimath] Fully discretized ElevatorFF and ArmFF (#7024)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
committed by
GitHub
parent
5d9a553104
commit
4adfa8bf64
@@ -48,7 +48,7 @@ void Elevator::ReachGoal(units::meter_t goal) {
|
||||
auto pidOutput = m_controller.Calculate(m_encoder.GetDistance(),
|
||||
m_setpoint.position / 1_m);
|
||||
auto feedforwardOutput =
|
||||
m_feedforward.Calculate(m_setpoint.velocity, next.velocity, 20_ms);
|
||||
m_feedforward.Calculate(m_setpoint.velocity, next.velocity);
|
||||
|
||||
m_motor.SetVoltage(units::volt_t{pidOutput} + feedforwardOutput);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <numbers>
|
||||
|
||||
#include <units/angle.h>
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/time.h>
|
||||
#include <units/voltage.h>
|
||||
|
||||
|
||||
@@ -28,5 +28,5 @@ class ShooterSubsystem : public frc2::PIDSubsystem {
|
||||
frc::PWMSparkMax m_shooterMotor;
|
||||
frc::PWMSparkMax m_feederMotor;
|
||||
frc::Encoder m_shooterEncoder;
|
||||
frc::SimpleMotorFeedforward<units::turns> m_shooterFeedforward;
|
||||
frc::SimpleMotorFeedforward<units::radians> m_shooterFeedforward;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ class Shooter : public frc2::SubsystemBase {
|
||||
frc::Encoder m_shooterEncoder{ShooterConstants::kEncoderPorts[0],
|
||||
ShooterConstants::kEncoderPorts[1],
|
||||
ShooterConstants::kEncoderReversed};
|
||||
frc::SimpleMotorFeedforward<units::turns> m_shooterFeedforward{
|
||||
frc::SimpleMotorFeedforward<units::radians> m_shooterFeedforward{
|
||||
ShooterConstants::kS, ShooterConstants::kV};
|
||||
frc::PIDController m_shooterFeedback{ShooterConstants::kP, 0.0, 0.0};
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ inline constexpr units::turns_per_second_t kShooterTolerance = 50_tps;
|
||||
inline constexpr double kP = 1.0;
|
||||
|
||||
inline constexpr units::volt_t kS = 0.05_V;
|
||||
inline constexpr kv_unit_t kV = (12_V) / kShooterFreeSpeed;
|
||||
inline constexpr kv_unit_t kV = 12_V / kShooterFreeSpeed;
|
||||
inline constexpr ka_unit_t kA = 0_V * 1_s * 1_s / 1_tr;
|
||||
|
||||
inline constexpr double kFeederSpeed = 0.5;
|
||||
|
||||
@@ -48,6 +48,6 @@ class Shooter : public frc2::SubsystemBase {
|
||||
},
|
||||
this}};
|
||||
frc::PIDController m_shooterFeedback{constants::shooter::kP, 0, 0};
|
||||
frc::SimpleMotorFeedforward<units::turns> m_shooterFeedforward{
|
||||
frc::SimpleMotorFeedforward<units::radians> m_shooterFeedforward{
|
||||
constants::shooter::kS, constants::shooter::kV, constants::shooter::kA};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user