Skip to content

Commit 0b50a99

Browse files
finished GroundIntakePivoteReal
1 parent 632a77b commit 0b50a99

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/main/java/frc/robot/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ public enum Mode {
7575
public static final int ARM_INTAKE_ID = 18;
7676
public static final int ARM_ENCODER_ID = 24;
7777

78+
// Intake
7879
public static final int GROUND_INTAKE_PIVOT_ID = 21;
7980
}

src/main/java/frc/robot/subsystems/arm/ArmIOReal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ArmIOReal implements ArmIO {
1919
TalonFX pivotMotor;
2020
TalonFXConfiguration pivotMotorConfig;
2121

22-
PositionVoltage pivotPositionControl = new PositionVoltage(0);
22+
private PositionVoltage pivotPositionControl = new PositionVoltage(0);
2323

2424
// Intake/Outtake motors & configurations
2525
TalonFX intakeMotor;

src/main/java/frc/robot/subsystems/groundintake/GroundIntakePivotIO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
public interface GroundIntakePivotIO {
99

10+
final double MOTOR_TO_GROUND_INTAKE_PIVOT = 66.0 / 14.0; // 14.0 / 66.0;
11+
1012
@AutoLog
1113
class GroundIntakePivotIOInputs {
1214
public double groundIntakePivotAngleDegrees;

src/main/java/frc/robot/subsystems/groundintake/GroundIntakePivotIOReal.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.ctre.phoenix6.configs.TalonFXConfiguration;
44
import com.ctre.phoenix6.controls.PositionVoltage;
55
import com.ctre.phoenix6.hardware.TalonFX;
6-
76
import edu.wpi.first.units.measure.Angle;
7+
import edu.wpi.first.units.measure.Voltage;
88
import frc.robot.Constants;
99

1010
public class GroundIntakePivotIOReal implements GroundIntakePivotIO {
@@ -16,31 +16,37 @@ public class GroundIntakePivotIOReal implements GroundIntakePivotIO {
1616

1717
public GroundIntakePivotIOReal() {
1818

19-
groundIntakePivotMotor = new TalonFX(Constants.GROUNDINTAKEPIVOTE_ID);
19+
groundIntakePivotMotor = new TalonFX(Constants.GROUND_INTAKE_PIVOT_ID);
2020
}
2121

2222
@Override
23-
public void updateState(GroundIntakePivotIOInputs inputs){
24-
23+
public void updateState(GroundIntakePivotIOInputs inputs) {
24+
inputs.groundIntakePivotAngleDegrees = 0.0;
25+
26+
inputs.pivotMotorRotations = groundIntakePivotMotor.getPosition().getValueAsDouble();
27+
inputs.pivotMotorVelocityRotsPerSecond =
28+
groundIntakePivotMotor.getVelocity().getValueAsDouble();
29+
inputs.pivotMotorCurrent = groundIntakePivotMotor.getStatorCurrent().getValueAsDouble();
30+
inputs.pivotMotorVoltage = groundIntakePivotMotor.getMotorVoltage().getValueAsDouble();
2531
}
2632

2733
@Override
2834
public void setPivotMotorSetpoint(Angle setpoint) {
29-
35+
groundIntakePivotMotor.setControl(positionVoltage.withPosition(setpoint));
3036
}
3137

3238
@Override
33-
public void setPivotMotorVoltage(double voltage) {
34-
39+
public void setPivotMotorVoltage(Voltage voltage) {
40+
groundIntakePivotMotor.setVoltage(voltage.magnitude());
3541
}
3642

3743
@Override
3844
public Angle getPivotMotorPosition() {
39-
45+
return groundIntakePivotMotor.getPosition().getValue();
4046
}
4147

4248
@Override
4349
public Angle getGroundIntakePivotPosition() {
44-
50+
return groundIntakePivotMotor.getPosition().getValue().div(MOTOR_TO_GROUND_INTAKE_PIVOT);
4551
}
4652
}

0 commit comments

Comments
 (0)