generated from OakvilleDynamics/frc-robot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added intake, dump, and conveyor subsystems. These closely mirror those found on OakvilleDynamics/2024-Robot. Updated constants to reflect better names of some of the variables.
- Loading branch information
1 parent
84dada5
commit 50e719b
Showing
6 changed files
with
182 additions
and
35 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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.subsystems; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkBase.IdleMode; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants.MechanismConstants.Conveyor; | ||
|
||
public class ConveyorSubsystem extends SubsystemBase { | ||
private final CANSparkMax conveyorMotorLeft = new CANSparkMax(Conveyor.CONVEYOR_MOTOR_LEFT, MotorType.kBrushless); | ||
private final CANSparkMax conveyorMotorRight = new CANSparkMax(Conveyor.CONVEYOR_MOTOR_RIGHT, MotorType.kBrushless); | ||
|
||
public ConveyorSubsystem() { | ||
conveyorMotorLeft.setInverted(Conveyor.CONVEYOR_MOTOR_LEFT_INVERTED); | ||
conveyorMotorRight.setInverted(Conveyor.CONVEYOR_MOTOR_RIGHT_INVERTED); | ||
|
||
conveyorMotorLeft.setIdleMode(IdleMode.kBrake); | ||
conveyorMotorRight.setIdleMode(IdleMode.kBrake); | ||
} | ||
|
||
@Override | ||
public void periodic() {} | ||
|
||
/** | ||
* Run the conveyor at a set speed in the {@link Conveyor} class. | ||
*/ | ||
public void runConveyor() { | ||
conveyorMotorLeft.set(Conveyor.CONVEYOR_MOTOR_SPEED); | ||
conveyorMotorRight.set(Conveyor.CONVEYOR_MOTOR_SPEED); | ||
} | ||
|
||
/** | ||
* Stop the conveyor. | ||
*/ | ||
public void stopConveyor() { | ||
conveyorMotorLeft.set(0); | ||
conveyorMotorRight.set(0); | ||
} | ||
|
||
/** | ||
* Reverse the conveyor at a set speed in the {@link Conveyor} class. | ||
*/ | ||
public void reverseConveyor() { | ||
conveyorMotorLeft.set(-Conveyor.CONVEYOR_MOTOR_SPEED); | ||
conveyorMotorRight.set(-Conveyor.CONVEYOR_MOTOR_SPEED); | ||
} | ||
} |
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,42 @@ | ||
// 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.subsystems; | ||
|
||
import edu.wpi.first.wpilibj.DoubleSolenoid; | ||
import edu.wpi.first.wpilibj.PneumaticsModuleType; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants.HardwareConstants; | ||
|
||
public class DumpSubsystem extends SubsystemBase { | ||
private final DoubleSolenoid dumpSolenoid = new DoubleSolenoid(HardwareConstants.REV_PCM_ID, PneumaticsModuleType.REVPH, HardwareConstants.PneumaticsChannel.DUMP_OUT, HardwareConstants.PneumaticsChannel.DUMP_IN); | ||
private boolean isDumped = false; | ||
|
||
public DumpSubsystem() { | ||
SmartDashboard.putBoolean(getName(), isDumped); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
} | ||
|
||
/** | ||
* Dumps the dump bed. | ||
*/ | ||
public void dump() { | ||
dumpSolenoid.set(DoubleSolenoid.Value.kForward); | ||
isDumped = true; | ||
SmartDashboard.putBoolean(getName(), isDumped); | ||
} | ||
|
||
/** | ||
* Retracts the dump bed. | ||
*/ | ||
public void retract() { | ||
dumpSolenoid.set(DoubleSolenoid.Value.kReverse); | ||
isDumped = false; | ||
SmartDashboard.putBoolean(getName(), isDumped); | ||
} | ||
} |
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,53 @@ | ||
// 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.subsystems; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkBase.IdleMode; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import frc.robot.Constants.MechanismConstants.Intake; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class IntakeSubsystem extends SubsystemBase { | ||
private final CANSparkMax intakeSushi = new CANSparkMax(Intake.INTAKE_SUSHI, MotorType.kBrushless); | ||
private final CANSparkMax intakeFront = new CANSparkMax(Intake.INTAKE_FRONT, MotorType.kBrushless); | ||
|
||
public IntakeSubsystem() { | ||
intakeSushi.setInverted(Intake.INTAKE_SUSHI_INVERTED); | ||
intakeFront.setInverted(Intake.INTAKE_FRONT_INVERTED); | ||
|
||
intakeFront.setIdleMode(IdleMode.kBrake); | ||
intakeSushi.setIdleMode(IdleMode.kBrake); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
|
||
/** | ||
* Run the intake at a set speed in the {@link Intake} class. | ||
*/ | ||
public void runIntake() { | ||
intakeSushi.set(Intake.INTAKE_SUSHI_SPEED); | ||
intakeFront.set(Intake.INTAKE_FRONT_SPEED); | ||
} | ||
|
||
/** | ||
* Stop the intake. | ||
*/ | ||
public void stopIntake() { | ||
intakeSushi.set(0); | ||
intakeFront.set(0); | ||
} | ||
|
||
/** | ||
* Reverse the intake at a set speed in the {@link Intake} class. | ||
*/ | ||
public void reverseIntake() { | ||
intakeSushi.set(-Intake.INTAKE_SUSHI_SPEED); | ||
intakeFront.set(-Intake.INTAKE_FRONT_SPEED); | ||
} | ||
} |
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