mirror of
https://github.com/Team4388/2025-Programer-Training.git
synced 2026-06-09 00:38:03 -06:00
added 2024 shooter code
This commit is contained in:
@@ -133,6 +133,12 @@ public final class Constants {
|
|||||||
public static final int SMARTDASHBOARD_UPDATE_FRAME = 2;
|
public static final int SMARTDASHBOARD_UPDATE_FRAME = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class ShooterConstants {
|
||||||
|
public static final double SHOOTER_SPEED = .5;
|
||||||
|
public static final int LEFT_SHOOTER_ID = 15;
|
||||||
|
public static final int RIGHT_SHOOTER_ID = 16;
|
||||||
|
}
|
||||||
|
|
||||||
public static final class LEDConstants {
|
public static final class LEDConstants {
|
||||||
public static final int LED_SPARK_ID = 0;
|
public static final int LED_SPARK_ID = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import edu.wpi.first.wpilibj2.command.RunCommand;
|
|||||||
import frc4388.utility.controller.VirtualController;
|
import frc4388.utility.controller.VirtualController;
|
||||||
import frc4388.robot.commands.Swerve.neoJoystickPlayback;
|
import frc4388.robot.commands.Swerve.neoJoystickPlayback;
|
||||||
import frc4388.robot.commands.Swerve.neoJoystickRecorder;
|
import frc4388.robot.commands.Swerve.neoJoystickRecorder;
|
||||||
|
import frc4388.robot.subsystems.Shooter;
|
||||||
// Subsystems
|
// Subsystems
|
||||||
// import frc4388.robot.subsystems.LED;
|
// import frc4388.robot.subsystems.LED;
|
||||||
import frc4388.robot.subsystems.SwerveDrive;
|
import frc4388.robot.subsystems.SwerveDrive;
|
||||||
@@ -56,6 +56,8 @@ public class RobotContainer {
|
|||||||
|
|
||||||
m_robotMap.gyro);
|
m_robotMap.gyro);
|
||||||
|
|
||||||
|
public 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);
|
||||||
private final DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID);
|
private final DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID);
|
||||||
@@ -152,6 +154,10 @@ public class RobotContainer {
|
|||||||
|
|
||||||
// ? /* Operator Buttons */
|
// ? /* Operator Buttons */
|
||||||
|
|
||||||
|
DualJoystickButton(getDeadbandedOperatorController(), getVirtualOperatorController(), XboxController.LEFT_BUMPER_BUTTON)
|
||||||
|
.onTrue(new InstantCommand(() -> m_robotShooter.spin(), m_robotShooter))
|
||||||
|
.onFalse(new InstantCommand(() -> m_robotShooter.stop(), m_robotShooter));
|
||||||
|
|
||||||
// ? /* Programer Buttons (Controller 3)*/
|
// ? /* Programer Buttons (Controller 3)*/
|
||||||
|
|
||||||
// * /* Auto Recording */
|
// * /* Auto Recording */
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ 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;
|
||||||
|
import frc4388.robot.subsystems.Shooter;
|
||||||
import frc4388.robot.subsystems.SwerveModule;
|
import frc4388.robot.subsystems.SwerveModule;
|
||||||
import frc4388.utility.RobotGyro;
|
import frc4388.utility.RobotGyro;
|
||||||
|
|
||||||
@@ -55,6 +57,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);
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// 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 frc4388.robot.subsystems;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.hardware.TalonFX;
|
||||||
|
import com.ctre.phoenix6.signals.NeutralModeValue;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||||
|
import frc4388.robot.Constants.ShooterConstants;
|
||||||
|
import frc4388.robot.Constants;
|
||||||
|
|
||||||
|
public class Shooter extends SubsystemBase {
|
||||||
|
/** Creates a new Shooter. */
|
||||||
|
TalonFX leftShooter;
|
||||||
|
TalonFX rightShooter;
|
||||||
|
|
||||||
|
public Shooter(TalonFX leftShooter, TalonFX rightShooter) {
|
||||||
|
this.leftShooter = leftShooter;
|
||||||
|
this.rightShooter = rightShooter;
|
||||||
|
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
|
||||||
|
public void periodic() {
|
||||||
|
// This method will be called once per scheduler run
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user