Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Punk 2.0 #18

Closed
wants to merge 10 commits into from
Closed

Punk 2.0 #18

wants to merge 10 commits into from

Conversation

chenPerach
Copy link

@ori-coval - next time you ask for a CR at least create a PR for me to go through

@ori-coval ori-coval requested a review from noamgo March 2, 2024 10:50
Copy link
Member

@ori-coval ori-coval left a comment

Choose a reason for hiding this comment

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

Add ZeroShooterArm.

/** Creates a new TurnToDegree. */
SwerveSubsystem swerve = SwerveSubsystem.getInstance();
FeederSubsystem feeder = FeederSubsystem.getInstance();
TakeFeedSubsystem feeder = TakeFeedSubsystem.getInstance();
Copy link
Member

Choose a reason for hiding this comment

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

Why????

Copy link
Author

@chenPerach chenPerach left a comment

Choose a reason for hiding this comment

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

very good overall.
There are mostly documentation changes which I want you to implement.
grape🍇 - https://youtu.be/xOKBM16UFE4

public static final int driveCurrentThreshold = 60;
public static final double driveCurrentThresholdTime = 0.1;
public static final boolean driveEnableCurrentLimit = true;
public static final String CAN_BUS_NAME = "canBus";
Copy link
Author

Choose a reason for hiding this comment

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

I think it might be Important to change this to "canivor can-bus" or something similar.

Comment on lines 63 to +66

/** Center of the speaker opening (blue alliance) */
public static Pose2d centerSpeakerOpening = AllianceFlipUtil.apply(
new Pose2d(0.0, fieldWidth - Units.inchesToMeters(104.0), new Rotation2d()));
public static Pose2d centerSpeakerOpening =
new Pose2d(0.0, fieldWidth - Units.inchesToMeters(104.0), new Rotation2d());
Copy link
Author

Choose a reason for hiding this comment

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

hmm, maybe you can add a function called applyAllianceTranslation which will apply the AllianceFlipUtils::apply logic

Comment on lines +17 to +30
public ClimbSetSpeed(DoubleSupplier speed) {
addRequirements(climb);
this.speed = speed;
}

@Override
public void execute() {
climb.setSpeed(speed.getAsDouble());
}

@Override
public void end(boolean interrupted) {
climb.setSpeed(0);
}
Copy link
Author

Choose a reason for hiding this comment

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

where is finished?

is isFinished initialized to false by default?

@@ -29,7 +29,7 @@ public void initialize() {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
swerve.drive(new Translation2d(),0,true,true,true);
swerve.drive(new Translation2d(),0,true,false);
Copy link
Author

Choose a reason for hiding this comment

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

what the fuck does 0,true,false mean?

Is this command incomplete?

private final ShooterArmSubsystem shooterArm = ShooterArmSubsystem.getInstance();
double angle;

public ShooterArmMoveToAngle(double angle) {
Copy link
Author

Choose a reason for hiding this comment

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

Document what this function expects to get
And don't just say

@param angle is the expected angle of the subsystem

say something more descriptive like what are the expected units of this angle (degrees, radians or encoder ticks?)
this should be at moveArmTo function also.

These documentation changes will help the next rashatz in your position understand how to write code and your line of thought. so adding them is worth it.

Comment on lines +147 to +153
public double getUpShooterSpeed() {
return m_upShooterMotor.getVelocity().getValue();
}

public double getDownShooterSpeed() {
return m_downShooterMotor.getVelocity().getValue();
}
Copy link
Author

Choose a reason for hiding this comment

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

Again, think about it you are getting the velocity (angular, measured in ticks, radians or degrees...)
This is a small but meaningful change.

Comment on lines +155 to +158
public boolean checkIfShooterAtSpeed() {
return ((Math.abs(getUpShooterSpeed() - targetSpeed) < shooterConstants.MAX_ERROR)
&& ((Math.abs(getDownShooterSpeed() - targetSpeed) < shooterConstants.MAX_ERROR)));
}
Copy link
Author

Choose a reason for hiding this comment

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

maybe you should create a more generic form of this function

    public boolean checkIfShooterAtVelocity(double targetVelocity, double acceptableError) {
        return (Math.abs(getUpShooterVelocity() - targetVelocity) < acceptableError)
                && (Math.abs(getDownShooterVelocity() - targetVelocity) < acceptableError);
    }

and then use function overloading to create a simpler version:

    public boolean checkIfShooterAtVelocity() {
        return checkIfShooterAtVelocity(targetVelocity, shooterConstants.MAX_ERROR);
    }

&& ((Math.abs(getDownShooterSpeed() - targetSpeed) < shooterConstants.MAX_ERROR)));
}

public double speakerInterpolate() {
Copy link
Author

Choose a reason for hiding this comment

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

Looks good, just document that this function returns the expected velocity of the shooter.

Comment on lines +51 to +52
TalonFXConfiguration upConfigs = new TalonFXConfiguration();
TalonFXConfiguration downConfigs = new TalonFXConfiguration();
Copy link
Author

Choose a reason for hiding this comment

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

Fuck CTRE for not giving you a better way to statically create a configuration in the constants file.

private TalonFX m_shooterArmMotor;
DigitalInput limitSwitch = new DigitalInput(SwitchID);
DigitalInput limitSwitch = new DigitalInput(shooterArmConstants.SWITCH_ID);
Copy link
Author

Choose a reason for hiding this comment

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

Can't stress enough how much this micro switch could not be trusted.

Make sure that if this switch breaks you still have some sort of fall back which makes sure the subsystem does not break.

@chenPerach chenPerach assigned chenPerach and ori-coval and unassigned chenPerach Mar 3, 2024
@chenPerach chenPerach marked this pull request as draft March 3, 2024 05:47
@PrimoSoftwarePC PrimoSoftwarePC deleted the PUNK-2.0 branch March 6, 2024 04:14
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