generated from Frc5572/Java-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes on command, finish neo and vortex
- Loading branch information
Showing
8 changed files
with
93 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
src/main/java/frc/robot/subsystems/RandomMotors/RandomMotors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsIO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsReal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |