-
Notifications
You must be signed in to change notification settings - Fork 0
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
Shooter pull request #7
Open
amrrao
wants to merge
3
commits into
main
Choose a base branch
from
shooter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 20 additions & 0 deletions
20
src/main/java/org/usfirst/frc4904/robot/commands/FlywheelOff.java
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,20 @@ | ||
package org.usfirst.frc4904.robot.commands; | ||
|
||
import org.usfirst.frc4904.robot.RobotMap; | ||
import org.usfirst.frc4904.robot.subsystems.Flywheel; | ||
|
||
public class FlywheelOff extends FlywheelSetSpeed { | ||
|
||
/** | ||
* Set flywheel speed to zero | ||
* | ||
* @param flywheel The flywheel to manipulate | ||
*/ | ||
public FlywheelOff(Flywheel flywheel) { | ||
super(flywheel, 0.0); | ||
} | ||
|
||
public FlywheelOff() { | ||
super(RobotMap.Component.shooter, 0.0); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, you should leave a newline at the end of your file. |
22 changes: 22 additions & 0 deletions
22
src/main/java/org/usfirst/frc4904/robot/commands/FlywheelSetSpeed.java
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,22 @@ | ||
package org.usfirst.frc4904.robot.commands; | ||
|
||
import org.usfirst.frc4904.robot.RobotMap; | ||
import org.usfirst.frc4904.robot.subsystems.Flywheel; | ||
import org.usfirst.frc4904.standard.commands.motor.MotorVelocitySet; | ||
|
||
public class FlywheelSetSpeed extends MotorVelocitySet { | ||
|
||
/** | ||
* Spin up the flywheel to a speed | ||
* | ||
* @param flywheel The flywheel to manipulate | ||
* @param speed The speed to spin the flywheel up to | ||
*/ | ||
public FlywheelSetSpeed(Flywheel flywheel, double speed) { | ||
super("FlywheelMaintainSpeed", flywheel, speed); | ||
} | ||
|
||
public FlywheelSetSpeed(double speed) { | ||
this(RobotMap.Component.shooter, speed); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above comment |
115 changes: 115 additions & 0 deletions
115
src/main/java/org/usfirst/frc4904/robot/subsystems/Flywheel.java
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,115 @@ | ||
package org.usfirst.frc4904.robot.subsystems; | ||
|
||
import edu.wpi.first.wpilibj.motorcontrol.MotorController; | ||
|
||
import org.usfirst.frc4904.standard.custom.motioncontrollers.MotionController; | ||
import org.usfirst.frc4904.standard.subsystems.motor.VelocitySensorMotor; | ||
import org.usfirst.frc4904.standard.subsystems.motor.speedmodifiers.IdentityModifier; | ||
import org.usfirst.frc4904.standard.subsystems.motor.speedmodifiers.SpeedModifier; | ||
|
||
/** | ||
* Flywheel Base Class | ||
* | ||
* ! This class does not include a piston, use Shooter.java for the 2020-season | ||
* ! specific flywheel subsystem. | ||
* | ||
* This class is designed to go into standard, eventually. | ||
*/ | ||
public class Flywheel extends VelocitySensorMotor { | ||
public static enum FlywheelStatus { | ||
IDLE, SPINNING_UP, AT_SPEED | ||
} | ||
|
||
protected FlywheelStatus currentStatus = FlywheelStatus.IDLE; | ||
protected double targetSpeed = 0.0; | ||
|
||
/** | ||
* Flywheel constructor - extends VelocitySensorMotor | ||
* motionController.absoluteTolerance should be set. | ||
* | ||
* @param name The name of the flywheel | ||
* @param SpeedModifier The speedModifier | ||
* @param motionController The motionController | ||
* @param motors Motors to control | ||
*/ | ||
public Flywheel(String name, SpeedModifier speedModifier, MotionController motionController, | ||
MotorController... motors) { | ||
super(name, speedModifier, motionController, motors); | ||
// super.enableMotionController(); | ||
} | ||
|
||
/** | ||
* Flywheel constructor - extends VelocitySensorMotor | ||
* | ||
* @param SpeedModifier The speedModifier | ||
* @param motionController The motionController | ||
* @param motors Motors to control | ||
*/ | ||
public Flywheel(SpeedModifier speedModifier, MotionController motionController, MotorController... motors) { | ||
this("Flywheel", speedModifier, motionController, motors); | ||
} | ||
|
||
/** | ||
* Flywheel constructor - extends VelocitySensorMotor | ||
* | ||
* @param name The name of the flywheel | ||
* @param motionController The motionController | ||
* @param motors Motors to control | ||
*/ | ||
public Flywheel(String name, MotionController motionController, MotorController... motors) { | ||
this(name, new IdentityModifier(), motionController, motors); | ||
} | ||
|
||
/** | ||
* Flywheel constructor - extends VelocitySensorMotor | ||
* | ||
* @param motionController The motionController | ||
* @param motors Motors to control | ||
*/ | ||
public Flywheel(MotionController motionController, MotorController... motors) { | ||
this("Flywheel", motionController, motors); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
syncStatus(); | ||
} | ||
|
||
protected void syncStatus() { | ||
// TODO:// Infinitely idle? | ||
if (Math.abs(targetSpeed) < motionController.getAbsoluteTolerance() || currentStatus == FlywheelStatus.IDLE) { | ||
currentStatus = FlywheelStatus.IDLE; | ||
return; | ||
} | ||
if (motionController.onTarget()) { | ||
currentStatus = FlywheelStatus.AT_SPEED; | ||
} else { | ||
currentStatus = FlywheelStatus.SPINNING_UP; | ||
} | ||
} | ||
|
||
public FlywheelStatus getStatus() { | ||
return currentStatus; | ||
} | ||
|
||
public double getVelocity() { | ||
return motionController.getSensorValue(); | ||
} | ||
|
||
public double getTargetVelocity() { | ||
return targetSpeed; | ||
} | ||
|
||
public void setVelocity() { | ||
super.set(targetSpeed); | ||
} | ||
|
||
public void setVelocity(double speed) { | ||
targetSpeed = speed; | ||
setVelocity(); | ||
} | ||
|
||
public MotionController getMC() { | ||
return motionController; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vaguely concerning, but as long as it's good I guess that's fine.