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

Shooterlights #114

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/java/com/team766/robot/reva/DriverOI.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class DriverOI extends OIFragment {
protected boolean isCross = false;

private final OICondition movingJoysticks;
private final OICondition isAtGoodSpeed;

private LaunchedContext visionContext;

Expand Down Expand Up @@ -57,6 +58,9 @@ public DriverOI(
+ Math.abs(leftJoystickY)
+ Math.abs(rightJoystickY)
> 0);
isAtGoodSpeed =
new OICondition(
() -> Robot.shooter.isCloseToExpectedSpeed() && Robot.shooter.isNotZero());
}

public void handleOI(Context context) {
Expand Down Expand Up @@ -95,20 +99,23 @@ public void handleOI(Context context) {
visionSpeakerHelper.update();

if (leftJoystick.getButtonPressed(InputConstants.BUTTON_TARGET_SHOOTER)) {

visionContext = context.startAsync(new DriverShootNow());

} else if (leftJoystick.getButtonReleased(InputConstants.BUTTON_TARGET_SHOOTER)) {
visionContext.stop();
context.takeOwnership(drive);
context.takeOwnership(intake);

Robot.lights.signalShotComplete();
Robot.intake.stop();
drive.stopDrive();

context.releaseOwnership(drive);
context.releaseOwnership(intake);
}
else if(isAtGoodSpeed.isNewlyTriggering()) {
Robot.lights.signalAtSpeed();
}

// Moves the robot if there are joystick inputs
if (movingJoysticks.isTriggering()) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/team766/robot/reva/mechanisms/Lights.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,19 @@ private boolean handleErrorCode(ErrorCode e) {

return false;
}

public boolean signalStartSpinup() {
ErrorCode e = m_candle.setLEDs(2, 245, 229);
return handleErrorCode(e);
}

public boolean signalAtSpeed() {
ErrorCode e = m_candle.setLEDs(172, 245, 2);
return handleErrorCode(e);
}

public boolean signalShotComplete() {
ErrorCode e = m_candle.setLEDs(0, 0, 0);
return handleErrorCode(e);
}
}
5 changes: 4 additions & 1 deletion src/main/java/com/team766/robot/reva/mechanisms/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public boolean isCloseToExpectedSpeed() {
&& (Math.abs(targetSpeed - getShooterSpeedBottom()) < SPEED_TOLERANCE));
}

public boolean isNotZero() {
return ((getShooterSpeedTop() <= SPEED_TOLERANCE) || (getShooterSpeedBottom() <= SPEED_TOLERANCE));
}

private double getShooterSpeedTop() {
return shooterMotorTop.getSensorVelocity();
}
Expand Down Expand Up @@ -94,7 +98,6 @@ public void run() {
}

// SmartDashboard.putBoolean("Shooter At Speed", isCloseToExpectedSpeed());

// FIXME: problem with this - does not pay attention to changes in PID values
// https://github.com/Team766/2024/pull/49 adds support to address this
// until then, this is equivalent to the earlier approach
Expand Down
Loading