@@ -28,18 +28,18 @@ public class Elevator extends SubsystemBase {
2828
2929 // amp bar gains
3030
31- private static double barkP ;
32- private static double barkV ;
33- private static double barkG ;
31+ private static final LoggedTunableNumber barkP = new LoggedTunableNumber ( "Bar/kP" ) ;
32+ private static final LoggedTunableNumber barkV = new LoggedTunableNumber ( "Bar/kV" ) ;
33+ private static final LoggedTunableNumber barkG = new LoggedTunableNumber ( "Bar/kG" ) ;
3434
3535 private TrapezoidProfile extenderProfile ;
3636 private TrapezoidProfile .Constraints extenderConstraints =
3737 new TrapezoidProfile .Constraints (30 , 85 );
3838 private TrapezoidProfile .State extenderGoal = new TrapezoidProfile .State ();
3939 private TrapezoidProfile .State extenderCurrent = new TrapezoidProfile .State ();
4040
41- private static double maxVelocityRPM ;
42- private static double maxAccelerationRPM ;
41+ private static double maxVelocityDegPerSec ;
42+ private static double maxAccelerationDegPerSecSquared ;
4343
4444 private TrapezoidProfile barProfile ;
4545 private TrapezoidProfile .Constraints barConstraints ;
@@ -66,9 +66,9 @@ public Elevator(ElevatorIO elevator, AmpBarIO ampBar) {
6666 kP .initDefault (0.44 );
6767 kI .initDefault (0 );
6868
69- barkP = 0.0 ;
70- barkV = 0.0 ;
71- barkG = 0.0 ;
69+ barkP . initDefault ( 0 ) ;
70+ barkV . initDefault ( 0 ) ;
71+ barkG . initDefault ( 0 ) ;
7272 break ;
7373 case REPLAY :
7474 kS .initDefault (0 );
@@ -79,9 +79,9 @@ public Elevator(ElevatorIO elevator, AmpBarIO ampBar) {
7979 kP .initDefault (15 );
8080 kI .initDefault (0 );
8181
82- barkP = 0.0 ;
83- barkV = 0.0 ;
84- barkG = 0.0 ;
82+ barkP . initDefault ( 0 ) ;
83+ barkV . initDefault ( 0 ) ;
84+ barkG . initDefault ( 0 ) ;
8585 break ;
8686 case SIM :
8787 kS .initDefault (0 );
@@ -92,9 +92,9 @@ public Elevator(ElevatorIO elevator, AmpBarIO ampBar) {
9292 kP .initDefault (1 );
9393 kI .initDefault (0 );
9494
95- barkP = 0.0 ;
96- barkV = 0.0 ;
97- barkG = 0.0 ;
95+ barkP . initDefault ( 0 ) ;
96+ barkV . initDefault ( 0 ) ;
97+ barkG . initDefault ( 0 ) ;
9898 break ;
9999 default :
100100 kS .initDefault (0 );
@@ -105,36 +105,37 @@ public Elevator(ElevatorIO elevator, AmpBarIO ampBar) {
105105 kP .initDefault (15 );
106106 kI .initDefault (0 );
107107
108- barkP = 0.0 ;
109- barkV = 0.0 ;
110- barkG = 0.0 ;
108+ barkP . initDefault ( 0 ) ;
109+ barkV . initDefault ( 0 ) ;
110+ barkG . initDefault ( 0 ) ;
111111 break ;
112112 }
113113
114114 setExtenderGoal (0.162 );
115115 extenderProfile = new TrapezoidProfile (extenderConstraints );
116116 extenderCurrent = extenderProfile .calculate (0 , extenderCurrent , extenderGoal );
117117
118- maxVelocityRPM = 15 ;
119- maxAccelerationRPM = 1 ;
118+ maxVelocityDegPerSec = 15 ;
119+ maxAccelerationDegPerSecSquared = 1 ;
120120
121- barConstraints = new TrapezoidProfile .Constraints (maxVelocityRPM , maxAccelerationRPM );
121+ barConstraints =
122+ new TrapezoidProfile .Constraints (maxVelocityDegPerSec , maxAccelerationDegPerSecSquared );
122123 barProfile = new TrapezoidProfile (barConstraints );
123124 barCurrent = barProfile .calculate (0 , barCurrent , barGoal );
124125
125126 this .elevator .configurePID (kP .get (), 0 , 0 );
126127 elevatorFFModel = new ElevatorFeedforward (kS .get (), kG .get (), kV .get (), kA .get ());
127128
128- ampBar .configurePID (barkP , 0 , 0 );
129- barFFmodel = new ArmFeedforward (0 , barkG , barkV , 0 );
129+ ampBar .configurePID (barkP . get () , 0 , 0 );
130+ barFFmodel = new ArmFeedforward (0 , barkG . get () , barkV . get () , 0 );
130131 }
131132
132133 public boolean atGoal () {
133134 return (Math .abs (eInputs .elevatorPosition - goal ) <= Constants .ElevatorConstants .THRESHOLD );
134135 }
135136
136137 public boolean barAtGoal () {
137- return (Math .abs (aInputs .barPositionRotations - barGoalPos )
138+ return (Math .abs (aInputs .barPositionDegrees - barGoalPos )
138139 <= Constants .ElevatorConstants .BAR_THRESHOLD );
139140 }
140141
@@ -148,7 +149,7 @@ private double getElevatorError() {
148149
149150 private double getBarError () {
150151
151- return aInputs .barPositionSetpointRotations - aInputs .barPositionRotations ;
152+ return aInputs .barPositionSetpointDegrees - aInputs .barPositionDegrees ;
152153 }
153154
154155 public boolean elevatorAtSetpoint () {
@@ -165,15 +166,16 @@ public void setBarBrakeMode(boolean bool) {
165166 }
166167
167168 public double getBarPositionRotations () {
168- return aInputs .barPositionRotations ;
169+ return aInputs .barPositionDegrees ;
169170 }
170171
171- public void setBarPosition (double positionRotations , double velocityRPM ) {
172+ public void setBarPosition (double positionRotations , double velocityDegsPerSec ) {
172173
173- positionRotations = MathUtil .clamp (positionRotations , - 1000 , 1000 );
174+ positionRotations = MathUtil .clamp (positionRotations , 0 , 20 );
174175 ampBar .setPositionSetpoint (
175176 positionRotations ,
176- barFFmodel .calculate (Math .toRadians (positionRotations ), Math .toRadians (velocityRPM )));
177+ barFFmodel .calculate (
178+ Math .toRadians (positionRotations ), Math .toRadians (velocityDegsPerSec )));
177179 }
178180
179181 public void stopAmpBar () {
0 commit comments