Skip to content

Handle balls 2#24

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

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

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
*/
Copy link

Choose a reason for hiding this comment

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

not comments, the command name should say that instead.

@Override
public void execute() {
SmartDashboard.putBoolean("isBallInFunnel", isBallInFunnel);
SmartDashboard.putBoolean("isEnemyBallUnSensor", index.isEnemyBallInSensor());
Copy link

Choose a reason for hiding this comment

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

Suggested change
SmartDashboard.putBoolean("isEnemyBallUnSensor", index.isEnemyBallInSensor());
SmartDashboard.putBoolean("isEnemyBallInSensor", index.isEnemyBallInSensor());

change the original name too, cause uh you have atypo

isBallInFunnel = false;
}

if (index.isEnemyBallInSensor()) {
Copy link

Choose a reason for hiding this comment

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

you said team's
so follow the same suit with enemy's for this.

Suggested change
if (index.isEnemyBallInSensor()) {
if (index.isEnemysBallInSensor()) {

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

Choose a reason for hiding this comment

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

remove commit, your code should speak for itself.

Suggested change
//back direction

new ReverseRunFunnel().raceWith(new WaitCommand(0.2))
).andThen(new RunFunnel().until(() -> DigitalInputMap.getInstance().getValue(0))).schedule(false);
} else {
//shooter evacuation
Copy link

Choose a reason for hiding this comment

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

remove comment, your code should speak for itself.

Suggested change
//shooter evacuation

import edu.wpi.first.wpilibj2.command.ParallelRaceGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;

public class EjectEnemyBallFromGripper extends ParallelRaceGroup { //todo can be deadline
Copy link

@rys4590 rys4590 Aug 24, 2025

Choose a reason for hiding this comment

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

No todo :D
decide if its deadline or not, and change accordingly, then delete comment.

public class EjectEnemyBallFromGripper extends ParallelRaceGroup { //todo can be deadline
public EjectEnemyBallFromGripper() {
addCommands(
new WaitCommand(1.5),
Copy link

Choose a reason for hiding this comment

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

what does the number represent? Use a const.

} else {
//shooter evacuation
SmartDashboard.putBoolean("isEvacuatingFromShooter", true);
new ShooterEvacuate().raceWith(new WaitCommand(5)).schedule(false);
Copy link

Choose a reason for hiding this comment

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

what does the number represent? const instead please.

new ParallelDeadlineGroup(
new WaitCommand(0.5),
new ReverseRunRoller(),
new ReverseRunFunnel().raceWith(new WaitCommand(0.2))
Copy link

Choose a reason for hiding this comment

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

what do these number represent?
use a const instead.

SmartDashboard.putBoolean("isEvacuatingFromShooter", false);
//back direction
new ParallelDeadlineGroup(
new WaitCommand(0.5),
Copy link

Choose a reason for hiding this comment

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

what does the number represent? use a const.

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
*/
Copy link

Choose a reason for hiding this comment

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

Remove comments

Suggested change
/**
* 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
*/

Comment on lines +37 to +39
/**
* @return the color that is in front of the sensor (as a DriverStation.Alliance enum)
*/
Copy link

Choose a reason for hiding this comment

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

Remove comments

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

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

Choose a reason for hiding this comment

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

Remove comments

Suggested change
/**
* @return true if enemy ball in front of the sensor
*/

Comment on lines +61 to +63
/**
* @return true is our team's ball is in front of the sensor.
*/
Copy link

Choose a reason for hiding this comment

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

Remove comments

Suggested change
/**
* @return true is our team's ball is in front of the sensor.
*/

* @return true is our team's ball is in front of the sensor.
*/
public boolean isTeamsBallInSensor() {
DriverStation.Alliance a = instance.getBallColor();
Copy link

Choose a reason for hiding this comment

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

Name is not informative
Use a better name for it

import edu.wpi.first.wpilibj2.command.ParallelRaceGroup;
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;

public class EjectFromShooter extends ParallelRaceGroup {//todo delete
Copy link

Choose a reason for hiding this comment

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

Remove comments

Suggested change
public class EjectFromShooter extends ParallelRaceGroup {//todo delete
public class EjectFromShooter extends ParallelRaceGroup {

addCommands(
new MoveBallUntilClick(),

//waits until the shooter is ready
Copy link

Choose a reason for hiding this comment

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

Remove comments

Suggested change
//waits until the shooter is ready

//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)
Copy link

@Dolev3 Dolev3 Aug 24, 2025

Choose a reason for hiding this comment

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

Remove comments

Suggested change
new ParallelDeadlineGroup(//activates both roller and funnel until ball is no longer at macro switch (was probably propelled)
new ParallelDeadLineGroup(

@Override
public void initialize() {
super.initialize();
startTime = System.currentTimeMillis() / 1000.0;
Copy link

Choose a reason for hiding this comment

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

Use constants

Comment on lines +42 to +44
if (color[0] >= 0.05 && color[0] <= 0.2) {
return DriverStation.Alliance.Red;
} else if (color[0] >= 0.4 && color[0] < 0.6) {
Copy link

Choose a reason for hiding this comment

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

constants

Suggested change
if (color[0] >= 0.05 && color[0] <= 0.2) {
return DriverStation.Alliance.Red;
} else if (color[0] >= 0.4 && color[0] < 0.6) {
if (color[0] >= constant1 && color[0] <= constant2) {
return DriverStation.Alliance.Red;
} else if (color[0] >= constant3 && color[0] < constant4) {

}

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

Choose a reason for hiding this comment

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

no numbers, please replace with matching consts.

Comment on lines +41 to +47
if (index.isTeamsBallInSensor()) {
//if our team's ball is in front of the sensor activate the boolean
isBallInFunnel = true;
}
if (DigitalInputMap.getInstance().getValue(0)) {
//if the ball got to the macroSwitch then disable the boolean
isBallInFunnel = false;
Copy link

Choose a reason for hiding this comment

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

perhaps split into functions, so we can know what each part does without any comments.

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