Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Format with Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanknj5 committed Aug 29, 2023
1 parent d0b08ae commit 2ace78d
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 588 deletions.
13 changes: 7 additions & 6 deletions src/main/java/frc/robot/intake/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package frc.robot.intake;

import com.revrobotics.*;

import edu.wpi.first.math.filter.LinearFilter;
import frc.robot.util.scheduling.LifecycleSubsystem;
import frc.robot.util.scheduling.SubsystemPriority;
Expand All @@ -15,7 +14,7 @@
public class IntakeSubsystem extends LifecycleSubsystem {
private final LinearFilter voltageFilter = LinearFilter.movingAverage(7);
private final LinearFilter velocityFilter = LinearFilter.movingAverage(7);
//7 is a placeholder not tuned
// 7 is a placeholder not tuned
private final CANSparkMax motor;
private final RelativeEncoder encoder;
private IntakeState goalState;
Expand All @@ -36,7 +35,8 @@ public void setGoalState(IntakeState intakeState) {

goalState = intakeState;
}
@Override

@Override
public void robotPeriodic() {
Logger.getInstance().recordOutput("Intake/State", goalState.toString());
Logger.getInstance().recordOutput("Intake/HeldGamePiece", gamePiece.toString());
Expand Down Expand Up @@ -66,18 +66,19 @@ public void enabledPeriodic() {
// Game piece detection
double motorVelocity = velocityFilter.calculate(encoder.getVelocity());
double intakeVoltage = voltageFilter.calculate(motor.getAppliedOutput()) * 12.0;
double theoreticalSpeed = intakeVoltage * (5700.0/12.0); //Neo Max is 5700
double theoreticalSpeed = intakeVoltage * (5700.0 / 12.0); // Neo Max is 5700
double threshold = theoreticalSpeed * 0.5;
if (motorVelocity < threshold && goalState == IntakeState.INTAKE_CONE) {
gamePiece = HeldGamePiece.CONE;
} else if (motorVelocity < threshold && goalState == IntakeState.INTAKE_CUBE) {
gamePiece = HeldGamePiece.CUBE;
} else if (motorVelocity > threshold && (goalState == IntakeState.OUTTAKE_CONE || goalState == IntakeState.OUTTAKE_CUBE)) {
} else if (motorVelocity > threshold
&& (goalState == IntakeState.OUTTAKE_CONE || goalState == IntakeState.OUTTAKE_CUBE)) {
gamePiece = HeldGamePiece.NOTHING;
}
}

public IntakeState getIntakeState(){
public IntakeState getIntakeState() {
return goalState;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/lights/BlinkPattern.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// 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.lights;

public enum BlinkPattern {
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/frc/robot/lights/LightsSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package frc.robot.lights;
// 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.lights;

import com.ctre.phoenix.led.CANdle;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.util.Color;
Expand All @@ -15,12 +17,11 @@
import frc.robot.util.scheduling.LifecycleSubsystem;
import frc.robot.util.scheduling.SubsystemPriority;

public class LightsSubsystem extends LifecycleSubsystem{
public class LightsSubsystem extends LifecycleSubsystem {

private static final double FAST_BLINK_DURATION = 0.08;
private static final double SLOW_BLINK_DURATION = 0.25;


private final CANdle candle;
private final IntakeSubsystem intake;
private final SuperstructureManager superstructure;
Expand All @@ -31,16 +32,14 @@ public class LightsSubsystem extends LifecycleSubsystem{
private BlinkPattern blinkPattern = BlinkPattern.SOLID;

public LightsSubsystem(
CANdle candle,
IntakeSubsystem intake,
SuperstructureManager superstructure
) {
CANdle candle, IntakeSubsystem intake, SuperstructureManager superstructure) {
super(SubsystemPriority.LIGHTS);
this.candle = candle;
this.intake = intake;
this.superstructure = superstructure;
}
public void enabledPeriodic(){

public void enabledPeriodic() {
HeldGamePiece gamePiece = intake.getGamePiece();
IntakeState intakeMode = intake.getIntakeState();
HeldGamePiece superstructureMode = superstructure.getMode();
Expand All @@ -53,7 +52,7 @@ public void enabledPeriodic(){
color = Color.kBlue;
blinkPattern = BlinkPattern.SOLID;
}
}else if (gamePiece == HeldGamePiece.CUBE) {
} else if (gamePiece == HeldGamePiece.CUBE) {
if (intakeMode == IntakeState.INTAKE_CUBE) {
color = Color.kPurple;
blinkPattern = BlinkPattern.BLINK_FAST;
Expand Down Expand Up @@ -103,10 +102,5 @@ public void enabledPeriodic(){
candle.setLEDs(color8Bit.red, color8Bit.green, color8Bit.blue);
}
}


}



}
44 changes: 28 additions & 16 deletions src/main/java/frc/robot/managers/superstructure/Positions.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,34 @@
import edu.wpi.first.math.geometry.Rotation2d;

public class Positions {
public static final SuperstructurePosition STOWED = new SuperstructurePosition(Rotation2d.fromDegrees(0), Rotation2d.fromDegrees(0));

public static final SuperstructurePosition INTAKING_CUBE_FLOOR = new SuperstructurePosition(Rotation2d.fromDegrees(20), Rotation2d.fromDegrees(135));
public static final SuperstructurePosition INTAKING_CUBE_SHELF = new SuperstructurePosition(Rotation2d.fromDegrees(90), Rotation2d.fromDegrees(180));

public static final SuperstructurePosition CUBE_NODE_LOW = new SuperstructurePosition(Rotation2d.fromDegrees(-20), Rotation2d.fromDegrees(-135));
public static final SuperstructurePosition CUBE_NODE_MID = new SuperstructurePosition(Rotation2d.fromDegrees(-75), Rotation2d.fromDegrees(-190));
public static final SuperstructurePosition CUBE_NODE_HIGH = new SuperstructurePosition(Rotation2d.fromDegrees(-100), Rotation2d.fromDegrees(-190));

public static final SuperstructurePosition INTAKING_CONE_FLOOR = new SuperstructurePosition(Rotation2d.fromDegrees(20), Rotation2d.fromDegrees(135));
public static final SuperstructurePosition INTAKING_CONE_SHELF = new SuperstructurePosition(Rotation2d.fromDegrees(90), Rotation2d.fromDegrees(180));
public static final SuperstructurePosition INTAKING_CONE_SINGLE_SUBSTATION = new SuperstructurePosition(Rotation2d.fromDegrees(0), Rotation2d.fromDegrees(30));

public static final SuperstructurePosition CONE_NODE_LOW = new SuperstructurePosition(Rotation2d.fromDegrees(-20), Rotation2d.fromDegrees(-135));
public static final SuperstructurePosition CONE_NODE_MID = new SuperstructurePosition(Rotation2d.fromDegrees(-75), Rotation2d.fromDegrees(-190));
public static final SuperstructurePosition CONE_NODE_HIGH = new SuperstructurePosition(Rotation2d.fromDegrees(-100), Rotation2d.fromDegrees(-190));
public static final SuperstructurePosition STOWED =
new SuperstructurePosition(Rotation2d.fromDegrees(0), Rotation2d.fromDegrees(0));

public static final SuperstructurePosition INTAKING_CUBE_FLOOR =
new SuperstructurePosition(Rotation2d.fromDegrees(20), Rotation2d.fromDegrees(135));
public static final SuperstructurePosition INTAKING_CUBE_SHELF =
new SuperstructurePosition(Rotation2d.fromDegrees(90), Rotation2d.fromDegrees(180));

public static final SuperstructurePosition CUBE_NODE_LOW =
new SuperstructurePosition(Rotation2d.fromDegrees(-20), Rotation2d.fromDegrees(-135));
public static final SuperstructurePosition CUBE_NODE_MID =
new SuperstructurePosition(Rotation2d.fromDegrees(-75), Rotation2d.fromDegrees(-190));
public static final SuperstructurePosition CUBE_NODE_HIGH =
new SuperstructurePosition(Rotation2d.fromDegrees(-100), Rotation2d.fromDegrees(-190));

public static final SuperstructurePosition INTAKING_CONE_FLOOR =
new SuperstructurePosition(Rotation2d.fromDegrees(20), Rotation2d.fromDegrees(135));
public static final SuperstructurePosition INTAKING_CONE_SHELF =
new SuperstructurePosition(Rotation2d.fromDegrees(90), Rotation2d.fromDegrees(180));
public static final SuperstructurePosition INTAKING_CONE_SINGLE_SUBSTATION =
new SuperstructurePosition(Rotation2d.fromDegrees(0), Rotation2d.fromDegrees(30));

public static final SuperstructurePosition CONE_NODE_LOW =
new SuperstructurePosition(Rotation2d.fromDegrees(-20), Rotation2d.fromDegrees(-135));
public static final SuperstructurePosition CONE_NODE_MID =
new SuperstructurePosition(Rotation2d.fromDegrees(-75), Rotation2d.fromDegrees(-190));
public static final SuperstructurePosition CONE_NODE_HIGH =
new SuperstructurePosition(Rotation2d.fromDegrees(-100), Rotation2d.fromDegrees(-190));

private Positions() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setMode(HeldGamePiece mode) {
this.mode = mode;
}

public HeldGamePiece getMode(){
public HeldGamePiece getMode() {
return mode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public SuperstructureMotionManager(WristSubsystem shoulder, WristSubsystem wrist
}

public boolean atPosition(SuperstructurePosition position) {
return shoulder.atAngle(position.shoulderAngle)
&& wrist.atAngle(position.wristAngle);
return shoulder.atAngle(position.shoulderAngle) && wrist.atAngle(position.wristAngle);
}

public void set(SuperstructurePosition newGoalPosition) {
Expand Down
41 changes: 22 additions & 19 deletions src/main/java/frc/robot/shoulder/ShoulderSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package frc.robot.shoulder;
// 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.

import org.littletonrobotics.junction.Logger;
package frc.robot.shoulder;

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMax.ControlType;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkMaxPIDController;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.util.scheduling.LifecycleSubsystem;
import frc.robot.util.scheduling.SubsystemPriority;
import org.littletonrobotics.junction.Logger;

public class ShoulderSubsystem extends LifecycleSubsystem {
private final CANSparkMax motor;
Expand Down Expand Up @@ -43,22 +45,24 @@ public void enabledPeriodic() {
pid.setReference(goalAngle.getRotations(), ControlType.kSmartMotion);
}

@Override
public void robotPeriodic(){
Logger.getInstance().recordOutput("Shoulder/MainMotor/Velocity", encoder.getVelocity());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/Velocity", encoder.getVelocity());
Logger.getInstance().recordOutput("Shoulder/MainMotor/Angle", getWristAngle().getDegrees());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/Angle", getWristAngle().getDegrees());
Logger.getInstance().recordOutput("Shoulder/MainMotor/GoalAngle", goalAngle.getDegrees());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/GoalAngle", goalAngle.getDegrees());
Logger.getInstance().recordOutput("Shoulder/MainMotor/DutyCycleOutput", motor.getAppliedOutput());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/DutyCycleOutput", motor.getAppliedOutput());
Logger.getInstance().recordOutput("Shoulder/MainMotor/StatorCurrent", motor.getOutputCurrent());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/StatorCurrent", motor.getOutputCurrent());

}
@Override
public void robotPeriodic() {
Logger.getInstance().recordOutput("Shoulder/MainMotor/Velocity", encoder.getVelocity());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/Velocity", encoder.getVelocity());
Logger.getInstance().recordOutput("Shoulder/MainMotor/Angle", getWristAngle().getDegrees());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/Angle", getWristAngle().getDegrees());
Logger.getInstance().recordOutput("Shoulder/MainMotor/GoalAngle", goalAngle.getDegrees());
Logger.getInstance().recordOutput("Shoulder/FollowerMotor/GoalAngle", goalAngle.getDegrees());
Logger.getInstance()
.recordOutput("Shoulder/MainMotor/DutyCycleOutput", motor.getAppliedOutput());
Logger.getInstance()
.recordOutput("Shoulder/FollowerMotor/DutyCycleOutput", motor.getAppliedOutput());
Logger.getInstance().recordOutput("Shoulder/MainMotor/StatorCurrent", motor.getOutputCurrent());
Logger.getInstance()
.recordOutput("Shoulder/FollowerMotor/StatorCurrent", motor.getOutputCurrent());
}

public void set(Rotation2d angle) {
public void set(Rotation2d angle) {
goalAngle = angle;
}

Expand All @@ -78,4 +82,3 @@ private Rotation2d getWristAngle() {
return Rotation2d.fromRotations(encoder.getPosition());
}
}

7 changes: 5 additions & 2 deletions src/main/java/frc/robot/wrist/WristSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// 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.wrist;
import org.littletonrobotics.junction.Logger;

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMax.ControlType;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkMaxPIDController;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.util.scheduling.LifecycleSubsystem;
import frc.robot.util.scheduling.SubsystemPriority;
import org.littletonrobotics.junction.Logger;

public class WristSubsystem extends LifecycleSubsystem {
private final CANSparkMax motor;
Expand Down
Loading

0 comments on commit 2ace78d

Please sign in to comment.