Skip to content

Commit

Permalink
remove speedMultiplier from drive
Browse files Browse the repository at this point in the history
  • Loading branch information
AngleSideAngle committed Jan 20, 2024
1 parent e3dee2d commit ed5a511
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/sciborgs1155/lib/InputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ public static InputStream of(InputStream base) {
return base;
}

/**
* Shorthand to return a double value.
*
* @return The value from {@link #getAsDouble()}.
*/
public default double get() {
return getAsDouble();
}

/**
* Transforms the stream outputs by an operator.
*
Expand Down
24 changes: 3 additions & 21 deletions src/main/java/org/sciborgs1155/robot/drive/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.math.controller.ProfiledPIDController;
import edu.wpi.first.math.estimator.SwerveDrivePoseEstimator;
import edu.wpi.first.math.filter.SlewRateLimiter;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Transform2d;
Expand All @@ -33,7 +32,6 @@
import org.sciborgs1155.lib.InputStream;
import org.sciborgs1155.robot.Constants;
import org.sciborgs1155.robot.Robot;
import org.sciborgs1155.robot.drive.DriveConstants.Rotation;

public class Drive extends SubsystemBase implements Logged, AutoCloseable {

Expand All @@ -55,14 +53,6 @@ public class Drive extends SubsystemBase implements Logged, AutoCloseable {
@Log.NT private final Field2d field2d = new Field2d();
private final FieldObject2d[] modules2d;

// Rate limiting
private final SlewRateLimiter xLimiter =
new SlewRateLimiter(MAX_ACCEL.in(MetersPerSecondPerSecond));
private final SlewRateLimiter yLimiter =
new SlewRateLimiter(MAX_ACCEL.in(MetersPerSecondPerSecond));

@Log.NT private double speedMultiplier = 1;

// SysId
private final SysIdRoutine driveRoutine;
private final SysIdRoutine turnRoutine;
Expand Down Expand Up @@ -153,10 +143,7 @@ public void resetOdometry(Pose2d pose) {
* @return The driving command.
*/
public Command drive(InputStream vx, InputStream vy, InputStream vOmega) {
return run(
() ->
driveFieldRelative(
new ChassisSpeeds(vx.getAsDouble(), vy.getAsDouble(), vOmega.getAsDouble())));
return run(() -> driveFieldRelative(new ChassisSpeeds(vx.get(), vy.get(), vOmega.get())));
}

/**
Expand All @@ -181,8 +168,8 @@ public Command drive(InputStream vx, InputStream vy, Supplier<Rotation2d> headin
() ->
driveFieldRelative(
new ChassisSpeeds(
vx.getAsDouble(),
vy.getAsDouble(),
vx.get(),
vy.get(),
pid.calculate(getHeading().getRadians(), heading.get().getRadians()))));
}

Expand Down Expand Up @@ -295,11 +282,6 @@ public Command lock() {
return run(() -> setModuleStates(new SwerveModuleState[] {front, back, back, front}));
}

/** Sets a new speed multiplier for the robot, this affects max cartesian and angular speeds */
public Command setSpeedMultiplier(double multiplier) {
return runOnce(() -> speedMultiplier = multiplier);
}

/** Locks the drive motors. */
private Command lockDriveMotors() {
return Commands.run(() -> modules.forEach(m -> m.updateDriveSpeed(0)));
Expand Down

0 comments on commit ed5a511

Please sign in to comment.