Skip to content

Commit

Permalink
fixes on command, finish neo and vortex
Browse files Browse the repository at this point in the history
  • Loading branch information
Merridew1 committed Nov 21, 2024
1 parent 35c74f2 commit 5fd7b1c
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public static final class IntakeMotors {
public static final int LMOTOR = 1;
public static final int RMOTOR = 2;
}
public static final class RandomMotors {
public static final int NEOVORTEX = 10;
public static final int FALCON = 11;
}
}

/**
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import frc.robot.commands.Drive;
import frc.robot.commands.IntakeCommand;
import frc.robot.commands.OutTakeCommand;
import frc.robot.commands.RandomMotorCommand;
import frc.robot.subsystems.Intake.Intake;
import frc.robot.subsystems.RandomMotors.RandomMotors;
import frc.robot.subsystems.drive.Drivetrain;
import frc.robot.subsystems.drive.DrivetrainIO;
import frc.robot.subsystems.drive.DrivetrainReal;
Expand All @@ -30,7 +32,7 @@ public class RobotContainer {
/* Subsystems */
private Drivetrain driveTrain;
private Intake intake;

private RandomMotors randMot;

/**
* The container for the robot. Contains subsystems, OI devices, and commands.
Expand Down Expand Up @@ -63,12 +65,12 @@ public RobotContainer(RobotRunType runtimeType) {
;

private void configureButtonBindings() {
driver.rightTrigger().whileTrue(new OutTakeCommand(intake, driver));
driver.leftTrigger().whileTrue(new IntakeCommand(intake, driver));

driver.rightTrigger().whileTrue(new OutTakeCommand(intake));
driver.leftTrigger().whileTrue(new IntakeCommand(intake));
driver.a().whileTrue(new RandomMotorCommand(randMot));
}


}

/**
* Gets the user's selected autonomous command.
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/frc/robot/commands/IntakeCommand.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.subsystems.Intake.Intake;

public class IntakeCommand extends Command {
private CommandXboxController controller;
private Intake intake;

public IntakeCommand(Intake intake, CommandXboxController controller) {
this.controller = controller;
public IntakeCommand(Intake intake) {
this.intake = intake;
addRequirements(intake);
}

@Override
public void execute() {
intake.setIntakeVoltage(1);
controller.leftTrigger().whileTrue(new InstantCommand(() -> intake.setIntakeVoltage(-1)));
}
}
8 changes: 1 addition & 7 deletions src/main/java/frc/robot/commands/OutTakeCommand.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.subsystems.Intake.Intake;

public class OutTakeCommand extends Command {
private CommandXboxController controller;
private Intake intake;

public OutTakeCommand(Intake intake, CommandXboxController controller) {
this.controller = controller;
public OutTakeCommand(Intake intake) {
this.intake = intake;
addRequirements(intake);
}

@Override
public void execute() {
intake.setIntakeVoltage(-1);
controller.rightTrigger().whileTrue(new InstantCommand(() -> intake.setIntakeVoltage(1)));
controller.leftTrigger().whileTrue(new InstantCommand(() -> intake.setIntakeVoltage(-1)));
}
}
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/commands/RandomMotorCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.RandomMotors.RandomMotors;

public class RandomMotorCommand extends Command {
private RandomMotors randMot;

public RandomMotorCommand(RandomMotors randMot) {
this.randMot = randMot;
addRequirements(randMot);
}

@Override
public void execute() {
randMot.runMotor(1);
}
}
23 changes: 23 additions & 0 deletions src/main/java/frc/robot/subsystems/RandomMotors/RandomMotors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package frc.robot.subsystems.RandomMotors;

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

public class RandomMotors extends SubsystemBase {
private RandomMotorsIO io;
private RandomMotorsIOInputsAutoLogged inputs = new RandomMotorsIOInputsAutoLogged();

public RandomMotors(RandomMotorsIO io) {
this.io = io;
}

@Override
public void periodic() {
io.updateInputs(inputs);
}

public void runMotor(double power) {
io.runMotor(power);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package frc.robot.subsystems.RandomMotors;

import org.littletonrobotics.junction.AutoLog;

public interface RandomMotorsIO {


@AutoLog
public static class RandomMotorsIOInputs {
public double falconMotor;
public double neoVortex;

}

public default void updateInputs(RandomMotorsIOInputs inputs) {}

public default void runMotor(double voltage) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package frc.robot.subsystems.RandomMotors;

import com.ctre.phoenix6.hardware.TalonFX;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.revrobotics.CANSparkMax;
import frc.robot.Constants;

public class RandomMotorsReal implements RandomMotorsIO {
private final CANSparkMax neoVortex =
new CANSparkMax(Constants.Motors.RandomMotors.NEOVORTEX, MotorType.kBrushless);
private final TalonFX Falcon = new TalonFX(Constants.Motors.RandomMotors.FALCON);

@Override
public void updateInputs(RandomMotorsIOInputs inputs) {}

public void runMotor(double power) {
neoVortex.set(power);
Falcon.set(power);
}

}

0 comments on commit 5fd7b1c

Please sign in to comment.