Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
430e667
added constants commands and subsystem class
ShmayaR Dec 30, 2024
4ffd554
added code to subsystem constants and command
ShmayaR Dec 30, 2024
86e083b
Update RobotContainer.java
ShmayaR Dec 30, 2024
232ad10
Update RobotContainer.java
ShmayaR Dec 30, 2024
a4b05aa
Update ShooterConstants.java
ShmayaR Dec 30, 2024
0772e04
renamed variables in enum to match
ShmayaR Dec 30, 2024
86b5917
Update ShooterConstants.java
ShmayaR Dec 30, 2024
7b6a0e5
Update ShooterConstants.java
ShmayaR Dec 30, 2024
8339018
renamed setTargetPercentageVoltageOutput to SetMotorOutput
ShmayaR Dec 30, 2024
853f167
Update ShooterConstants.java
ShmayaR Dec 30, 2024
36def3f
added function to subsystem for setting a state for the shooter
ShmayaR Dec 30, 2024
a32ac41
changed command form instant command to a start end command
ShmayaR Dec 30, 2024
d8e2605
Update Shooter.java
ShmayaR Dec 31, 2024
0e72872
Update ShooterConstants.java
ShmayaR Dec 31, 2024
e5be1c2
removed INHALE_GAME_PIECE state
ShmayaR Dec 31, 2024
5baaacb
changed name of setShooterState to shooterStateVoltagePercentage
ShmayaR Dec 31, 2024
d8220a8
Update ShooterCommands.java
ShmayaR Dec 31, 2024
fde22d2
Merge branch 'main' into shooter
ShmayaR Dec 31, 2024
37900ed
Update Shooter.java
ShmayaR Dec 31, 2024
cdf7fcd
switched all the targetMotorOutputPercentage to targetVoltagePercentage
ShmayaR Dec 31, 2024
9037e62
Update RobotContainer.java
ShmayaR Dec 31, 2024
f8d1e26
Update Shooter.java
ShmayaR Dec 31, 2024
2450b98
Update Shooter.java
ShmayaR Dec 31, 2024
69c361b
Update Shooter.java
ShmayaR Dec 31, 2024
3b3b4a6
Update Robot.java
ShmayaR Dec 31, 2024
83e27f0
Update RobotContainer.java
ShmayaR Dec 31, 2024
ecdcd49
Update Robot.java
ShmayaR Dec 31, 2024
aa000ef
Update ShooterConstants.java
ShmayaR Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import frc.robot.subsystems.Shooter.Shooter;


public class RobotContainer {

public class RobotContainer
{
public RobotContainer()
{
public static final Shooter SHOOTER = new Shooter();

public RobotContainer() {
configureBindings();
}

private void configureBindings() {
}



private void configureBindings() {}


public Command getAutonomousCommand()
{
public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");
}
}
28 changes: 28 additions & 0 deletions src/main/java/frc/robot/subsystems/Shooter/Shooter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package frc.robot.subsystems.Shooter;


import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class Shooter extends SubsystemBase {
private final WPI_TalonSRX rightMotor = ShooterConstants.RIGHT_MOTOR;
private final WPI_TalonSRX leftMotor = ShooterConstants.LEFT_MOTOR;
private ShooterConstants.ShooterState currentState;

void stopMotors() {
setMotorOutput(0);
}

void setTargetState(ShooterConstants.ShooterState targetState) {
setMotorOutput(targetState.setShooterState);
currentState = targetState;
}

void setMotorOutput(double percentageMotorOutput) {
rightMotor.set(ControlMode.PercentOutput, percentageMotorOutput);
leftMotor.set(ControlMode.PercentOutput, percentageMotorOutput);
}
}


23 changes: 23 additions & 0 deletions src/main/java/frc/robot/subsystems/Shooter/ShooterCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package frc.robot.subsystems.Shooter;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.StartEndCommand;
import frc.robot.RobotContainer;

public class ShooterCommands {
public static Command getSetTargetStateCommand(ShooterConstants.ShooterState targetState) {
return new InstantCommand(
() -> RobotContainer.SHOOTER.setTargetState(targetState)
);
}

private static Command getSetMotorOutputCommand(double motorOutput) {
return new StartEndCommand(
() -> RobotContainer.SHOOTER.setMotorOutput(motorOutput),
RobotContainer.SHOOTER::stopMotors,
RobotContainer.SHOOTER
);
}
}

58 changes: 58 additions & 0 deletions src/main/java/frc/robot/subsystems/Shooter/ShooterConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package frc.robot.subsystems.Shooter;

import com.ctre.phoenix.motorcontrol.InvertType;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;

public class ShooterConstants {
private static final int
RIGHT_MOTOR_ID = 3,
LEFT_MOTOR_ID = 4;

static final WPI_TalonSRX
RIGHT_MOTOR = new WPI_TalonSRX(RIGHT_MOTOR_ID),
LEFT_MOTOR = new WPI_TalonSRX(LEFT_MOTOR_ID);

private static final InvertType RIGHT_MOTOR_INVERTED_VALUE = InvertType.None;
private static final InvertType LEFT_MOTOR_INVERTED_VALUE = InvertType.InvertMotorOutput;
private static final NeutralMode NEUTRAL_MODE = NeutralMode.Coast;
private static final double VOLTAGE_COMPENSATION_SATURATION = 12;

static {
configureRightMotor();
configureLeftMotor();
}

private static final void configureRightMotor() {
RIGHT_MOTOR.configFactoryDefault();

RIGHT_MOTOR.setInverted(RIGHT_MOTOR_INVERTED_VALUE);
RIGHT_MOTOR.setNeutralMode(NEUTRAL_MODE);

RIGHT_MOTOR.enableVoltageCompensation(true);
RIGHT_MOTOR.configVoltageCompSaturation(VOLTAGE_COMPENSATION_SATURATION);
}

private static final void configureLeftMotor() {
LEFT_MOTOR.configFactoryDefault();

LEFT_MOTOR.setInverted(LEFT_MOTOR_INVERTED_VALUE);
LEFT_MOTOR.setNeutralMode(NEUTRAL_MODE);

LEFT_MOTOR.enableVoltageCompensation(true);
LEFT_MOTOR.configVoltageCompSaturation(VOLTAGE_COMPENSATION_SATURATION);
}

public enum ShooterState {
SHOOT(1),
EJECT(0.3),
COLLECT(-0.3),
STOP(0);

final double setShooterState;

ShooterState(double setShooterState) {
this.setShooterState = setShooterState;
}
}
}
Loading