patch: include swerve angles and write shooter subsystem.

This commit is contained in:
C4llSiqn
2024-12-03 09:33:11 -07:00
parent 025d14c128
commit 7226f79a1c
4 changed files with 32 additions and 6 deletions
+4 -4
View File
@@ -41,10 +41,10 @@ public final class Constants {
public static final double TURBO_SPEED = 1.0; public static final double TURBO_SPEED = 1.0;
public static final class DefaultSwerveRotOffsets { public static final class DefaultSwerveRotOffsets {
public static final double FRONT_LEFT_ROT_OFFSET = 0.0; //TODO: per robot swerve module offsets. public static final double FRONT_LEFT_ROT_OFFSET = 0.36962890625 + 0.5; //TODO: per robot swerve module offsets.
public static final double FRONT_RIGHT_ROT_OFFSET = 0.0; //TODO: per robot swerve module offsets. public static final double FRONT_RIGHT_ROT_OFFSET = 0.61474609375 + 0.5; //TODO: per robot swerve module offsets.
public static final double BACK_LEFT_ROT_OFFSET = 0.0; //TODO: per robot swerve module offsets. public static final double BACK_LEFT_ROT_OFFSET = -0.227294921875 + 0.5; //TODO: per robot swerve module offsets.
public static final double BACK_RIGHT_ROT_OFFSET = 0.0; //TODO: per robot swerve module offsets. public static final double BACK_RIGHT_ROT_OFFSET = 0.60595703125 + 0.5; //TODO: per robot swerve module offsets.
} }
public static final class IDs { public static final class IDs {
@@ -56,7 +56,7 @@ public class RobotContainer {
m_robotMap.gyro); m_robotMap.gyro);
private final Shooter m_robotshooter = new Shooter(m_robotMap.leftShooter, m_robotMap.rightShooter); private final Shooter m_robotShooter = new Shooter(m_robotMap.leftShooter, m_robotMap.rightShooter);
/* Controllers */ /* Controllers */
private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID); private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID);
@@ -154,6 +154,10 @@ public class RobotContainer {
// ? /* Operator Buttons */ // ? /* Operator Buttons */
DualJoystickButton(getDeadbandedOperatorController(), getVirtualOperatorController(), XboxController.LEFT_BUMPER_BUTTON)
.onTrue(new InstantCommand(() -> m_robotShooter.spin()))
.onFalse(new InstantCommand(() -> m_robotShooter.stop()));
// ? /* Programer Buttons (Controller 3)*/ // ? /* Programer Buttons (Controller 3)*/
// * /* Auto Recording */ // * /* Auto Recording */
@@ -11,6 +11,7 @@ import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.hardware.CANcoder; import com.ctre.phoenix6.hardware.CANcoder;
import com.ctre.phoenix6.hardware.Pigeon2; import com.ctre.phoenix6.hardware.Pigeon2;
import frc4388.robot.Constants.ShooterConstants;
// import edu.wpi.first.wpilibj.motorcontrol.Spark; // import edu.wpi.first.wpilibj.motorcontrol.Spark;
// import frc4388.robot.Constants.LEDConstants; // import frc4388.robot.Constants.LEDConstants;
import frc4388.robot.Constants.SwerveDriveConstants; import frc4388.robot.Constants.SwerveDriveConstants;
@@ -55,6 +56,10 @@ public class RobotMap {
public final TalonFX rightBackSteer = new TalonFX(SwerveDriveConstants.IDs.RIGHT_BACK_STEER_ID); public final TalonFX rightBackSteer = new TalonFX(SwerveDriveConstants.IDs.RIGHT_BACK_STEER_ID);
public final CANcoder rightBackEncoder = new CANcoder(SwerveDriveConstants.IDs.RIGHT_BACK_ENCODER_ID); public final CANcoder rightBackEncoder = new CANcoder(SwerveDriveConstants.IDs.RIGHT_BACK_ENCODER_ID);
/* Shooter Subsystem */
public final TalonFX leftShooter = new TalonFX(ShooterConstants.LEFT_SHOOTER_ID);
public final TalonFX rightShooter = new TalonFX(ShooterConstants.RIGHT_SHOOTER_ID);
void configureDriveMotorControllers() { void configureDriveMotorControllers() {
// initialize SwerveModules // initialize SwerveModules
this.rightFront = new SwerveModule(rightFrontWheel, rightFrontSteer, rightFrontEncoder, SwerveDriveConstants.DefaultSwerveRotOffsets.FRONT_RIGHT_ROT_OFFSET); this.rightFront = new SwerveModule(rightFrontWheel, rightFrontSteer, rightFrontEncoder, SwerveDriveConstants.DefaultSwerveRotOffsets.FRONT_RIGHT_ROT_OFFSET);
@@ -5,8 +5,10 @@
package frc4388.robot.subsystems; package frc4388.robot.subsystems;
import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.NeutralModeValue;
import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.robot.Constants.ShooterConstants;
public class Shooter extends SubsystemBase { public class Shooter extends SubsystemBase {
private final TalonFX leftShooter; private final TalonFX leftShooter;
@@ -15,8 +17,23 @@ public class Shooter extends SubsystemBase {
public Shooter(TalonFX leftShooterMotor, TalonFX rightShooterMotor) { public Shooter(TalonFX leftShooterMotor, TalonFX rightShooterMotor) {
leftShooter = leftShooterMotor; leftShooter = leftShooterMotor;
rightShooter = rightShooterMotor; rightShooter = rightShooterMotor;
leftShooter.setNeutralMode(NeutralModeValue.Coast);
rightShooter.setNeutralMode(NeutralModeValue.Coast);
} }
public void spin(double speed) {
leftShooter.set(-speed);
rightShooter.set(-speed);
}
public void spin() {
spin(ShooterConstants.SHOOTER_SPEED);
}
public void stop() {
spin(0);
}
@Override @Override
public void periodic() { public void periodic() {