-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76e2316
commit 54710dc
Showing
3 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/org/team1540/robot2024/commands/drivetrain/KidModeSwerveDriveCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.team1540.robot2024.commands.drivetrain; | ||
|
||
import edu.wpi.first.math.MathUtil; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController; | ||
import org.team1540.robot2024.subsystems.drive.Drivetrain; | ||
import org.team1540.robot2024.util.LoggedTunableNumber; | ||
|
||
public class KidModeSwerveDriveCommand extends Command { | ||
private final Drivetrain drivetrain; | ||
private final CommandXboxController controller; | ||
private double maxSpeedPercentage; | ||
private double maxRotsPercentage; | ||
|
||
public KidModeSwerveDriveCommand(Drivetrain drivetrain, CommandXboxController controller){ | ||
this.drivetrain = drivetrain; | ||
this.controller = controller; | ||
} | ||
|
||
public void execute() { | ||
//TODO: check deadbands bc of diff controllers | ||
double xPercent = MathUtil.applyDeadband((-controller.getLeftY()), 0.1); | ||
double yPercent = MathUtil.applyDeadband((-controller.getLeftX()), 0.1); | ||
double rotPercent = MathUtil.applyDeadband((-controller.getRightX()), 0.1); | ||
|
||
LoggedTunableNumber kidModeSpeedPercent = new LoggedTunableNumber("kidMode/maxSpeedPercentage", 0.3); | ||
LoggedTunableNumber kidModeRotsPercent = new LoggedTunableNumber("kidMode/maxRotsPercentage", 0.5); | ||
|
||
drivetrain.drivePercent(xPercent * kidModeSpeedPercent.get(), yPercent * kidModeSpeedPercent.get(), rotPercent * kidModeRotsPercent.get(), true); | ||
} | ||
|
||
|
||
} |