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

Commit

Permalink
Add example OneNote Auto Routine
Browse files Browse the repository at this point in the history
Resolves #20
  • Loading branch information
spacey-sooty committed May 26, 2024
1 parent b10b117 commit d475a58
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.autos.OneNote;
import frc.robot.generated.TunerConstants;
import frc.robot.subsystems.Climber;
import frc.robot.subsystems.CommandSwerveDrivetrain;
Expand All @@ -26,11 +27,13 @@ public class Robot extends TimedRobot {
private CommandXboxController m_codriver;
private Shooter m_shooter;
private Climber m_climber;
private SendableChooser<Command> m_chooser = new SendableChooser<>();
private SendableChooser<Auto> m_chooser = new SendableChooser<>();
private Intake m_intake;

private Command getAutonomousCommand() {
return m_chooser.getSelected();
Auto auto = m_chooser.getSelected();
auto.configureBindings();
return auto.followTrajectory();
}

private double MaxSpeed =
Expand Down Expand Up @@ -103,7 +106,7 @@ public Robot() {
new Intake(new CANSparkMax(Constants.intakePort, CANSparkMaxLowLevel.MotorType.kBrushless));
CommandScheduler.getInstance().registerSubsystem(m_intake);

m_chooser.setDefaultOption("Simple Auto", m_shooter.spinup(1));
m_chooser.setDefaultOption("One Note", new OneNote(m_shooter, m_intake));
SmartDashboard.putData(m_chooser);

configureBindings();
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/frc/robot/autos/OneNote.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package frc.robot.autos;

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;

public class OneNote implements Auto {
Shooter m_shooter;
Intake m_intake;

public OneNote(Shooter shooter, Intake intake) {
m_shooter = shooter;
m_intake = intake;
}

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

public void configureBindings() {
Choreo.event("shoot")
.onTrue(
m_shooter
.spinup(300)
.andThen(Commands.parallel(m_intake.pass(), m_shooter.maintain())));
}
}

0 comments on commit d475a58

Please sign in to comment.