-
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.
- Loading branch information
1 parent
9e67a07
commit 97571fa
Showing
2 changed files
with
78 additions
and
0 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
74 changes: 74 additions & 0 deletions
74
src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.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,74 @@ | ||
// 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.intake; | ||
|
||
import java.util.function.DoubleSupplier; | ||
|
||
import org.lasarobotics.hardware.revrobotics.Spark; | ||
import org.lasarobotics.hardware.revrobotics.Spark.MotorKind; | ||
|
||
import com.revrobotics.CANSparkBase.ControlType; | ||
import com.revrobotics.SparkPIDController.ArbFFUnits; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
public class IntakeSubsystem extends SubsystemBase { | ||
public static class Hardware { | ||
private Spark rollorMotor; | ||
|
||
public Hardware(Spark rollorMotor) { | ||
this.rollorMotor = rollorMotor; | ||
} | ||
} | ||
|
||
private Spark m_rollorMotor; | ||
|
||
/** Creates a new IntakeSubsystem. */ | ||
public IntakeSubsystem(Hardware intakeHardware) { | ||
this.m_rollorMotor = intakeHardware.rollorMotor; | ||
} | ||
|
||
/** | ||
* Initialize hardware devices for intake subsystem | ||
* | ||
* @return Hardware object containing all necessary devices for this subsystem | ||
*/ | ||
public static Hardware initializeHardware() { | ||
Hardware intakeHardware = new Hardware( | ||
new Spark(Constants.IntakeHardware.ROLLER_MOTOR_ID, MotorKind.NEO) | ||
); | ||
return intakeHardware; | ||
} | ||
|
||
// Tells the robot to intake | ||
private void intake(double speed) { | ||
m_rollorMotor.set(speed, ControlType.kDutyCycle, 0.0, ArbFFUnits.kPercentOut); | ||
} | ||
|
||
public Command intakeCommand(DoubleSupplier speed) { | ||
return startEnd(() -> intake(speed.getAsDouble()), () -> stop()); | ||
} | ||
|
||
// Tells the robot to outtake | ||
private void outtake(double speed) { | ||
m_rollorMotor.set(-speed, ControlType.kDutyCycle, 0.0, ArbFFUnits.kPercentOut); | ||
} | ||
|
||
public Command outtakeCommand(DoubleSupplier speed) { | ||
return startEnd(() -> outtake(speed.getAsDouble()), () -> stop()); | ||
} | ||
|
||
// Stop the robot | ||
private void stop() { | ||
m_rollorMotor.stopMotor();; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |