Skip to content

Commit

Permalink
Redo auto command structure
Browse files Browse the repository at this point in the history
  • Loading branch information
manthan-acharya committed Feb 17, 2024
1 parent d708710 commit abfb3cb
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 156 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/littletonrobotics/frc2024/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
public final class Constants {
public static final double loopPeriodSecs = 0.02;
private static RobotType robotType = RobotType.DEVBOT;
private static RobotType robotType = RobotType.SIMBOT;
public static final boolean tuningMode = true;

public static RobotType getRobot() {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/littletonrobotics/frc2024/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import org.littletonrobotics.frc2024.commands.FeedForwardCharacterization;
import org.littletonrobotics.frc2024.commands.auto.AutoCommands;
import org.littletonrobotics.frc2024.commands.auto.AutoBuilder;
import org.littletonrobotics.frc2024.subsystems.apriltagvision.AprilTagVision;
import org.littletonrobotics.frc2024.subsystems.apriltagvision.AprilTagVisionConstants;
import org.littletonrobotics.frc2024.subsystems.apriltagvision.AprilTagVisionIO;
Expand Down Expand Up @@ -180,8 +180,8 @@ public RobotContainer() {

private void configureAutos() {
autoChooser.addDefaultOption("Do Nothing", Commands.none());
AutoCommands autoCommands = new AutoCommands(drive, superstructure, flywheels, rollers);
autoChooser.addOption("Drive Straight", autoCommands.driveStraight());
AutoBuilder autoBuilder = new AutoBuilder(drive, superstructure, flywheels, rollers);
// autoChooser.addOption("Drive Straight", autoBuilder.driveStraight());

// Set up feedforward characterization
autoChooser.addOption(
Expand All @@ -196,9 +196,9 @@ private void configureAutos() {
flywheels::runCharacterizationVolts,
flywheels::getCharacterizationVelocity));

autoChooser.addOption(("Davis Ethical Auto"), autoCommands.davisEthicalAuto());
autoChooser.addOption("N5_S0_C0123", autoCommands.N5_S0_C012());
autoChooser.addOption("N5_S1_C123", autoCommands.N5_S1_C234());
autoChooser.addOption(("Davis Ethical Auto"), autoBuilder.davisEthicalAuto());
// autoChooser.addOption("N5_S0_C0123", autoBuilder.N5_S0_C012());
// autoChooser.addOption("N5_S1_C123", autoBuilder.N5_S1_C234());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Copyright (c) 2024 FRC 6328
// http://github.com/Mechanical-Advantage
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file at
// the root directory of this project.

package org.littletonrobotics.frc2024.commands.auto;

import static edu.wpi.first.wpilibj2.command.Commands.*;
import static org.littletonrobotics.frc2024.commands.auto.AutoCommands.*;

import edu.wpi.first.wpilibj2.command.Command;
import org.littletonrobotics.frc2024.FieldConstants;
import org.littletonrobotics.frc2024.subsystems.drive.Drive;
import org.littletonrobotics.frc2024.subsystems.drive.trajectory.HolonomicTrajectory;
import org.littletonrobotics.frc2024.subsystems.flywheels.Flywheels;
import org.littletonrobotics.frc2024.subsystems.rollers.Rollers;
import org.littletonrobotics.frc2024.subsystems.superstructure.Superstructure;

public class AutoBuilder {
private final Drive drive;
private final Superstructure superstructure;
private final Flywheels flywheels;
private final Rollers rollers;

public AutoBuilder(
Drive drive, Superstructure superstructure, Flywheels flywheels, Rollers rollers) {
this.drive = drive;
this.superstructure = superstructure;
this.flywheels = flywheels;
this.rollers = rollers;
}

public Command davisEthicalAuto() {
HolonomicTrajectory driveToPodiumTrajectory =
new HolonomicTrajectory("davisEthicalAuto_driveToPodium");
HolonomicTrajectory driveToCenterline2Trajectory =
new HolonomicTrajectory("davisEthicalAuto_driveToCenterline2");
HolonomicTrajectory driveToCenterline1Trajectory =
new HolonomicTrajectory("davisEthicalAuto_driveToCenterline1");
HolonomicTrajectory driveToCenterline0Trajectory =
new HolonomicTrajectory("davisEthicalAuto_driveToCenterline0");

return sequence(
// Shoot first note
resetPose(driveToPodiumTrajectory),
shoot(superstructure, flywheels, rollers),

// Drive to podium while intaking then shoot
followTrajectory(drive, driveToPodiumTrajectory)
.deadlineWith(intake(superstructure, rollers).andThen(superstructure.aim())),
shoot(superstructure, flywheels, rollers),

// Drive to centerline waiting to intake after we cross the wing
followTrajectory(drive, driveToCenterline2Trajectory)
.deadlineWith(
waitUntilXCrossed(FieldConstants.wingX).andThen(intake(superstructure, rollers))),
shoot(superstructure, flywheels, rollers),

// Drive back to centerline 1
followTrajectory(drive, driveToCenterline1Trajectory)
.deadlineWith(intake(superstructure, rollers)),
shoot(superstructure, flywheels, rollers),

// Drive to centerline 0 and come back for shot
followTrajectory(drive, driveToCenterline0Trajectory)
.deadlineWith(intake(superstructure, rollers)),
shoot(superstructure, flywheels, rollers)

//

// path("davisEthicalAuto_driveToCenterline2")
// .deadlineWith(
// superstructure
// .floorIntakeCommand()
// .alongWith(rollers.floorIntakeCommand())
// .withTimeout(3)
// .andThen(superstructure.aimCommand())),
//
// rollers.feedShooterCommand().withTimeout(.1).deadlineWith(superstructure.aimCommand()),
// path("davisEthicalAuto_driveToPodium")
// .deadlineWith(superstructure.floorIntakeCommand(),
// rollers.floorIntakeCommand()),
// Commands.waitUntil(
// () -> true
// // superstructure::atArmSetpoint
// )
// .andThen(rollers.feedShooterCommand().withTimeout(.1))
);
}

// public Command N5_S1_C234() {
// return sequence(
// reset("N5-S1-C234_driveToS1"),
// path("N5-S1-C234_driveToS1"),
// path("N5-S1-C234_driveToC2"),
// path("N5-S1-C234_driveToC3"),
// path("N5-S1-C234_driveToC4"));
// }

// public Command N5_S0_C012() {
// return sequence(
// reset("N5-S0-C0123_driveToS0"),
// // Commands.waitUntil(
// // () -> true
// // () -> superstructure.atArmSetpoint() &&
// // flywheels.atSetpoint()
// // )
// // .andThen(rollers.feedShooterCommand().withTimeout(.3))
// // .deadlineWith(superstructure.aimCommand()),
// path("N5-S0-C0123_driveToS0"),
// // .deadlineWith(
// // superstructure
// // .floorIntakeCommand()
// // .alongWith(rollers.floorIntakeCommand())
// // .withTimeout(3)
// // .andThen(superstructure.aimCommand())),
// //
// //
// rollers.feedShooterCommand().withTimeout(.1).deadlineWith(superstructure.aimCommand()),
// path("N5-S0-C0123_driveToC0")
// // .deadlineWith(
// // superstructure
// // .floorIntakeCommand()
// // .alongWith(rollers.floorIntakeCommand())
// // .withTimeout(3)
// // .andThen(superstructure.aimCommand())),
// //
// //
// rollers.feedShooterCommand().withTimeout(.1).deadlineWith(superstructure.aimCommand())
// // path("N5-S0-C0123_driveToC1")
// // .deadlineWith(
// // superstructure
// // .floorIntakeCommand()
// // .alongWith(rollers.floorIntakeCommand())
// // .withTimeout(3)
// // .andThen(superstructure.aimCommand())),
// //
// //
// rollers.feedShooterCommand().withTimeout(.1).deadlineWith(superstructure.aimCommand())
// // path("N5-S0-C0123_driveToC2")
// // .deadlineWith(superstructure.floorIntakeCommand(),
// // rollers.floorIntakeCommand()),
// // Commands.waitUntil(
// // () -> true
// // // superstructure::atArmSetpoint
// // )
// // .andThen(rollers.feedShooterCommand().withTimeout(.1)))
// // .deadlineWith(flywheels.shootCommand()
// );
}

// public Command driveStraight() {
// return reset("driveToPodium")
// .andThen(path("driveToPodium"));
Loading

0 comments on commit abfb3cb

Please sign in to comment.