-
Notifications
You must be signed in to change notification settings - Fork 1
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
6953095
commit e1b86b2
Showing
6 changed files
with
117 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.drive.DriveBase; | ||
import java.util.function.DoubleSupplier; | ||
|
||
public class DriveBaseCommand extends Command { | ||
DriveBase drive; | ||
DoubleSupplier speed; | ||
DoubleSupplier rot; | ||
|
||
public DriveBaseCommand(DriveBase drive, DoubleSupplier speed, DoubleSupplier rot) { | ||
this.drive = drive; | ||
this.speed = speed; | ||
this.rot = rot; | ||
|
||
addRequirements(drive); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
ChassisSpeeds speeds = | ||
new ChassisSpeeds( | ||
speed.getAsDouble() * drive.getMaxLinearSpeed(), | ||
0, | ||
rot.getAsDouble() * drive.getMaxAngularSpeed()); | ||
|
||
drive.runVelocity(speeds); | ||
} | ||
} |
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,21 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
|
||
public interface Drive { | ||
public void runVelocity(ChassisSpeeds speeds); | ||
|
||
public double getMaxLinearSpeed(); | ||
|
||
public double getMaxAngularSpeed(); | ||
|
||
/* | ||
public void stop(); | ||
public Pose2d getPose(); | ||
public void setPose(Pose2d Pose2d); | ||
public Rotation2d getRotation(); | ||
*/ | ||
} |
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,19 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class DriveBase extends SubsystemBase implements Drive { | ||
public DriveBase() {} | ||
|
||
public void runVelocity(ChassisSpeeds speeds) {} | ||
; | ||
|
||
public double getMaxLinearSpeed() { | ||
return 0; | ||
} | ||
|
||
public double getMaxAngularSpeed() { | ||
return 0; | ||
} | ||
} |
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,10 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
|
||
public class DriveSwerve extends DriveBase { | ||
@Override | ||
public void runVelocity(ChassisSpeeds speeds) { | ||
/* Swerve Controls Here */ | ||
} | ||
} |
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,10 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
|
||
public class DriveTank extends DriveBase { | ||
@Override | ||
public void runVelocity(ChassisSpeeds speeds) { | ||
/* Tank Controls Here */ | ||
} | ||
} |