-
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
98a1eab
commit 482ebcd
Showing
4 changed files
with
36 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
public class RobotContainer { | ||
private final int number; | ||
private final Drive drive; | ||
public RobotContainer(){ | ||
switch (Constants.currentMode) { | ||
case REAL: | ||
number = 5; | ||
drive = new Drive(new DriveIORomi()); | ||
break; | ||
case SIM: | ||
number 20; | ||
drive = new Drive(new DriveIO(){}); | ||
break; | ||
default: | ||
number = 10; | ||
drive = new Drive(new DriveIO(){}); | ||
break; | ||
} | ||
drive.setDefaultCommand(drive.drive()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,36 @@ | ||
public class Drive extends SubsystemBase { | ||
|
||
public Drive{ | ||
|
||
} | ||
private final DriveIOInputsAutoLogged inputs = new DriveIOInputsAutoLogged(); | ||
private final DriveIO io; | ||
|
||
|
||
public Drive(DriveIO io){ | ||
this.io = io; | ||
} | ||
private tankDrive(double lateral, double rotational) { | ||
double l_Speed = lateral + rotational; | ||
double r_Speed = lateral - rotational; | ||
if (Math.abs(l_Speed) > 1) { | ||
r_Speed = r_Speed/l_Speed * Math.sign(l_Speed); | ||
l_Speed = 1; | ||
} | ||
if (Math.abs(r_Speed) > 1) { | ||
l_Speed = l_Speed/r_Speed * Math.sign(r_Speed); | ||
r_Speed = 1; | ||
} | ||
io.setLeftVoltage(5*l_Speed); | ||
io.setRightVoltage(5*r_Speed); | ||
} | ||
public Command drive(DoubleSupplier lateralSupplier, DoubleSupplier rotationalSupplier) { | ||
Commands.run(() -> { | ||
tankDrive(lateralSupplier.get(), rotationalSupplier.get()); | ||
}, this); | ||
} | ||
|
||
|
||
@Override | ||
public void periodic() { | ||
|
||
} | ||
|
||
} |
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