Skip to content

Commit

Permalink
intake/outake commands sequentail stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Twilight420 committed Nov 29, 2023
1 parent 5fb816b commit bde1653
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 15 deletions.
18 changes: 17 additions & 1 deletion src/main/java/frc/Subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,37 @@
public class IntakeSubsystem extends SubsystemBase {
public TalonFX IntakeMotor;
public double IntakeMotorSpeed;
public double OutakeMotorPower;
public boolean Intake = false;


/** Creates a new IntakeSubsystem. */
public IntakeSubsystem() {
IntakeMotor = new TalonFX(Constants.Intake.INTAKE_MOTOR_PORT);

}

public void setIntakePower(double IntakeMotorSpeed){
Intake = true;
this.IntakeMotorSpeed = IntakeMotorSpeed;
}

public void setOutakePower(double OutakeMotorPower){
Intake = false;
this.OutakeMotorPower = OutakeMotorPower;

}



@Override
public void periodic() {
// This method will be called once per scheduler run
IntakeMotor.set(ControlMode.PercentOutput, IntakeMotorSpeed);
if(!Intake){
IntakeMotor.set(ControlMode.PercentOutput, IntakeMotorSpeed);
} else{
IntakeMotor.set(ControlMode.PercentOutput, OutakeMotorPower);
}

}
}
11 changes: 2 additions & 9 deletions src/main/java/frc/robot/Commands/IntakeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@
import frc.Subsystems.IntakeSubsystem;

public class IntakeCommand extends CommandBase {

private final IntakeSubsystem subsystem;

/** Creates a new IntakeCommand. */
public IntakeCommand(IntakeSubsystem subsystem) {
// Use addRequirements() here to declare subsystem dependencies.
this.subsystem = subsystem;

addRequirements(subsystem);

}

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

}
public void initialize() {}

// Called every time the scheduler runs while the command is scheduled.
@Override
Expand All @@ -34,9 +29,7 @@ public void execute() {

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

// Returns true when the command should end.
@Override
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/frc/robot/Commands/IntakeSequentailCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.SequentialCommandGroup;
import frc.Subsystems.IntakeSubsystem;


public class IntakeSequentailCommands extends SequentialCommandGroup{

private final IntakeSubsystem subsystem;

/** Creates a new IntakeCommand. */
public IntakeSequentailCommands(IntakeSubsystem subsystem) {
// Use addRequirements() here to declare subsystem dependencies.
this.subsystem = subsystem;

addRequirements(subsystem);

addCommands(
new IntakeCommand(subsystem),
new OutakeCommand(subsystem)
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
// 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.Commands;
package frc.robot.Commands;

import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.Subsystems.IntakeSubsystem;

public class IntakeCommand extends CommandBase {
/** Creates a new IntakeCommand. */
public IntakeCommand() {
public class OutakeCommand extends CommandBase {
private final IntakeSubsystem subsystem;

/** Creates a new OutakeCommand. */
public OutakeCommand(IntakeSubsystem subsystem) {
// Use addRequirements() here to declare subsystem dependencies.
this.subsystem = subsystem;

addRequirements(subsystem);
}

// Called when the command is initially scheduled.
Expand All @@ -18,7 +24,9 @@ public void initialize() {}

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

// Called once the command ends or is interrupted.
@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import frc.Subsystems.ElevatorSubsystem;
import frc.Subsystems.IntakeSubsystem;
import frc.robot.Commands.IntakeCommand;
import frc.robot.Commands.IntakeSequentailCommands;
import frc.robot.Commands.OutakeCommand;


/**
Expand Down Expand Up @@ -49,6 +51,9 @@ public RobotContainer() {
driverA.a().onTrue(new ElevatorBaseCommand(elevatorSubsystem, 3d));

driverA.rightTrigger().whileTrue(new IntakeCommand(intakeSubsystem));
driverA.rightBumper().whileTrue(new OutakeCommand(intakeSubsystem));

driverA.leftBumper().whileTrue(new IntakeSequentailCommands(intakeSubsystem));
}


Expand Down

0 comments on commit bde1653

Please sign in to comment.