-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added climb with two motors Has a manual control break mode peak gaming --------- Co-authored-by: Joseph Eng <[email protected]>
- Loading branch information
1 parent
0c1210c
commit 25f0be9
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.ctre.phoenix6.configs.CurrentLimitsConfigs; | ||
import com.ctre.phoenix6.configs.MotorOutputConfigs; | ||
import com.ctre.phoenix6.controls.Follower; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Hardware; | ||
|
||
public class ClimbPivot extends SubsystemBase { | ||
|
||
private final TalonFX climbPivotMotorOne; | ||
private final TalonFX climbPivotMotorTwo; | ||
private final DigitalInput climbSensor; | ||
|
||
public ClimbPivot() { | ||
climbPivotMotorOne = new TalonFX(Hardware.CLIMB_PIVOT_MOTOR_ONE_ID); | ||
climbPivotMotorTwo = new TalonFX(Hardware.CLIMB_PIVOT_MOTOR_TWO_ID); | ||
climbSensor = new DigitalInput(Hardware.CLIMB_SENSOR); | ||
configureMotors(); | ||
} | ||
|
||
private void configureMotors() { | ||
var talonFXConfigurator = climbPivotMotorOne.getConfigurator(); | ||
var talonFXConfigurator2 = climbPivotMotorTwo.getConfigurator(); | ||
// Set and enable current limit | ||
var currentLimits = new CurrentLimitsConfigs(); | ||
currentLimits.StatorCurrentLimit = 5; | ||
currentLimits.StatorCurrentLimitEnable = true; | ||
currentLimits.SupplyCurrentLimit = 5; | ||
currentLimits.SupplyCurrentLimitEnable = true; | ||
talonFXConfigurator.apply(currentLimits); | ||
talonFXConfigurator2.apply(currentLimits); | ||
|
||
var talonFXMotorOutput = new MotorOutputConfigs(); | ||
// Enable brake mode | ||
talonFXMotorOutput.NeutralMode = NeutralModeValue.Brake; | ||
talonFXConfigurator.apply(talonFXMotorOutput); | ||
talonFXConfigurator2.apply(talonFXMotorOutput); | ||
// OpposeMasterDirection can be changed based on climb design, not yet sure if 2nd motor will be | ||
// on opposite side | ||
climbPivotMotorTwo.setControl(new Follower(climbPivotMotorOne.getDeviceID(), true)); | ||
} | ||
|
||
public Command moveClimbMotor(double speed) { | ||
return run(() -> { | ||
climbPivotMotorOne.set(speed); | ||
}) | ||
.finallyDo( | ||
() -> { | ||
climbPivotMotorOne.stopMotor(); | ||
}); | ||
} | ||
|
||
public boolean checkClimbSensor() { | ||
return climbSensor.get(); | ||
} | ||
} |