-
Notifications
You must be signed in to change notification settings - Fork 0
Drive base command impl #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TaeSeanDo
wants to merge
34
commits into
Command-Based
Choose a base branch
from
Drive-Base-Command-Impl
base: Command-Based
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
ca5d5b1
Use tank drive in RobotContainer
TaeSeanDo 4525ba9
Add and use DriveBase.drive() for simplicity
TaeSeanDo ffc3616
Update Gamepad.java
TaeSeanDo 58171b6
Add overloaded drive(double) method to DriveBase
TaeSeanDo 3d1ac94
Add shifter state machine for switchGears()
TaeSeanDo d44df34
Add Tank Drive Command
TaeSeanDo 5eff87c
Add Shifter Command
TaeSeanDo 2c74093
Use Tank Drive and Shifter Commands
TaeSeanDo 68a3ee6
Format BallChucker and Harvester
TaeSeanDo e441c1d
Use DoubleSuppliers in TankDrive for versatility
TaeSeanDo 6fda952
Rename DriveBase.switchGears() to changeShifterState
TaeSeanDo af3848b
Make ToggleShifter a subclass of InstantsCommand
TaeSeanDo 65c2612
Suppress the SuppressWarnings
TaeSeanDo 308b370
Switch gamepad for xbox controller
TaeSeanDo a82f664
Rename ChangeShifter to ToggleShifter
TaeSeanDo 8ef3f46
Delete unecessary import
TaeSeanDo ffaf1c9
Rename drive motor port constants.
TaeSeanDo d5a8438
Reduce dunder count by one
TaeSeanDo 7669918
Make Javadocs for useHighGear and getShifterState
TaeSeanDo 35c27a1
Add javadocs for DriveBase methods
TaeSeanDo 6a75ab6
Make changes based on real life robot
TaeSeanDo 68624cb
Fixed bug
TaeSeanDo e711bd4
Drive base with correct motor controllers
TaeSeanDo 9f73753
Formatting
TaeSeanDo b8eb126
Reorganize drivebase constructor parameters
TaeSeanDo aaf8a76
Add UseHighGear Command
TaeSeanDo d1cbb1b
Invert joysticks
TaeSeanDo f88ab5f
Use differential drive
TaeSeanDo 9fdcea2
Change naming convention to BlahCommand
TaeSeanDo 3b06234
Bring the gamepad back!
TaeSeanDo 6ebbca5
Rename to SetHighGearCommand
TaeSeanDo 4762818
No need for toggle code in subsystems
TaeSeanDo fe7586c
Suppress the SuppressWarnings
TaeSeanDo a8ba49a
Rename constants to ...CAN_ID
TaeSeanDo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,51 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import frc.robot.subsystems.DriveBase; | ||
|
||
import java.util.function.BooleanSupplier; | ||
import java.util.function.DoubleSupplier; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
|
||
public class ArcadeDriveCommand extends CommandBase { | ||
private final DriveBase driveBase; | ||
private final DoubleSupplier leftPowerSupplier; | ||
private final DoubleSupplier rightPowerSupplier; | ||
private final BooleanSupplier squareInputs; | ||
|
||
public ArcadeDriveCommand(DriveBase driveBase, DoubleSupplier leftPowerSupplier, DoubleSupplier rightPowerSupplier, | ||
BooleanSupplier squareInputs) { | ||
this.driveBase = driveBase; | ||
this.leftPowerSupplier = leftPowerSupplier; | ||
this.rightPowerSupplier = rightPowerSupplier; | ||
this.squareInputs = squareInputs; | ||
addRequirements(driveBase); | ||
} | ||
|
||
public ArcadeDriveCommand(DriveBase driveBase, DoubleSupplier leftPowerSupplier, | ||
DoubleSupplier rightPowerSupplier) { | ||
this(driveBase, leftPowerSupplier, rightPowerSupplier, () -> false); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
driveBase.arcadeDrive(leftPowerSupplier.getAsDouble(), rightPowerSupplier.getAsDouble(), squareInputs.getAsBoolean()); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
driveBase.stopMotor(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/frc/robot/commands/CurvatureDriveCommand.java
This file contains hidden or 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,51 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import frc.robot.subsystems.DriveBase; | ||
|
||
import java.util.function.BooleanSupplier; | ||
import java.util.function.DoubleSupplier; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
|
||
public class CurvatureDriveCommand extends CommandBase { | ||
private final DriveBase driveBase; | ||
private final DoubleSupplier leftPowerSupplier; | ||
private final DoubleSupplier rightPowerSupplier; | ||
private final BooleanSupplier squareInputs; | ||
|
||
public CurvatureDriveCommand(DriveBase driveBase, DoubleSupplier leftPowerSupplier, | ||
DoubleSupplier rightPowerSupplier, BooleanSupplier squareInputs) { | ||
this.driveBase = driveBase; | ||
this.leftPowerSupplier = leftPowerSupplier; | ||
this.rightPowerSupplier = rightPowerSupplier; | ||
this.squareInputs = squareInputs; | ||
addRequirements(driveBase); | ||
} | ||
|
||
public CurvatureDriveCommand(DriveBase driveBase, DoubleSupplier leftPowerSupplier, | ||
DoubleSupplier rightPowerSupplier) { | ||
this(driveBase, leftPowerSupplier, rightPowerSupplier, () -> false); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
driveBase.curvatureDrive(leftPowerSupplier.getAsDouble(), rightPowerSupplier.getAsDouble(), squareInputs.getAsBoolean()); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
driveBase.stopMotor(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,22 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import frc.robot.subsystems.DriveBase; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
public class SetHighGearCommand extends InstantCommand { | ||
public SetHighGearCommand(DriveBase driveBase, boolean highGear) { | ||
super(() -> driveBase.setHighGear(highGear), driveBase); | ||
} | ||
|
||
public SetHighGearCommand(DriveBase driveBase) { | ||
this(driveBase, true); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.