Files
2023WayOfTheRobot/src/main/java/frc4388/robot/subsystems/Arm.java
T

61 lines
1.7 KiB
Java
Raw Normal View History

2023-01-20 18:06:53 -07:00
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc4388.robot.subsystems;
2023-02-04 14:27:40 -07:00
import com.ctre.phoenix.motorcontrol.LimitSwitchNormal;
import com.ctre.phoenix.motorcontrol.LimitSwitchSource;
2023-01-20 18:06:53 -07:00
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
2023-02-04 14:27:40 -07:00
import frc4388.robot.Constants;
2023-01-20 18:06:53 -07:00
public class Arm extends SubsystemBase {
/** Creates a new Arm. */
private WPI_TalonFX pivot;
private WPI_TalonFX tele;
2023-02-04 14:27:40 -07:00
2023-01-20 18:06:53 -07:00
public Arm(WPI_TalonFX pivot, WPI_TalonFX tele) {
this.pivot = pivot;
this.tele = tele;
2023-02-04 14:27:40 -07:00
//Limit switches
pivot.configForwardLimitSwitchSource(LimitSwitchSource.FeedbackConnector, LimitSwitchNormal.NormallyOpen);
pivot.configReverseLimitSwitchSource(LimitSwitchSource.FeedbackConnector, LimitSwitchNormal.NormallyOpen);
tele.configReverseLimitSwitchSource(LimitSwitchSource.FeedbackConnector, LimitSwitchNormal.NormallyOpen);
tele.configForwardSoftLimitThreshold(Constants.ArmConstants.TELE_FORWARD_SOFT_LIMIT);
2023-01-20 18:06:53 -07:00
}
public void runPivot(double output) {
pivot.set(output);
}
2023-01-21 13:22:37 -07:00
public void runTele(double output) {
2023-01-20 18:06:53 -07:00
tele.set(output);
}
2023-01-21 13:22:37 -07:00
public void runPivotAndTele(double pOutput, double tOutput) {
pivot.set(pOutput);
tele.set(tOutput);
}
public double getPivotPos() {
return pivot.getSelectedSensorPosition();
}
public double getTelePos() {
return tele.getSelectedSensorPosition();
}
2023-01-20 18:06:53 -07:00
@Override
public void periodic() {
2023-02-04 14:27:40 -07:00
if (tele.isRevLimitSwitchClosed() == 1) {
tele.setSelectedSensorPosition(0);
}
2023-01-20 18:06:53 -07:00
}
}