-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from ddjoshua01/main
Vortex Swerve
- Loading branch information
Showing
11 changed files
with
229 additions
and
13 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/frc/robot/commands/ExtendClimberCommand.java
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,43 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.XboxController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.ClimberSubsystem; | ||
|
||
|
||
import com.revrobotics.RelativeEncoder; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.ClimberSubsystem; | ||
|
||
public class ExtendClimberCommand extends Command { | ||
private final ClimberSubsystem climberSubsystem; | ||
|
||
private RelativeEncoder leftEncoder; | ||
|
||
// private RelativeEncoder rightEncoder; | ||
|
||
double leftEncoderPos; | ||
// double rightEncoderPos; | ||
|
||
public ExtendClimberCommand(ClimberSubsystem climberSubsystem) { | ||
this.climberSubsystem = climberSubsystem; | ||
this.leftEncoder = climberSubsystem.getLeftEncoder(); | ||
// this.rightEncoder = climberSubsystem.getRightEncoder(); | ||
addRequirements(climberSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
|
||
leftEncoderPos = leftEncoder.getPosition(); | ||
// rightEncoderPos = rightEncoder.getPosition(); | ||
|
||
if (leftEncoderPos > 3.0) { | ||
climberSubsystem.hold(); | ||
} else { | ||
climberSubsystem.extend(); | ||
} | ||
|
||
} | ||
|
||
} |
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
36 changes: 36 additions & 0 deletions
36
src/main/java/frc/robot/commands/RetractClimberCommand.java
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,36 @@ | ||
package frc.robot.commands; | ||
|
||
import com.revrobotics.RelativeEncoder; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.ClimberSubsystem; | ||
|
||
public class RetractClimberCommand extends Command { | ||
private final ClimberSubsystem climberSubsystem; | ||
|
||
private final RelativeEncoder leftEncoder; | ||
|
||
// private RelativeEncoder rightEncoder; | ||
|
||
|
||
public RetractClimberCommand(ClimberSubsystem climberSubsystem) { | ||
this.climberSubsystem = climberSubsystem; | ||
this.leftEncoder = climberSubsystem.getLeftEncoder(); | ||
// this.rightEncoder = climberSubsystem.getRightEncoder(); | ||
addRequirements(climberSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
double leftEncoderPos = leftEncoder.getPosition(); | ||
// double rightEncoderPos = rightEncoder.getPosition(); | ||
|
||
climberSubsystem.retract(); | ||
|
||
if (leftEncoderPos < 1.0) { | ||
climberSubsystem.hold(); | ||
} else { | ||
climberSubsystem.retract(); | ||
} | ||
|
||
} | ||
} |
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,26 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.SwerveSubsystem; | ||
|
||
public class TranslateCommand extends Command { | ||
|
||
private final SwerveSubsystem swerveSubsystem; | ||
private final double metersPerSecond; | ||
|
||
public TranslateCommand(SwerveSubsystem swerveSubsystem, double metersPerSecond) { | ||
this.swerveSubsystem = swerveSubsystem; | ||
this.metersPerSecond = metersPerSecond; | ||
} | ||
|
||
|
||
@Override | ||
|
||
public void execute() { | ||
swerveSubsystem.drive(metersPerSecond, 0.0, 0.0, false, true); | ||
} | ||
|
||
public double getMetersPerSecond() { | ||
return metersPerSecond; | ||
} | ||
} |
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,6 @@ | ||
package frc.robot.constants; | ||
|
||
public class ClimberConstants { | ||
public static final int leftSideID = 13; | ||
public static final int rightSideID = 16; | ||
} |
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,49 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkBase; | ||
import com.revrobotics.CANSparkLowLevel; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.constants.ClimberConstants; | ||
import frc.robot.subsystems.SwerveSubsystem; | ||
import frc.robot.constants.DrivetrainConstants; | ||
import frc.robot.commands.DriveCommands; | ||
|
||
|
||
public class ClimberSubsystem extends SubsystemBase { | ||
private final CANSparkMax leftSide = new CANSparkMax(ClimberConstants.leftSideID, CANSparkLowLevel.MotorType.kBrushless); | ||
// private CANSparkMax rightSide = new CANSparkMax(ClimberConstants.leftSideID, CANSparkLowLevel.MotorType.kBrushless); | ||
private final RelativeEncoder leftSideEncoder = leftSide.getEncoder(); | ||
// private final RelativeEncoder rightSideEncoder = rightSide.getEncoder(); | ||
|
||
public RelativeEncoder getLeftEncoder() { | ||
return leftSideEncoder; | ||
} | ||
|
||
// public RelativeEncoder getRightEncoder() { | ||
// return rightSideEncoder; | ||
// } | ||
|
||
public void extend() { | ||
//rightSide.set(0.1); | ||
leftSide.set(0.1); | ||
} | ||
|
||
public void retract() { | ||
//rightSide.set(-0.1); | ||
leftSide.set(-0.1); | ||
} | ||
|
||
|
||
/** | ||
* Put the brakes on the climber motors. | ||
*/ | ||
public void hold() { | ||
leftSide.set(0.0); | ||
//rightSide.set(0.0); | ||
leftSide.setIdleMode(CANSparkBase.IdleMode.kBrake); | ||
//rightSide.setIdleMode(CANSparkBase.IdleMode.kBrake); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -16,4 +16,4 @@ public void periodic() { | |
public void setLED(double value) { | ||
BlinkinDriver.set(value); | ||
} | ||
} | ||
} |
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