From 95f6b9ea6112e5877f17699500d7159205dc0b61 Mon Sep 17 00:00:00 2001 From: DigitalFork <113265535+DigitalFork@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:09:53 -0800 Subject: [PATCH] Create ScoringAlign.java --- .../java/frc/robot/commands/ScoringAlign.java | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/main/java/frc/robot/commands/ScoringAlign.java diff --git a/src/main/java/frc/robot/commands/ScoringAlign.java b/src/main/java/frc/robot/commands/ScoringAlign.java new file mode 100644 index 0000000..8d45a74 --- /dev/null +++ b/src/main/java/frc/robot/commands/ScoringAlign.java @@ -0,0 +1,82 @@ +package frc.robot.commands; + +import frc.robot.subsystems.SwerveDrivetrain; +import edu.wpi.first.wpilibj2.command.Command; + +// How to make Command: https://compendium.readthedocs.io/en/latest/tasks/commands/commands.html (ignore image instructions, code is out of date, just look at written general instructions) +// Command based programming: https://docs.wpilib.org/en/stable/docs/software/commandbased/what-is-command-based.html +// Code documentations https://docs.wpilib.org/en/stable/docs/software/commandbased/commands.html + +/** An example command that uses an example subsystem. */ +public class ScoringAlign extends Command { + private final SwerveDrivetrain drivetrain; + + /** + * The constructor creates a new command and is automatically called one time + * when the command is created (with 'new' keyword). + * It should set up the initial state and properties of the object to ensure + * it's ready for use. + * This can take in any arguments you need. It normally uses 1 subsystem (but an + * take multiple when necessary), + * as wells as arguments for what to do, such as a joystick in the drive command + * or a desired position in an auto command. + * Example uses include saving parameters passed to the command, creating and + * configuring objects for the class like PID controllers, and adding subsystem + * requirements + */ + public ScoringAlign(SwerveDrivetrain drivetrain) { + // use "this" to access member variable subsystem rather than local subsystem + this.drivetrain = drivetrain; + + // Use addRequirements() here to declare subsystem dependencies. + // This makes sure no other commands try to do stuff with your subsystem while + // you are using it. + addRequirements(this.drivetrain); + } + + /** + * initialize() is used to prepare a command for execution and is called once + * when the command is scheduled. + * It should reset the command's state since command objects can be used + * multiple times. + * Example uses include setting motor to constant speed, setting a solenoid to a + * certain state, and resetting variables + */ + @Override + public void initialize() { + + } + + @Override + public void execute() { + + } + + /** + * isFinished() finished is called repeatedly while a command is scheduled, + * right after execute. + * It should return true when you want the command to finish. end(false) is + * called directly after isFinished() returns true. + * Example uses include checking if control loop is at set point, and always + * returning false to end after just 1 call to execute. + */ + @Override + public boolean isFinished() { + return true; + } + + /** + * end(boolean interrupted) is called once when a command ends, regardless of + * whether it finishes normally or is interrupted. + * It should wrap up the command since other commands might use the same + * subsystems. + * Once end runs the command will no longer be in the command scheduler loop. + * It takes in a boolean interrupted which is set to true when the command is + * ended without isFinished() returning true. + * Example uses include setting motor speeds back to zero, and setting a + * solenoid back to a "default" state. + */ + @Override + public void end(boolean interrupted) { + } +}