Skip to content

Handle balls#23

Open
tnrz135 wants to merge 2 commits intomainfrom
handle-balls
Open

Handle balls#23
tnrz135 wants to merge 2 commits intomainfrom
handle-balls

Conversation

@tnrz135
Copy link
Contributor

@tnrz135 tnrz135 commented Aug 24, 2025

No description provided.

Comment on lines +17 to +24
/**
* 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
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an informative name instead of a comment


public class HandleBalls extends IntakeCommand {


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove one of the enters

SmartDashboard.putBoolean("isMacroSwitch", DigitalInputMap.getInstance().getValue(0));

if (index.isTeamsBallInSensor()) {
//if our team's ball is in front of the sensor activate the boolean

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need for a comment

if (DigitalInputMap.getInstance().getValue(0) || isBallInFunnel) {
isBallInFunnel = false;
SmartDashboard.putBoolean("isEvacuatingFromShooter", false);
//back direction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is uninformative and unnecessary

new RunFunnel(),
new RunRoller()
));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the unnecessary enter

));

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the "InsertIntoShooter" function Ctrl + Alt +L!

startTime = System.currentTimeMillis() / 1000.0;
}


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary enter

Comment on lines +15 to +17
public MoveBallUntilClick() {
super(new WaitUntilCommand(() -> DigitalInputMap.getInstance().getValue(0)), new RunRoller(),new RunFunnel());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl + Alt + L

}

public static class Swerve {
public static final double WHEEL_CIRC = 0.0517 * 2 * Math.PI; //very accurate right now

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment

Comment on lines +13 to +18
/**
* 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
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should optimize the readabilty of the code instead of writing a comment

Comment on lines +1 to +11
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.*;


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should drop any unnecessary spaces


/**
* @return the color that is in front of the sensor (as a DriverStation.Alliance enum)
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for a comment ( return is present)

Comment on lines +19 to +28

private static Indexing instance;
private ColorSensorV3 cs;
public DriverStation.Alliance alliance;

private Indexing() {
cs = new ColorSensorV3(I2C.Port.kOnboard);
alliance = DriverStation.getAlliance();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +51 to +53
/**
* @return true if enemy ball in front of the sensor
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should drop the comment

Comment on lines +51 to +69
/**
* @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;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete space

Comment on lines +18 to +26
// 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid writing the comments inside the functions or at all
image

}

private void initAmirButtons() {
//Indexing.getInstance().setDefaultCommand(new HandleBalls());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either delete the code or use it

Comment on lines +41 to +44
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a name that indicates the meaning of "a"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants