88
99import static edu .wpi .first .units .Units .Kilograms ;
1010import static edu .wpi .first .units .Units .Meters ;
11- import static edu .wpi .first .units .Units .MetersPerSecond ;
11+ import static edu .wpi .first .units .Units .MetersPerSecondPerSecond ;
1212import static org .frc6423 .robot .subsystems .superstructure .elevator .Elevator .*;
1313
1414import edu .wpi .first .math .MathUtil ;
@@ -37,7 +37,7 @@ public class ElevatorIOSim implements ElevatorIO {
3737
3838 private final ElevatorFeedforward feedforward = new ElevatorFeedforward (0.0 , 0.1265 , 0.4 , 0.0 );
3939 private final ProfiledPIDController feedback =
40- new ProfiledPIDController (15.0 , 0.0 , 0.0 , new TrapezoidProfile .Constraints (0.0 , 0 .0 ));
40+ new ProfiledPIDController (15.0 , 0.0 , 0.0 , new TrapezoidProfile .Constraints (2.25 , 10 .0 ));
4141
4242 public ElevatorIOSim () {
4343 SmartDashboard .putData (feedback );
@@ -92,17 +92,14 @@ public void setVolts(double volts) {
9292 appliedVolts = MathUtil .clamp (volts , -12.0 , 12.0 );
9393 }
9494
95- @ Override
96- public void setPose (double poseMeters , double accelerationMpsSqrd ) {
95+ public void setPose (double poseMeters , double accelMpsSqrd ) {
9796 // Clamp pose in range
9897 poseMeters = MathUtil .clamp (poseMeters , 0.0 , MAX_EXTENSION_HEIGHT .in (Meters ));
9998 // Get current setpoint velocity
10099 var currentVel = feedback .getSetpoint ().velocity ;
101100
102101 // Give feedback controller new accel
103- feedback .setConstraints (
104- new TrapezoidProfile .Constraints (
105- MAX_VELOCITY .in (MetersPerSecond ) / 2 , accelerationMpsSqrd ));
102+ feedback .setConstraints (new TrapezoidProfile .Constraints (2.25 , accelMpsSqrd ));
106103 // Calculate next feedback setpoint
107104 var fbOut = feedback .calculate (getParentPoseMeters (), poseMeters );
108105 // Get next velocity
@@ -111,9 +108,15 @@ public void setPose(double poseMeters, double accelerationMpsSqrd) {
111108 // Calculate feedforward velocity output
112109 var ffOut = feedforward .calculateWithVelocities (currentVel , nextVel );
113110
111+ // Combine output
114112 setVolts (ffOut + fbOut );
115113 }
116114
115+ @ Override
116+ public void setPose (double poseMeters ) {
117+ setPose (poseMeters , MAX_ACCELERATION .in (MetersPerSecondPerSecond ));
118+ }
119+
117120 @ Override
118121 public void close () throws Exception {}
119122}
0 commit comments