This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aidan
committed
Feb 10, 2024
1 parent
2cad3f8
commit 1ffa7bd
Showing
7 changed files
with
130 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.conveyor; | ||
|
||
public enum ConveyorMode { | ||
IDLE, | ||
PASSING_NOTE, | ||
CONVEYORING, | ||
AMP_OUTTAKE, | ||
PASS_TO_INTAKE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.conveyor; | ||
|
||
import com.ctre.phoenix6.controls.MotionMagicVelocityDutyCycle; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import frc.robot.util.scheduling.LifecycleSubsystem; | ||
import frc.robot.util.scheduling.SubsystemPriority; | ||
|
||
public class ConveyorSubsystem extends LifecycleSubsystem { | ||
private final TalonFX motor; | ||
private final DigitalInput sensor; | ||
private MotionMagicVelocityDutyCycle velocityRequest = | ||
new MotionMagicVelocityDutyCycle(0.00).withSlot(0); | ||
|
||
private ConveyorMode goalMode = ConveyorMode.IDLE; | ||
private boolean hasNote = false; | ||
private double goalVelocity = 0.00; | ||
|
||
public ConveyorSubsystem(TalonFX motor, DigitalInput sensor) { | ||
super(SubsystemPriority.CONVEYOR); | ||
|
||
this.motor = motor; | ||
this.sensor = sensor; | ||
} | ||
|
||
@Override | ||
public void enabledPeriodic() { | ||
if (goalMode == ConveyorMode.IDLE) { | ||
motor.disable(); | ||
} else { | ||
velocityRequest.withVelocity(goalVelocity); | ||
} | ||
|
||
setHasNote(sensorHasNote()); | ||
} | ||
|
||
@Override | ||
public void robotPeriodic() { | ||
if (goalMode == ConveyorMode.AMP_OUTTAKE) { | ||
goalVelocity = 0.20; | ||
} else if (goalMode == ConveyorMode.CONVEYORING) { | ||
goalVelocity = 0.35; | ||
} else if (goalMode == ConveyorMode.PASSING_NOTE) { | ||
goalVelocity = 0.30; | ||
} else if (goalMode == ConveyorMode.PASS_TO_INTAKE) { | ||
goalVelocity = -0.30; | ||
} else { | ||
goalVelocity = 0.00; | ||
} | ||
} | ||
|
||
public void setMode(ConveyorMode mode) { | ||
goalMode = mode; | ||
} | ||
|
||
public ConveyorMode getMode() { | ||
return goalMode; | ||
} | ||
|
||
public boolean atGoal(ConveyorMode mode) { | ||
if (goalMode != mode) { | ||
return false; | ||
} | ||
if (goalMode == ConveyorMode.IDLE) { | ||
return true; | ||
} | ||
if (hasNote) { | ||
return true; | ||
} | ||
if (!hasNote && Math.abs(goalVelocity) > 0.00) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public void setHasNote(boolean bool) { | ||
hasNote = bool; | ||
} | ||
|
||
public boolean gethasNote() { | ||
return hasNote; | ||
} | ||
|
||
private boolean sensorHasNote() { | ||
return sensor.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ public enum SubsystemPriority { | |
LIGHTS(10), | ||
INTAKE(10), | ||
|
||
CONVEYOR(10), | ||
|
||
FMS(0), | ||
RUMBLE_CONTROLLER(0); | ||
|
||
|