Conversation
| /** | ||
| * this command checks if an enemy ball is trying to enter the Funnel, | ||
| * and if so it is rejecting it from entering the funnel system using a | ||
| * color sensor to check the color | ||
| * | ||
| * @see com.revrobotics.ColorSensorV3 colorSensor. | ||
| * @see Indexing Subsystem | ||
| */ |
There was a problem hiding this comment.
use an informative name instead of a comment
|
|
||
| public class HandleBalls extends IntakeCommand { | ||
|
|
||
|
|
| SmartDashboard.putBoolean("isMacroSwitch", DigitalInputMap.getInstance().getValue(0)); | ||
|
|
||
| if (index.isTeamsBallInSensor()) { | ||
| //if our team's ball is in front of the sensor activate the boolean |
There was a problem hiding this comment.
Remove the comment, the name is informative enough
| isBallInFunnel = true; | ||
| } | ||
| if (DigitalInputMap.getInstance().getValue(0)) { | ||
| //if the ball got to the macroSwitch then disable the boolean |
There was a problem hiding this comment.
there is no need for a comment
| if (DigitalInputMap.getInstance().getValue(0) || isBallInFunnel) { | ||
| isBallInFunnel = false; | ||
| SmartDashboard.putBoolean("isEvacuatingFromShooter", false); | ||
| //back direction |
There was a problem hiding this comment.
the comment is uninformative and unnecessary
| new RunFunnel(), | ||
| new RunRoller() | ||
| )); | ||
|
|
| )); | ||
|
|
||
| } | ||
|
|
There was a problem hiding this comment.
for the "InsertIntoShooter" function Ctrl + Alt +L!
| startTime = System.currentTimeMillis() / 1000.0; | ||
| } | ||
|
|
||
|
|
| public MoveBallUntilClick() { | ||
| super(new WaitUntilCommand(() -> DigitalInputMap.getInstance().getValue(0)), new RunRoller(),new RunFunnel()); | ||
| } |
| } | ||
|
|
||
| public static class Swerve { | ||
| public static final double WHEEL_CIRC = 0.0517 * 2 * Math.PI; //very accurate right now |
| /** | ||
| * This class is in-charge of checking if an enemy ball is trying to get to the funnel (and eventually to the shooter) | ||
| * by using color sensor | ||
| * | ||
| * @see ColorSensorV3 colorSensorV3 | ||
| */ |
There was a problem hiding this comment.
you should optimize the readabilty of the code instead of writing a comment
| package edu.greenblitz.pegasus.subsystems; | ||
|
|
||
| import com.revrobotics.ColorSensorV3; | ||
| import edu.greenblitz.GBLib.src.main.java.edu.greenblitz.gblib.subsystems.GBSubsystem; | ||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj.I2C; | ||
| import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
|
||
| import java.awt.*; | ||
|
|
||
|
|
There was a problem hiding this comment.
should drop any unnecessary spaces
|
|
||
| /** | ||
| * @return the color that is in front of the sensor (as a DriverStation.Alliance enum) | ||
| */ |
There was a problem hiding this comment.
no need for a comment ( return is present)
|
|
||
| private static Indexing instance; | ||
| private ColorSensorV3 cs; | ||
| public DriverStation.Alliance alliance; | ||
|
|
||
| private Indexing() { | ||
| cs = new ColorSensorV3(I2C.Port.kOnboard); | ||
| alliance = DriverStation.getAlliance(); | ||
| } | ||
|
|
There was a problem hiding this comment.
should change the "cs" object into colorSensor
https://cdn.akamai.steamstatic.com/apps/csgo/images/csgo_react/social/cs2.jpg
| /** | ||
| * @return true if enemy ball in front of the sensor | ||
| */ |
| /** | ||
| * @return true if enemy ball in front of the sensor | ||
| */ | ||
| public boolean isEnemyBallInSensor() { | ||
| DriverStation.Alliance a = instance.getBallColor(); | ||
| SmartDashboard.putString("color", a.toString()); | ||
| return a != alliance | ||
| && a != DriverStation.Alliance.Invalid; | ||
| } | ||
|
|
||
| /** | ||
| * @return true is our team's ball is in front of the sensor. | ||
| */ | ||
| public boolean isTeamsBallInSensor() { | ||
| DriverStation.Alliance a = instance.getBallColor(); | ||
| SmartDashboard.putString("color", a.toString()); | ||
| return a == alliance | ||
| && a != DriverStation.Alliance.Invalid; | ||
| } |
There was a problem hiding this comment.
could merge both functions into one and change the receiving logic
| public void moveMotor(boolean reversed) { | ||
| moveMotor(reversed ? RobotMap.Pegasus.Funnel.REVERSE_POWER : RobotMap.Pegasus.Funnel.POWER); | ||
| } | ||
|
|
| // AKA InsertoShooter @tal935 | ||
| public InsertIntoShooter() { | ||
| addCommands( | ||
| new MoveBallUntilClick(), | ||
|
|
||
| //waits until the shooter is ready | ||
| new WaitUntilCommand(() -> Shooter.getInstance().isPreparedToShoot()), | ||
|
|
||
| new ParallelDeadlineGroup(//activates both roller and funnel until ball is no longer at macro switch (was probably propelled) |
| } | ||
|
|
||
| private void initAmirButtons() { | ||
| //Indexing.getInstance().setDefaultCommand(new HandleBalls()); |
There was a problem hiding this comment.
either delete the code or use it
| float[] color = Color.RGBtoHSB(cs.getRed(), cs.getGreen(), cs.getBlue(), new float[3]); | ||
| if (color[0] >= 0.05 && color[0] <= 0.2) { | ||
| return DriverStation.Alliance.Red; | ||
| } else if (color[0] >= 0.4 && color[0] < 0.6) { |
There was a problem hiding this comment.
use variables/constants instead of random numbers thrown in the code without an exact meaning
| * @return true if enemy ball in front of the sensor | ||
| */ | ||
| public boolean isEnemyBallInSensor() { | ||
| DriverStation.Alliance a = instance.getBallColor(); |
There was a problem hiding this comment.
use a name that indicates the meaning of "a"

No description provided.