mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 08:48:07 -06:00
JavaDocs
This commit is contained in:
@@ -10,9 +10,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
|
||||
import frc4388.robot.Constants.*;
|
||||
import frc4388.robot.subsystems.Intake;
|
||||
import frc4388.robot.subsystems.LED;
|
||||
import frc4388.robot.subsystems.Serializer;
|
||||
import frc4388.robot.subsystems.SwerveDrive;
|
||||
import frc4388.utility.LEDPatterns;
|
||||
import frc4388.utility.controller.IHandController;
|
||||
@@ -29,7 +27,7 @@ public class RobotContainer {
|
||||
/* RobotMap */
|
||||
private final RobotMap m_robotMap = new RobotMap();
|
||||
|
||||
/* Subsystems
|
||||
/* Subsystems */
|
||||
private final SwerveDrive m_robotSwerveDrive = new SwerveDrive(
|
||||
m_robotMap.leftFrontSteerMotor, m_robotMap.leftFrontWheelMotor,
|
||||
m_robotMap.rightFrontSteerMotor, m_robotMap.rightFrontWheelMotor,
|
||||
@@ -40,9 +38,6 @@ public class RobotContainer {
|
||||
m_robotMap.leftBackEncoder,
|
||||
m_robotMap.rightBackEncoder
|
||||
);
|
||||
*/
|
||||
private final Intake m_robotIntake = new Intake(m_robotMap.intakeMotor, m_robotMap.extenderMotor);
|
||||
private final Serializer m_robotSerializer = new Serializer(m_robotMap.serializerBelt, m_robotMap.serializerShooterBelt);
|
||||
|
||||
private final LED m_robotLED = new LED(m_robotMap.LEDController);
|
||||
|
||||
@@ -58,17 +53,12 @@ public class RobotContainer {
|
||||
|
||||
/* Default Commands */
|
||||
// drives the swerve drive with a two-axis input from the driver controller
|
||||
// m_robotSwerveDrive.setDefaultCommand(
|
||||
// new RunCommand(() -> m_robotSwerveDrive.driveWithInput(-getDriverController().getLeftXAxis(),
|
||||
// getDriverController().getLeftYAxis(), -getDriverController().getRightXAxis(), false), m_robotSwerveDrive));
|
||||
m_robotSwerveDrive.setDefaultCommand(
|
||||
new RunCommand(() -> m_robotSwerveDrive.driveWithInput(-getDriverController().getLeftXAxis(),
|
||||
getDriverController().getLeftYAxis(), -getDriverController().getRightXAxis(), false), m_robotSwerveDrive));
|
||||
|
||||
m_robotIntake.setDefaultCommand(
|
||||
new RunCommand(() -> m_robotIntake.runWithTriggers(
|
||||
getDriverController().getLeftTriggerAxis(), getDriverController().getRightTriggerAxis()),m_robotIntake));
|
||||
// continually sends updates to the Blinkin LED controller to keep the lights on
|
||||
m_robotLED.setDefaultCommand(
|
||||
new RunCommand(m_robotLED::updateLED, m_robotLED));
|
||||
// dri
|
||||
m_robotLED.setDefaultCommand(new RunCommand(m_robotLED::updateLED, m_robotLED));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,28 +69,12 @@ public class RobotContainer {
|
||||
*/
|
||||
private void configureButtonBindings() {
|
||||
/* Driver Buttons */
|
||||
|
||||
|
||||
/* Operator Buttons */
|
||||
|
||||
// extends and retracts the extender
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON)
|
||||
.whenPressed(() -> m_robotIntake.extendExtender(true))
|
||||
.whenReleased(() -> m_robotIntake.extendExtender(false));
|
||||
|
||||
// activates "Lit Mode"
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON)
|
||||
.whenPressed(() -> m_robotLED.setPattern(LEDPatterns.LAVA_RAINBOW))
|
||||
.whenReleased(() -> m_robotLED.setPattern(LEDConstants.DEFAULT_PATTERN));
|
||||
// revisit this later, not sure if we will still use this
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.B_BUTTON)
|
||||
.whenPressed(() -> m_robotSerializer.setSerializerStateWithBeam(true, m_robotSerializer.getBeam()))
|
||||
.whenReleased(() -> m_robotSerializer.setSerializerStateWithBeam(false, m_robotSerializer.getBeam()));
|
||||
|
||||
// new JoystickButton(getOperatorJoystick(), XboxController.Y_BUTTON)
|
||||
// .whenPressed(() -> m_robotIntake.extendExtender(true));
|
||||
|
||||
new JoystickButton(getOperatorJoystick(), XboxController.X_BUTTON)
|
||||
.whenPressed(() -> m_robotIntake.toggleExtender());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,14 +6,10 @@ package frc4388.robot;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
||||
import com.ctre.phoenix.sensors.CANCoder;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Spark;
|
||||
import frc4388.robot.Constants.IntakeConstants;
|
||||
import frc4388.robot.Constants.LEDConstants;
|
||||
import frc4388.robot.Constants.SerializerConstants;
|
||||
import frc4388.robot.Constants.SwerveDriveConstants;
|
||||
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
|
||||
|
||||
/**
|
||||
* Defines and holds all I/O objects on the Roborio. This is useful for unit
|
||||
@@ -23,7 +19,7 @@ public class RobotMap {
|
||||
|
||||
public RobotMap() {
|
||||
configureLEDMotorControllers();
|
||||
//configureSwerveMotorControllers();
|
||||
configureSwerveMotorControllers();
|
||||
}
|
||||
|
||||
/* LED Subsystem */
|
||||
@@ -33,7 +29,7 @@ public class RobotMap {
|
||||
|
||||
}
|
||||
|
||||
/* Swerve Subsystem
|
||||
/* Swerve Subsystem */
|
||||
public final WPI_TalonFX leftFrontSteerMotor = new WPI_TalonFX(SwerveDriveConstants.LEFT_FRONT_STEER_CAN_ID);
|
||||
public final WPI_TalonFX leftFrontWheelMotor = new WPI_TalonFX(SwerveDriveConstants.LEFT_FRONT_WHEEL_CAN_ID);
|
||||
public final WPI_TalonFX rightFrontSteerMotor = new WPI_TalonFX(SwerveDriveConstants.RIGHT_FRONT_STEER_CAN_ID);
|
||||
@@ -96,12 +92,4 @@ public class RobotMap {
|
||||
//rightBackSteerMotor.configRemoteFeedbackFilter(rightBackEncoder.getDeviceID(), RemoteSensorSource.CANCoder, SwerveDriveConstants.REMOTE_0, SwerveDriveConstants.SWERVE_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
/* Serializer Subsystem */
|
||||
|
||||
public final CANSparkMax serializerBelt = new CANSparkMax(SerializerConstants.SERIALIZER_BELT, MotorType.kBrushless);
|
||||
public final CANSparkMax serializerShooterBelt = new CANSparkMax(SerializerConstants.SERIALIZER_SHOOTER_BELT, MotorType.kBrushless);
|
||||
|
||||
/* Intake Subsytem */
|
||||
public final WPI_TalonFX intakeMotor = new WPI_TalonFX(IntakeConstants.INTAKE_MOTOR);
|
||||
public final CANSparkMax extenderMotor = new CANSparkMax(IntakeConstants.EXTENDER_MOTOR, MotorType.kBrushless);
|
||||
}
|
||||
|
||||
@@ -66,18 +66,26 @@ public double m_fireAngle;
|
||||
// m_angleAdjusterPIDController.setReference(targetAngle, ControlType.kPosition);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Runs The Hood
|
||||
* @param input The Speed Times 0.6
|
||||
*/
|
||||
public void runHood(double input) {
|
||||
input *= .6;
|
||||
m_angleAdjustMotor.set(input);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Resets The Encoder
|
||||
*/
|
||||
public void resetGyroAngleAdj(){
|
||||
m_angleEncoder.setPosition(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets The Encoders Position
|
||||
* @return The Encoders Position
|
||||
*/
|
||||
public double getAnglePositionPID() {
|
||||
return m_angleEncoder.getPosition();
|
||||
}
|
||||
|
||||
@@ -46,19 +46,28 @@ public class Intake extends SubsystemBase {
|
||||
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;
|
||||
extendExtender(toggle);
|
||||
runExtender(toggle);
|
||||
}
|
||||
//Test
|
||||
}
|
||||
@@ -23,29 +23,52 @@ public class Serializer extends SubsystemBase{
|
||||
m_serializerShooterBelt.set(0);
|
||||
|
||||
}
|
||||
/**
|
||||
* Gets The State Of The Beam
|
||||
* @return The State Of The Beam
|
||||
*/
|
||||
public boolean getBeam() {
|
||||
return m_serializerBeam.get();
|
||||
}
|
||||
public void setSerializerStateWithBeam(boolean ctrlbutter, boolean beambroken) {
|
||||
boolean total = ctrlbutter || beambroken;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -19,24 +19,42 @@ public class Storage extends SubsystemBase {
|
||||
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