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

Commit f2828fa

Browse files
Made drivetrain turn and not angry
Co-Authored-By: Evan Grinnell <155865196+S0L0GUY@users.noreply.github.com>
1 parent 4f3bf24 commit f2828fa

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88

99
import edu.wpi.first.wpilibj2.command.Command;
1010
import edu.wpi.first.wpilibj2.command.Commands;
11+
import frc.robot.commands.Drive;
12+
import frc.robot.subsystems.Drivetrain;
1113

1214
public class RobotContainer {
1315
private final SN_XboxController m_driverController = new SN_XboxController(RobotMap.mapControllers.DRIVER_USB);
1416

17+
Drivetrain subDrivetrain = new Drivetrain();
18+
1519
public RobotContainer() {
20+
subDrivetrain.setDefaultCommand(new Drive(subDrivetrain, m_driverController.axis_LeftY, m_driverController.axis_RightX));
1621
configureBindings();
1722
}
1823

19-
private void configureBindings() {
20-
Drive(m_driverController.axis_LeftY, m_driverController.axis_RightX);
21-
}
24+
private void configureBindings() {}
2225

2326
public Command getAutonomousCommand() {
2427
return Commands.print("No autonomous command configured");
2528
}
2629
}
27-
28-
// .whileTrue(new SpinMotor(MyMotorMoverName,
29-
// m_driverController.axis_RightTrigger, m_driverController.axis_LeftTrigger));

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public class Drive extends Command {
1313
/** Creates a new Drive. */
1414

1515
Drivetrain globalDrivetrain;
16-
DoubleSupplier forwardSpeed;
17-
DoubleSupplier rotationSpeed;
16+
DoubleSupplier globalForwardSpeed;
17+
DoubleSupplier globalRotationSpeed;
1818

19-
public Drive(Drivetrain passedDrivetrain) {
19+
public Drive(Drivetrain passedDrivetrain, DoubleSupplier passedForwardSpeed, DoubleSupplier passedRotationSpeed) {
2020
// Use addRequirements() here to declare subsystem dependencies.
2121
globalDrivetrain = passedDrivetrain;
22+
globalForwardSpeed = passedForwardSpeed;
23+
globalRotationSpeed = passedForwardSpeed;
2224
}
2325

2426
// Called when the command is initially scheduled.
@@ -28,8 +30,8 @@ public void initialize() {}
2830
// Called every time the scheduler runs while the command is scheduled.
2931
@Override
3032
public void execute() {
31-
globalDrivetrain.setLeftSpeed(forwardSpeed.getAsDouble());
32-
globalDrivetrain.setRightSpeed(forwardSpeed.getAsDouble());
33+
globalDrivetrain.setLeftSpeed(globalForwardSpeed.getAsDouble() + globalRotationSpeed.getAsDouble());
34+
globalDrivetrain.setRightSpeed(globalForwardSpeed.getAsDouble() - globalRotationSpeed.getAsDouble());
3335
}
3436

3537
// Called once the command ends or is interrupted.

0 commit comments

Comments
 (0)