Skip to content

Commit d88896c

Browse files
committed
feat: add an arm hardware method for getting pivot motor velocity
Signed-off-by: Dasun Abeykoon <[email protected]>
1 parent 1bf7773 commit d88896c

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmIO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public interface ArmIO extends AutoCloseable {
2525
@Logged(name = "Pivot Motor Setpoint Angle (Radians)")
2626
public double getSetpointAngleRads();
2727

28+
/**
29+
* @return pivot motor velocity in Radians/Second
30+
*/
31+
@Logged(name = "Pivot Motor Velocity (Radians Per Second)")
32+
public double getVelocityRadsPerSec();
33+
2834
/**
2935
* @return stator current of pivot motor in amps
3036
*/

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmIONone.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public double getSetpointAngleRads() {
2323
return 0.0;
2424
}
2525

26+
@Override
27+
public double getVelocityRadsPerSec() {
28+
return 0.0;
29+
}
30+
2631
@Override
2732
public double getStatorCurrentAmps() {
2833
return 0.0;

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmIOReal.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ArmIOReal implements ArmIO {
3535
private final VoltageOut voltReq = new VoltageOut(0.0).withEnableFOC(true);
3636
private final MotionMagicTorqueCurrentFOC poseReq = new MotionMagicTorqueCurrentFOC(0.0);
3737

38-
private final BaseStatusSignal poseSig, currentSig;
38+
private final BaseStatusSignal poseSig, velSig, currentSig;
3939

4040
public ArmIOReal() {
4141
conf.Audio.BeepOnBoot = true;
@@ -72,12 +72,13 @@ public ArmIOReal() {
7272
tryUntilOk(() -> motor.getConfigurator().apply(conf), 10, MOTOR_ID);
7373

7474
poseSig = motor.getPosition();
75+
velSig = motor.getVelocity();
7576
currentSig = motor.getStatorCurrent();
7677
}
7778

7879
@Override
7980
public void periodic() {
80-
BaseStatusSignal.refreshAll(poseSig, currentSig);
81+
BaseStatusSignal.refreshAll(poseSig, velSig, currentSig);
8182
}
8283

8384
@Override
@@ -90,6 +91,11 @@ public double getSetpointAngleRads() {
9091
return poseReq.getPositionMeasure().in(Radians);
9192
}
9293

94+
@Override
95+
public double getVelocityRadsPerSec() {
96+
return velSig.getValueAsDouble();
97+
}
98+
9399
@Override
94100
public double getStatorCurrentAmps() {
95101
return currentSig.getValueAsDouble();

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmIOSim.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public double getSetpointAngleRads() {
6464
return pivotFeedback.getSetpoint().position;
6565
}
6666

67+
@Override
68+
public double getVelocityRadsPerSec() {
69+
return pivotSim.getVelocityRadPerSec();
70+
}
71+
6772
@Override
6873
public double getStatorCurrentAmps() {
6974
return pivotSim.getCurrentDrawAmps();

0 commit comments

Comments
 (0)