From 5212608634d29c16f971ce1d6d9265dada4efed0 Mon Sep 17 00:00:00 2001 From: JordanP244656 <162927099+JordanP244656@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:10:09 -0400 Subject: [PATCH 1/3] Add files via upload --- .../frc/robot/subsystems/intakemotor.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/intakemotor.java diff --git a/src/main/java/frc/robot/subsystems/intakemotor.java b/src/main/java/frc/robot/subsystems/intakemotor.java new file mode 100644 index 0000000..4d454f1 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intakemotor.java @@ -0,0 +1,21 @@ +package frc.robot.subsystems; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkLowLevel.MotorType; + +public class IntakeMotor extends SubsystemBase { + private final CANSparkMax motor; + + public IntakeMotor() { + motor = new CANSparkMax(1, MotorType.kBrushless); // Replace 1 with your CAN ID + } + + public void setSpeed(double speed) { + motor.set(speed); + } + + public void stop() { + motor.set(0); + } +} From b459809bb5f6a5e6d771c0866ab8ae80176c1a5d Mon Sep 17 00:00:00 2001 From: JordanP244656 <162927099+JordanP244656@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:10:42 -0400 Subject: [PATCH 2/3] Add files via upload --- .../robot/commands/IntakeMotorCommand.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/frc/robot/commands/IntakeMotorCommand.java diff --git a/src/main/java/frc/robot/commands/IntakeMotorCommand.java b/src/main/java/frc/robot/commands/IntakeMotorCommand.java new file mode 100644 index 0000000..e7ea2ee --- /dev/null +++ b/src/main/java/frc/robot/commands/IntakeMotorCommand.java @@ -0,0 +1,31 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.subsystems.IntakeMotor; + +public class IntakeMotorCommand extends CommandBase { + private final IntakeMotor intakeSubsystem; + + public IntakeMotorCommand(IntakeMotor subsystem) { + intakeSubsystem = subsystem; + addRequirements(subsystem); + } + + @Override + public void initialize() {} + + @Override + public void execute() { + intakeSubsystem.setSpeed(0.35); + } + + @Override + public void end(boolean interrupted) { + intakeSubsystem.stop(); + } + + @Override + public boolean isFinished() { + return false; + } +} From 2476b1dc998c289d64be49fcb730118bf9ca57e5 Mon Sep 17 00:00:00 2001 From: JordanP244656 <162927099+JordanP244656@users.noreply.github.com> Date: Mon, 20 Oct 2025 21:15:55 -0400 Subject: [PATCH 3/3] Refactor RobotContainer to include IntakeMotor functionality --- src/main/java/frc/robot/RobotContainer.java | 66 ++++----------------- 1 file changed, 11 insertions(+), 55 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a33249e..26c4f4f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -1,63 +1,19 @@ -// 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; -import frc.robot.Constants.OperatorConstants; -import frc.robot.commands.Autos; -import frc.robot.commands.ExampleCommand; -import frc.robot.subsystems.ExampleSubsystem; -import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.IntakeMotor; +import frc.robot.commands.IntakeMotorCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; -import edu.wpi.first.wpilibj2.command.button.Trigger; -/** - * This class is where the bulk of the robot should be declared. Since Command-based is a - * "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot} - * periodic methods (other than the scheduler calls). Instead, the structure of the robot (including - * subsystems, commands, and trigger mappings) should be declared here. - */ public class RobotContainer { - // The robot's subsystems and commands are defined here... - private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem(); - - // Replace with CommandPS4Controller or CommandJoystick if needed - private final CommandXboxController m_driverController = - new CommandXboxController(OperatorConstants.kDriverControllerPort); - - /** The container for the robot. Contains subsystems, OI devices, and commands. */ - public RobotContainer() { - // Configure the trigger bindings - configureBindings(); - } - - /** - * Use this method to define your trigger->command mappings. Triggers can be created via the - * {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary - * predicate, or via the named factories in {@link - * edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for {@link - * CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller - * PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight - * joysticks}. - */ - private void configureBindings() { - // Schedule `ExampleCommand` when `exampleCondition` changes to `true` - new Trigger(m_exampleSubsystem::exampleCondition) - .onTrue(new ExampleCommand(m_exampleSubsystem)); + private final IntakeMotor intakeMotor = new IntakeMotor(); + private final IntakeMotorCommand intakeCommand = new IntakeMotorCommand(intakeMotor); + private final CommandXboxController controller = new CommandXboxController(0); - // Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed, - // cancelling on release. - m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand()); - } + public RobotContainer() { + configureBindings(); + } - /** - * Use this to pass the autonomous command to the main {@link Robot} class. - * - * @return the command to run in autonomous - */ - public Command getAutonomousCommand() { - // An example command will be run in autonomous - return Autos.exampleAuto(m_exampleSubsystem); - } + private void configureBindings() { + controller.a().whileTrue(intakeCommand); + } }