Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
actually use dynamic autos
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSkylake committed Mar 7, 2024
1 parent 2e4bc4b commit 8829795
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;

Expand Down Expand Up @@ -102,6 +103,23 @@ public void autonomousInit() {

// if autonomousRoutine is custom use RobotContainer.fullAuto(start, note...)
// somehow get and parse a string from glass for start and note...
if (autonomousRoutine.getName().equals("Dynamic")) {
String commandString = SmartDashboard.getString("DynamicAutoString", "");
String[] split = commandString.split(" ");
String[] notePoseStrings = new String[split.length - 1];

for (int i = 1; i < split.length; i++) {
notePoseStrings[i] = split[i];
}

if (commandString.equals("")) {
autonomousRoutine = robotContainer.fullAuto("center");
} else {
autonomousRoutine = robotContainer.fullAuto(split[0], notePoseStrings);
}

}

if (autonomousRoutine != null) {
autonomousRoutine.schedule();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.commands.Dynamic;
import frc.robot.commands.arm.SetArmState;
import frc.robot.commands.drive.AutoIntake;
import frc.robot.commands.drive.AutoPickupNote;
Expand Down Expand Up @@ -352,7 +353,9 @@ private void configureAutonmous() {

autoBuilder = new AutoBuilder();
autoChooser = AutoBuilder.buildAutoChooser();
autoChooser.addOption("Dynamic", new Dynamic());
SmartDashboard.putData("Auto Chooser", autoChooser);
SmartDashboard.putString("DynamicAutoString", "");

configurePathPlannerLogging();
}
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/frc/robot/commands/Dynamic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.commands;

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

public class Dynamic extends Command {
/** Creates a new Dynamic. */
public Dynamic() {
this.setName("Dynamic");
// Use addRequirements() here to declare subsystem dependencies.
}

// Called when the command is initially scheduled.
@Override
public void initialize() {}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return true;
}
}

0 comments on commit 8829795

Please sign in to comment.