Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 5aea604

Browse files
authored
Merge pull request #182 from AusTINCANsProgrammingTeam/DriverTesting2
Prepare for monday driver testing
2 parents 7f3682e + 2544872 commit 5aea604

10 files changed

Lines changed: 62 additions & 58 deletions

File tree

src/main/java/frc/robot/Constants.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public AimModes previous() {
2727
},
2828
EJECT(2500.0, 0.0),
2929
LAUNCH(0.0, 0.0),
30-
TARMAC(2600.0, 0.0),
30+
TARMAC(2550.0, 0.0),
3131
TEST {
3232
@Override
3333
public AimModes next() {
@@ -105,7 +105,8 @@ public AimModes previous() {
105105
public static final int driveRightFrontIndex = 2;
106106
public static final int driveRightRearIndex = 3;
107107

108-
public static final int driveBaseCurrentLimit = 60;
108+
public static final int driveBaseCurrentLimit = 50;
109+
public static final double driveBaseTurnRate = 0.85;
109110

110111
// drive base pid values
111112
// TODO: need to tune for real robot

src/main/java/frc/robot/Robot.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package frc.robot;
66

7+
import edu.wpi.first.cameraserver.CameraServer;
8+
import edu.wpi.first.cscore.UsbCamera;
79
import edu.wpi.first.wpilibj.TimedRobot;
810
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
911
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
@@ -21,6 +23,7 @@ public class Robot extends TimedRobot {
2123
private SendableChooser<Constants.Auton> chooser = new SendableChooser<>();
2224
private RobotContainer robotContainer;
2325
private TabContainer tabContainer;
26+
public UsbCamera usbCamera;
2427

2528
// This function is run when the robot is first started up and should be used
2629
// for any
@@ -32,6 +35,9 @@ public void robotInit() {
3235
// autonomous chooser on the dashboard.
3336
// TODO: Put commands here
3437

38+
usbCamera = CameraServer.startAutomaticCapture();
39+
usbCamera.setResolution(320, 240);
40+
3541
robotContainer = new RobotContainer();
3642

3743
chooser.setDefaultOption("Taxi", Constants.Auton.TAXI); // default is taxi mode

src/main/java/frc/robot/RobotContainer.java

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
1111
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
1212
import edu.wpi.first.wpilibj2.command.Command;
13-
import edu.wpi.first.wpilibj2.command.InstantCommand;
1413
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
1514
import frc.robot.commands.AutonModes;
1615
import frc.robot.commands.CDSBallManagementCommand;
@@ -135,10 +134,8 @@ private void initSubsystems() {
135134

136135
limelightSubsystem = new LimelightSubsystem();
137136

138-
if (axisCount1 > 0 && buttonCount1 > 0) {
139-
climbSubsystem = new ClimbSubsystem(operatorJoystick);
140-
climbCommand = new ClimbCommand(climbSubsystem);
141-
}
137+
climbSubsystem = new ClimbSubsystem(operatorJoystick);
138+
climbCommand = new ClimbCommand(climbSubsystem);
142139
}
143140

144141
private void initCommands() {
@@ -160,7 +157,8 @@ private void initCommands() {
160157
ballManagementCommand = new CDSBallManagementCommand(cdsSubsystem, intakeSubsystem);
161158
cdsSubsystem.setDefaultCommand(ballManagementCommand);
162159
} else {
163-
combinedIntakeCDS = new CombinedIntakeCDSForwardCommand(intakeSubsystem, cdsSubsystem);
160+
combinedIntakeCDS =
161+
new CombinedIntakeCDSForwardCommand(intakeSubsystem, cdsSubsystem, shooterSubsystem);
164162
}
165163
}
166164

@@ -221,38 +219,13 @@ private void configureButtonBindings() {
221219
shooterSubsystem));
222220
}
223221

224-
if (axisCount1 == 0 && buttonCount1 == 0) {
225-
226-
// Shooter
227-
if (shooterSubsystem != null && shooterHeldAuto != null) {
228-
buttons[Constants.backButton].whenPressed(shooterHeldAuto);
229-
buttons[Constants.LJoystickButton].whenPressed(
230-
new InstantCommand(shooterSubsystem::cycleAimModeNext, shooterSubsystem));
231-
buttons[Constants.RJoystickButton].whenPressed(
232-
new InstantCommand(shooterSubsystem::cycleAimModePrevious, shooterSubsystem));
233-
}
234-
235-
// Limelight
236-
if (limelightAlign != null) {
237-
buttons[Constants.startButton].whenPressed(limelightAlign);
238-
}
239-
240-
// ClimbSubysystem has no binding because there are not enuf axises
241-
if (climbSubsystem != null) {}
242-
243-
System.out.printf("Using Testing One-controller button mappings");
244-
} else {
245-
246-
if (climbSubsystem != null) {
247-
buttons2[Constants.startButton].whenPressed(ClimbEnabling);
248-
}
249-
250-
if (outtakeCommand != null && intakeForwardCommand != null) {
251-
buttons2[Constants.RTriggerButton].whileHeld(intakeForwardCommand);
252-
buttons2[Constants.RBumper].whileHeld(outtakeCommand);
253-
}
222+
if (climbSubsystem != null) {
223+
buttons2[Constants.startButton].whenPressed(ClimbEnabling);
224+
}
254225

255-
System.out.printf("Using Competition Two-controller button mappings");
226+
if (outtakeCommand != null && intakeForwardCommand != null) {
227+
buttons2[Constants.RTriggerButton].whileHeld(intakeForwardCommand);
228+
buttons2[Constants.RBumper].whileHeld(outtakeCommand);
256229
}
257230
}
258231

src/main/java/frc/robot/commands/AutonModes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private void initializeCommandGroups() {
188188
new ParallelDeadlineGroup(
189189
twoBallRamseteCommands[0].andThen(
190190
() -> driveBaseSubsystem.stopDriveMotors()), // travel to get ball
191-
new CombinedIntakeCDSForwardCommand(intakeSubsystem, cdsSubsystem));
191+
new CombinedIntakeCDSForwardCommand(intakeSubsystem, cdsSubsystem, shooterSubsystem));
192192

193193
twoBallCommand =
194194
new SequentialCommandGroup(
@@ -203,7 +203,7 @@ private void initializeCommandGroups() {
203203
new ParallelDeadlineGroup(
204204
threeBallRamseteCommands[0].andThen(
205205
() -> driveBaseSubsystem.stopDriveMotors()), // travel to get the two balls
206-
new CombinedIntakeCDSForwardCommand(intakeSubsystem, cdsSubsystem));
206+
new CombinedIntakeCDSForwardCommand(intakeSubsystem, cdsSubsystem, shooterSubsystem));
207207

208208
threeBallCommand =
209209
new SequentialCommandGroup(

src/main/java/frc/robot/commands/CDSForwardCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public CDSForwardCommand(CDSSubsystem CDSSubsystem, ShooterSubsystem shooterSubs
2828
public void initialize() {
2929
mCDSSubsystem.CDSWheelToggle(false);
3030
mCDSSubsystem.CDSBeltToggle(false);
31-
mShooterSubsystem.runCargo(Constants.stopperWheelSpeed);
31+
mShooterSubsystem.runCargo(Constants.Shooter.cargoReverse);
3232
}
3333

3434
// Called every time the scheduler runs while the command is scheduled.

src/main/java/frc/robot/commands/ClimbEnable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public void initialize() {
2828
m_subsystem.resetTargetedHeight();
2929

3030
if (m_subsystem.getclimbingenable() == true) {
31-
m_drivesubsystem.setArcadedrivespeed(40);
31+
m_drivesubsystem.setDriveBaseSpeed(0.40);
3232
} else {
33-
m_drivesubsystem.setArcadedrivespeed(100);
33+
m_drivesubsystem.setDriveBaseSpeed(1);
3434
}
3535
}
3636

src/main/java/frc/robot/commands/CombinedIntakeCDSForwardCommand.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@
55
package frc.robot.commands;
66

77
import edu.wpi.first.wpilibj2.command.CommandBase;
8+
import frc.robot.Constants;
89
import frc.robot.subsystems.CDSSubsystem;
910
import frc.robot.subsystems.IntakeSubsystem;
11+
import frc.robot.subsystems.ShooterSubsystem;
1012

1113
public class CombinedIntakeCDSForwardCommand extends CommandBase {
1214
/** Creates a new OuttakeCommand. */
1315
private final CDSSubsystem CDSSubsystem;
1416

17+
private final ShooterSubsystem shooterSubsystem;
18+
1519
private final IntakeSubsystem intakeSubsystem;
1620

1721
public CombinedIntakeCDSForwardCommand(
18-
IntakeSubsystem mIntakeSubsystem, CDSSubsystem mCDSSubsystem) {
22+
IntakeSubsystem mIntakeSubsystem,
23+
CDSSubsystem mCDSSubsystem,
24+
ShooterSubsystem mShooterSubsystem) {
1925
// Use addRequirements() here to declare subsystem dependencies.
26+
addRequirements(mShooterSubsystem);
2027
addRequirements(mIntakeSubsystem);
2128
addRequirements(mCDSSubsystem);
2229
intakeSubsystem = mIntakeSubsystem;
2330
CDSSubsystem = mCDSSubsystem;
31+
shooterSubsystem = mShooterSubsystem;
2432
}
2533

2634
// Called when the command is initially scheduled.
@@ -29,6 +37,7 @@ public void initialize() {
2937
CDSSubsystem.CDSBeltToggle(false);
3038
CDSSubsystem.CDSWheelToggle(false);
3139
intakeSubsystem.toggleIntake(false);
40+
shooterSubsystem.runCargo(Constants.Shooter.cargoReverse);
3241
}
3342

3443
// Called every time the scheduler runs while the command is scheduled.
@@ -40,6 +49,7 @@ public void execute() {}
4049
public void end(boolean interrupted) {
4150
CDSSubsystem.stopCDS();
4251
intakeSubsystem.stopIntake();
52+
shooterSubsystem.runCargo(0.0);
4353
}
4454

4555
// Returns true when the command should end.

src/main/java/frc/robot/common/hardware/MotorController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public MotorController(String name, int deviceID) {
2626
// Create default values for Spark Max motor controller
2727
setSmartCurrentLimit(Constants.defaultCurrentLimit); // default current limit is 40A
2828
setIdleMode(CANSparkMax.IdleMode.kCoast); // default mode is Coast
29-
setOpenLoopRampRate(Constants.openLoopRampRate); // default open loop rate
3029

3130
mPIDController = getPIDController();
3231
mEncoder = getEncoder();

src/main/java/frc/robot/subsystems/ClimbSubsystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
1313
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
1414
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
15-
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1615
import edu.wpi.first.wpilibj2.command.SubsystemBase;
1716
import frc.robot.Constants;
1817
import frc.robot.common.hardware.MotorController;
@@ -224,7 +223,7 @@ public void enableClimb() {
224223
}
225224

226225
public void periodic() {
227-
226+
/*
228227
SmartDashboard.putNumber(
229228
"Climb motor 1 Applied Output", m_climbMotorControllerOne.getAppliedOutput());
230229
SmartDashboard.putNumber(
@@ -271,6 +270,7 @@ public void periodic() {
271270
m_climbMotorControllerOne.getPIDCtrl().setI(sbClimbOneI.getDouble(0));
272271
m_climbMotorControllerOne.getPIDCtrl().setD(sbClimbOneD.getDouble(0));
273272
}
273+
*/
274274
}
275275

276276
public boolean getLimitSwitchVal() {

src/main/java/frc/robot/subsystems/DriveBaseSubsystem.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import edu.wpi.first.math.kinematics.DifferentialDriveOdometry;
1414
import edu.wpi.first.math.system.plant.DCMotor;
1515
import edu.wpi.first.math.util.Units;
16-
import edu.wpi.first.networktables.NetworkTableEntry;
1716
import edu.wpi.first.wpilibj.ADIS16448_IMU;
1817
import edu.wpi.first.wpilibj.AnalogGyro;
1918
import edu.wpi.first.wpilibj.Encoder;
@@ -34,10 +33,8 @@
3433
import frc.robot.common.hardware.MotorController;
3534

3635
public class DriveBaseSubsystem extends SubsystemBase {
36+
private double driveBaseSpeed;
3737
private ShuffleboardTab driverTab = Shuffleboard.getTab("Driver Teleop tab");
38-
private NetworkTableEntry teleopSpeed =
39-
driverTab.add("Speed percentage", 100).withPosition(0, 1).getEntry();
40-
4138
private final Joystick m_driverJoystick;
4239
private final MotorController[] m_motorControllers;
4340
private final DifferentialDrive m_differentialDrive;
@@ -64,7 +61,7 @@ public class DriveBaseSubsystem extends SubsystemBase {
6461
private boolean isReverse = false;
6562

6663
public DriveBaseSubsystem(Joystick joystick, boolean usingExternal) {
67-
64+
driveBaseSpeed = 1;
6865
m_driverJoystick = joystick;
6966

7067
m_motorControllers = new MotorController[4];
@@ -106,6 +103,24 @@ public DriveBaseSubsystem(Joystick joystick, boolean usingExternal) {
106103
m_motorControllers[Constants.driveLeftFrontIndex].setInverted(true);
107104
m_motorControllers[Constants.driveLeftRearIndex].setInverted(true);
108105

106+
m_motorControllers[Constants.driveLeftRearIndex].setOpenLoopRampRate(
107+
Constants.openLoopRampRate);
108+
m_motorControllers[Constants.driveLeftFrontIndex].setOpenLoopRampRate(
109+
Constants.openLoopRampRate);
110+
m_motorControllers[Constants.driveRightRearIndex].setOpenLoopRampRate(
111+
Constants.openLoopRampRate);
112+
m_motorControllers[Constants.driveRightFrontIndex].setOpenLoopRampRate(
113+
Constants.openLoopRampRate);
114+
115+
m_motorControllers[Constants.driveLeftRearIndex].setSmartCurrentLimit(
116+
Constants.driveBaseCurrentLimit);
117+
m_motorControllers[Constants.driveLeftFrontIndex].setSmartCurrentLimit(
118+
Constants.driveBaseCurrentLimit);
119+
m_motorControllers[Constants.driveRightRearIndex].setSmartCurrentLimit(
120+
Constants.driveBaseCurrentLimit);
121+
m_motorControllers[Constants.driveRightFrontIndex].setSmartCurrentLimit(
122+
Constants.driveBaseCurrentLimit);
123+
109124
// Forces rear motors of each side to follow the first
110125
m_motorControllers[Constants.driveLeftRearIndex].follow(
111126
m_motorControllers[Constants.driveLeftFrontIndex]);
@@ -217,24 +232,24 @@ public void periodic() {
217232

218233
}
219234

220-
public void setArcadedrivespeed(double input) {
221-
teleopSpeed.setDouble(input);
235+
public void setDriveBaseSpeed(double driveBaseSpeed) {
236+
this.driveBaseSpeed = driveBaseSpeed;
222237
}
223238

224239
// Normal Arcade Drive
225240
public void arcadeDrive() {
226241
// Note: -0.85 to accomodate comfort of driver (sensitivity)
227242
m_differentialDrive.arcadeDrive(
228-
m_driverJoystick.getRawAxis(Constants.leftJoystickY) * -(teleopSpeed.getDouble(100) / 100),
229-
m_driverJoystick.getRawAxis(Constants.rightJoystickX),
243+
m_driverJoystick.getRawAxis(Constants.leftJoystickY) * -driveBaseSpeed,
244+
m_driverJoystick.getRawAxis(Constants.rightJoystickX) * Constants.driveBaseTurnRate,
230245
true);
231246
// joystick has y-axis flipped so up is negative why down is positive
232247
}
233248

234249
// Arcade Drive where you can only move forwards and backwards for testing
235250
public void arcadeDrive(double rotation) {
236251
m_differentialDrive.arcadeDrive(
237-
-0.85 * m_driverJoystick.getRawAxis(Constants.leftJoystickY), rotation);
252+
m_driverJoystick.getRawAxis(Constants.leftJoystickY) * -driveBaseSpeed, rotation);
238253
}
239254

240255
// TODO: Make a command to switch modes (extra)

0 commit comments

Comments
 (0)