Skip to content

Commit

Permalink
Automatically applied spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinskycastle authored and github-actions[bot] committed Jan 18, 2025
1 parent db078a0 commit 8144a55
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 59 deletions.
63 changes: 33 additions & 30 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@

import com.ctre.phoenix6.SignalLogger;
import com.ctre.phoenix6.swerve.SwerveRequest;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.path.PathPlannerPath;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
Expand All @@ -29,8 +24,8 @@
import frc.robot.commands.SwerveCharacterization;
import frc.robot.constants.ROBOT;
import frc.robot.constants.SWERVE;
import frc.robot.constants.USB;
import frc.robot.constants.SWERVE.ROUTINE_TYPE;
import frc.robot.constants.USB;
import frc.robot.generated.TunerConstants;
import frc.robot.subsystems.AlgaeIntake;
import frc.robot.subsystems.CommandSwerveDrivetrain;
Expand Down Expand Up @@ -102,9 +97,9 @@ private void initializeSubSystems() {

private void initAutoChooser() {
SmartDashboard.putData("Auto Chooser", m_chooser);

m_chooser.addOption("Do Nothing", new WaitCommand(0));

m_chooser.addOption("DriveForward", new DriveForward(m_swerveDrive));
}

Expand All @@ -113,48 +108,56 @@ private void initSmartDashboard() {
else initAutoChooser();
SmartDashboard.putData("ResetGyro", new ResetGyro(m_swerveDrive));
}
private void initSysidChooser(){

private void initSysidChooser() {
SignalLogger.setPath("/media/sda1/");

SysIdUtils.createSwerveDriveRoutines(m_swerveDrive);
SysIdUtils.createSwerveTurnRoutines(m_swerveDrive);

SmartDashboard.putData(
"Start Logging", new InstantCommand(SignalLogger::start).ignoringDisable(true));
"Start Logging", new InstantCommand(SignalLogger::start).ignoringDisable(true));
SmartDashboard.putData(
"Stop Logging", new InstantCommand(SignalLogger::stop).ignoringDisable(true));
"Stop Logging", new InstantCommand(SignalLogger::stop).ignoringDisable(true));
SmartDashboard.putData(
"initDriveSettings",
"initDriveSettings",
new InstantCommand(m_swerveDrive::initDriveSysid).ignoringDisable(true));

m_sysidChooser.addOption(
"driveQuasistaticForward",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.DRIVE_QUASISTATIC));
"driveQuasistaticForward",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.DRIVE_QUASISTATIC));
m_sysidChooser.addOption(
"driveQuasistaticBackwards",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.DRIVE_QUASISTATIC));
"driveQuasistaticBackwards",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.DRIVE_QUASISTATIC));
m_sysidChooser.addOption(
"driveDynamicForward",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.DRIVE_DYNAMIC));
"driveDynamicForward",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.DRIVE_DYNAMIC));
m_sysidChooser.addOption(
"driveDynamicBackward",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.DRIVE_DYNAMIC));
"driveDynamicBackward",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.DRIVE_DYNAMIC));

m_sysidChooser.addOption(
"turnQuasistaticForward",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.TURN_QUASISTATIC));
"turnQuasistaticForward",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.TURN_QUASISTATIC));
m_sysidChooser.addOption(
"turnQuasistaticBackwards",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.TURN_QUASISTATIC));
"turnQuasistaticBackwards",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.TURN_QUASISTATIC));
m_sysidChooser.addOption(
"turnDynamicForward",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.TURN_DYNAMIC));
"turnDynamicForward",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kForward, ROUTINE_TYPE.TURN_DYNAMIC));
m_sysidChooser.addOption(
"turnDynamicBackward",
new SwerveCharacterization(m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.TURN_DYNAMIC));
"turnDynamicBackward",
new SwerveCharacterization(
m_swerveDrive, SysIdRoutine.Direction.kReverse, ROUTINE_TYPE.TURN_DYNAMIC));
}

}
/**
* Use this method to define your trigger->command mappings. Triggers can be created via the
* {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/frc/robot/commands/DriveForward.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ public class DriveForward extends SequentialCommandGroup {
/** Creates a new DriveForward. */
public DriveForward(CommandSwerveDrivetrain swerveDrive) {
try {
PathPlannerPath path = PathPlannerPath.fromPathFile("DriveForward");
PathPlannerPath path = PathPlannerPath.fromPathFile("DriveForward");

var m_ppCommand = AutoBuilder.followPath(path);
var point = new SwerveRequest.PointWheelsAt();
var stopRequest = new SwerveRequest.ApplyRobotSpeeds();
// Will throw an exception if the starting pose is not present
var starting_pose = path.getStartingHolonomicPose().orElseThrow();
// Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand());
addCommands(
new InstantCommand( // Reset the pose of the robot to the starting pose of the path
() -> swerveDrive.resetPose(starting_pose)),
new InstantCommand(
() -> swerveDrive.applyRequest(() -> point.withModuleDirection(new Rotation2d())),
swerveDrive)
.alongWith(new WaitCommand(1)),
m_ppCommand.andThen(() -> swerveDrive.setControl(stopRequest)));
var m_ppCommand = AutoBuilder.followPath(path);

var point = new SwerveRequest.PointWheelsAt();
var stopRequest = new SwerveRequest.ApplyRobotSpeeds();

// Will throw an exception if the starting pose is not present
var starting_pose = path.getStartingHolonomicPose().orElseThrow();

// Add your commands in the addCommands() call, e.g.
// addCommands(new FooCommand(), new BarCommand());
addCommands(
new InstantCommand( // Reset the pose of the robot to the starting pose of the path
() -> swerveDrive.resetPose(starting_pose)),
new InstantCommand(
() -> swerveDrive.applyRequest(() -> point.withModuleDirection(new Rotation2d())),
swerveDrive)
.alongWith(new WaitCommand(1)),
m_ppCommand.andThen(() -> swerveDrive.setControl(stopRequest)));
} catch (Exception e) {
DriverStation.reportError("Failed to load path for DriveForward", e.getStackTrace());
addCommands(new WaitCommand(0));
DriverStation.reportError("Failed to load path for DriveForward", e.getStackTrace());
addCommands(new WaitCommand(0));
}
}
}
}
15 changes: 8 additions & 7 deletions src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Subsystem;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.robot.generated.TunerConstants;
import frc.robot.generated.TunerConstants.TunerSwerveDrivetrain;
import frc.robot.utils.CtreUtils;
import frc.robot.utils.ModuleMap;

import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -143,14 +141,17 @@ public void initDriveSysid() {
var driveMotor = getModule(i.ordinal()).getDriveMotor();
var turnMotor = getModule(i.ordinal()).getSteerMotor();
CtreUtils.configureTalonFx(driveMotor, new TalonFXConfiguration());
CtreUtils.configureTalonFx(turnMotor, new TalonFXConfiguration() /* was previously CtreUtils.generateTurnMotorConfig() TODO: get that method working again*/);
CtreUtils.configureTalonFx(
turnMotor,
new TalonFXConfiguration() /* was previously CtreUtils.generateTurnMotorConfig() TODO: get that method working again*/);
driveMotor.setNeutralMode(NeutralModeValue.Brake);
BaseStatusSignal.setUpdateFrequencyForAll(
250, driveMotor.getPosition(), driveMotor.getVelocity(), driveMotor.getMotorVoltage());

driveMotor.optimizeBusUtilization();
}
}
}

/**
* Constructs a CTRE SwerveDrivetrain using the specified constants.
*
Expand Down Expand Up @@ -207,9 +208,9 @@ public CommandSwerveDrivetrain(
}

// TODO: Re-implement
// public Command applyChassisSpeeds(Supplier<ChassisSpeeds> chassisSpeeds) {
// return applyChassisSpeeds(chassisSpeeds, 0.02, 1.0, false);
// }
// public Command applyChassisSpeeds(Supplier<ChassisSpeeds> chassisSpeeds) {
// return applyChassisSpeeds(chassisSpeeds, 0.02, 1.0, false);
// }

/**
* Second-Order Kinematics <a
Expand Down

0 comments on commit 8144a55

Please sign in to comment.