Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
[auto] Refactor the way the Auto interface is used and add docs (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty authored Jul 19, 2024
1 parent 1e646d3 commit be24647
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

package frc.robot;
package com.choreo.lib;

import edu.wpi.first.wpilibj2.command.Command;

public interface Auto {
/** A function to setup Triggers for the Auto routine. */
public void configureBindings();

/**
* The Command to follow the trajectory, should be your autonomous command.
*
* <p>Should call the {@link configureBindings} method.
*
* @return The trajectory following command.
*/
public Command followTrajectory();
}
9 changes: 2 additions & 7 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package frc.robot;

import com.choreo.lib.Auto;
import com.ctre.phoenix6.SignalLogger;
import com.ctre.phoenix6.mechanisms.swerve.SwerveModule.DriveRequestType;
import com.ctre.phoenix6.mechanisms.swerve.SwerveRequest;
Expand Down Expand Up @@ -117,7 +118,7 @@ public void disabledExit() {}
@Override
public void autonomousInit() {
m_drivetrain.getOrchestra().stop();
m_autonomousCommand = getAutonomousCommand();
m_autonomousCommand = m_chooser.getSelected().followTrajectory();

if (m_autonomousCommand != null) {
m_autonomousCommand.schedule();
Expand Down Expand Up @@ -155,10 +156,4 @@ public void testPeriodic() {}

@Override
public void testExit() {}

private Command getAutonomousCommand() {
Auto auto = m_chooser.getSelected();
auto.configureBindings();
return auto.followTrajectory();
}
}
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/autos/Centre2541.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package frc.robot.autos;

import com.choreo.lib.Auto;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Auto;
import frc.robot.subsystems.CommandSwerveDrivetrain;

public class Centre2541 implements Auto {
Expand All @@ -20,6 +20,7 @@ public void configureBindings() {}

@Override
public Command followTrajectory() {
configureBindings();
return m_followerCommand;
}
}
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/autos/Centre26541.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package frc.robot.autos;

import com.choreo.lib.Auto;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Auto;
import frc.robot.subsystems.CommandSwerveDrivetrain;

public class Centre26541 implements Auto {
Expand All @@ -20,6 +20,7 @@ public void configureBindings() {}

@Override
public Command followTrajectory() {
configureBindings();
return m_follower;
}
}
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/autos/Flex.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package frc.robot.autos;

import com.choreo.lib.Auto;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Auto;
import frc.robot.subsystems.CommandSwerveDrivetrain;

public class Flex implements Auto {
Expand All @@ -20,6 +20,7 @@ public void configureBindings() {}

@Override
public Command followTrajectory() {
configureBindings();
return m_follower;
}
}
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/autos/OneNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

package frc.robot.autos;

import com.choreo.lib.Auto;
import com.choreo.lib.Choreo;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import frc.robot.Auto;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.Shooter;

Expand All @@ -22,6 +22,7 @@ public OneNote(Shooter shooter, Intake intake) {

@Override
public Command followTrajectory() {
configureBindings();
return Commands.print("No path to follow");
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/autos/TwoNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

package frc.robot.autos;

import com.choreo.lib.Auto;
import com.choreo.lib.Choreo;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Auto;
import frc.robot.subsystems.CommandSwerveDrivetrain;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.Shooter;
Expand All @@ -27,6 +27,7 @@ public TwoNote(

@Override
public Command followTrajectory() {
configureBindings();
return m_pathfollower;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/autos/WompWompKieran.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package frc.robot.autos;

import com.choreo.lib.Auto;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.Auto;
import frc.robot.subsystems.CommandSwerveDrivetrain;

public class WompWompKieran implements Auto {
Expand All @@ -20,6 +20,7 @@ public void configureBindings() {}

@Override
public Command followTrajectory() {
configureBindings();
return m_follower;
}
}

0 comments on commit be24647

Please sign in to comment.