-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'shooterprototypetest' into main
- Loading branch information
Showing
5 changed files
with
135 additions
and
37 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,39 @@ | ||
// 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 frc.robot.commands; | ||
|
||
import frc.robot.subsystems.ShooterSubsystem; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
/** An example command that uses an example subsystem. */ | ||
public class TossCommand extends Command { | ||
private final ShooterSubsystem s_shooter; | ||
private boolean finish; | ||
|
||
public TossCommand() { | ||
s_shooter = ShooterSubsystem.getInstance(); | ||
addRequirements(s_shooter); | ||
finish = false; | ||
} | ||
|
||
@Override | ||
public void initialize() {} | ||
|
||
@Override | ||
public void execute() { | ||
s_shooter.setVoltage(10); | ||
finish = true; | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
s_shooter.setVoltage(0); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return finish; | ||
} | ||
} |
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,54 @@ | ||
// 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 frc.robot.subsystems; | ||
|
||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
import com.ctre.phoenix6.controls.StrictFollower; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
|
||
public class ShooterSubsystem extends SubsystemBase { | ||
|
||
private static ShooterSubsystem instance; | ||
public static ShooterSubsystem getInstance() { | ||
if (instance == null) | ||
instance = new ShooterSubsystem(); | ||
return instance; | ||
} | ||
|
||
private TalonFX shooterLeaderM; | ||
private TalonFX shooterFollowerM; | ||
|
||
private double voltage; | ||
|
||
public ShooterSubsystem() { | ||
shooterLeaderM = new TalonFX(Constants.HardwarePorts.shooterLeaderM); | ||
shooterFollowerM = new TalonFX(Constants.HardwarePorts.shooterFollowerM); | ||
shooterFollowerM.setInverted(true); | ||
shooterFollowerM.setControl(new StrictFollower(Constants.HardwarePorts.shooterLeaderM)); | ||
} | ||
|
||
|
||
public void setVoltage(double voltage) { | ||
this.voltage = voltage; | ||
shooterLeaderM.setVoltage(voltage); | ||
} | ||
|
||
public double getVoltageSetpoint() { | ||
return voltage; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
SmartDashboard.putNumber("Motor Voltage Setpoint", getVoltageSetpoint()); | ||
} | ||
|
||
@Override | ||
public void simulationPeriodic() { | ||
// This method will be called once per scheduler run during simulation | ||
} | ||
} |