mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 08:48:07 -06:00
Merge branch 'swerve' of https://github.com/Team4388/2022NoWayHome into swerve
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
// 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 frc4388.robot.subsystems;
|
||||
|
||||
//Imported Limit switch ONLY
|
||||
import com.revrobotics.SparkMaxLimitSwitch;
|
||||
import com.revrobotics.SparkMaxLimitSwitch.Type;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
||||
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.CANSparkMax.IdleMode;
|
||||
|
||||
public class Intake extends SubsystemBase {
|
||||
|
||||
private WPI_TalonFX m_intakeMotor;
|
||||
private CANSparkMax m_extenderMotor;
|
||||
private SparkMaxLimitSwitch m_inLimit;
|
||||
private SparkMaxLimitSwitch m_outLimit;
|
||||
|
||||
public boolean toggle;
|
||||
|
||||
/** Creates a new Intake. */
|
||||
public Intake(WPI_TalonFX intakeMotor, CANSparkMax extenderMotor) {
|
||||
m_intakeMotor = intakeMotor;
|
||||
m_extenderMotor = extenderMotor;
|
||||
|
||||
m_extenderMotor.restoreFactoryDefaults();
|
||||
|
||||
m_intakeMotor.setNeutralMode(NeutralMode.Brake);
|
||||
m_intakeMotor.setInverted(false);
|
||||
m_extenderMotor.setInverted(true);
|
||||
|
||||
m_inLimit = m_extenderMotor.getForwardLimitSwitch(SparkMaxLimitSwitch.Type.kNormallyOpen);
|
||||
m_outLimit = m_extenderMotor.getForwardLimitSwitch(SparkMaxLimitSwitch.Type.kNormallyOpen);
|
||||
m_inLimit.enableLimitSwitch(true);
|
||||
m_outLimit.enableLimitSwitch(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
}
|
||||
/**
|
||||
* Runs The Intake With Triggers.
|
||||
* @param leftTrigger Left Trigger to Run -
|
||||
* @param rightTrigger Right Trigger to Run +
|
||||
*/
|
||||
public void runWithTriggers(double leftTrigger, double rightTrigger) {
|
||||
m_intakeMotor.set(rightTrigger - leftTrigger);
|
||||
}
|
||||
/**
|
||||
* Runs The Extender
|
||||
* @param extended Wether the Extender Is Extended
|
||||
*/
|
||||
public void runExtender(boolean extended) { //TODO: Do not bring intake in if there is a ball in the extender (check if intake being in brakes the beam brake?)
|
||||
double extenderMotorSpeed = extended ? 0.25d : 0.d;
|
||||
m_extenderMotor.set(extenderMotorSpeed);
|
||||
}
|
||||
/**
|
||||
* Toggles The Extender
|
||||
*/
|
||||
public void toggleExtender() {
|
||||
toggle = !toggle;
|
||||
runExtender(toggle);
|
||||
}
|
||||
//Test
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package frc4388.robot.subsystems;
|
||||
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc4388.robot.Constants;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
|
||||
public class Serializer extends SubsystemBase{
|
||||
private CANSparkMax m_serializerBelt;
|
||||
private CANSparkMax m_serializerShooterBelt;
|
||||
private DigitalInput m_serializerBeam;
|
||||
private boolean serializerState;
|
||||
|
||||
public Serializer(CANSparkMax serializerBelt, CANSparkMax serializerShooterBelt) {
|
||||
m_serializerBelt = serializerBelt;
|
||||
m_serializerShooterBelt = serializerShooterBelt;
|
||||
m_serializerBeam = new DigitalInput(Constants.SerializerConstants.SERIALIZER_BELT_BEAM);
|
||||
|
||||
serializerState = false;
|
||||
setSerializerState(serializerState);
|
||||
m_serializerBelt.set(0);
|
||||
m_serializerShooterBelt.set(0);
|
||||
|
||||
}
|
||||
/**
|
||||
* Gets The State Of The Beam
|
||||
* @return The State Of The Beam
|
||||
*/
|
||||
public boolean getBeam() {
|
||||
return m_serializerBeam.get();
|
||||
}
|
||||
/**
|
||||
* Sets The Serializer State With The Beam
|
||||
* @param state Your State Of The Button
|
||||
* @param beambroken The State of the Beam Senser
|
||||
*/
|
||||
public void setSerializerStateWithBeam(boolean state, boolean beambroken) {
|
||||
boolean total = state || beambroken;
|
||||
setSerializerState(total);
|
||||
}
|
||||
/**
|
||||
* Sets The Serializer State With The Beam
|
||||
* @param state Your State Of The Button
|
||||
*/
|
||||
public void setSerializerState(boolean state) {
|
||||
setSerializerBeltState(state);
|
||||
setSerializerShooterBeltState(state);
|
||||
serializerState = state;
|
||||
}
|
||||
/**
|
||||
* Sets the Serializer Belt State
|
||||
* @param state Your State Of The Button
|
||||
*/
|
||||
public void setSerializerBeltState(boolean state) {
|
||||
double serializerBeltSpeed = state ? Constants.SerializerConstants.SERIALIZER_BELT_SPEED : 0.d;
|
||||
m_serializerBelt.set(serializerBeltSpeed);
|
||||
}
|
||||
/**
|
||||
* Sets the Shooter Belt State
|
||||
* @param state Your State Of The Button
|
||||
*/
|
||||
public void setSerializerShooterBeltState(boolean state) {
|
||||
double serializerShooterBeltSpeed = state ? Constants.SerializerConstants.SERIALIZER_SHOOTER_BELT_SPEED : 0.d;
|
||||
m_serializerShooterBelt.set(serializerShooterBeltSpeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Serializer State
|
||||
* @return The Serializer State
|
||||
*/
|
||||
public boolean getSerializerState() {
|
||||
return serializerState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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 frc4388.robot.subsystems;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import frc4388.robot.Constants.StorageConstants;
|
||||
|
||||
public class Storage extends SubsystemBase {
|
||||
public CANSparkMax m_storageMotor = new CANSparkMax(StorageConstants.STORAGE_CAN_ID, MotorType.kBrushless);
|
||||
private DigitalInput m_beamShooter = new DigitalInput(StorageConstants.BEAM_SENSOR_SHOOTER);
|
||||
private DigitalInput m_beamIntake = new DigitalInput(StorageConstants.BEAM_SENSOR_INTAKE);
|
||||
|
||||
/** Creates a new Storage. */
|
||||
public Storage() {
|
||||
|
||||
}
|
||||
/**
|
||||
* If The Beam Is Broken, Run Storage
|
||||
* If Else, Stop Running Storage
|
||||
*/
|
||||
public void manageStorage() {
|
||||
if (m_beamShooter.get()) {
|
||||
runStorage(1.d);
|
||||
} else { runStorage(0.d); }
|
||||
}
|
||||
/**
|
||||
* Runs The Storage at a Specifyed Speed
|
||||
* @param input The Specifyed Speed
|
||||
*/
|
||||
public void runStorage(double input) {
|
||||
m_storageMotor.set(input);
|
||||
}
|
||||
/**
|
||||
* Gets The Beam State On The Shooter
|
||||
* @return The State Of The Beam on the Shooter
|
||||
*/
|
||||
public boolean getBeamShooter(){
|
||||
return m_beamShooter.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets The Beam State Of The Intake
|
||||
* @return The Beam State Of The Intake
|
||||
*/
|
||||
public boolean getBeamIntake(){
|
||||
return m_beamIntake.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Every Robot Tick Manage The Storage
|
||||
*/
|
||||
public void periodic() {
|
||||
manageStorage();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user