-
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
Added base shooter class #19
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dda6bca
Added base shooter class
Tsunami014 2bbee83
added motors configuration aswell as the set speed and rotation
fotnitfpro000 b19a013
imported shooter component to robot.py and made an injecting button i…
fotnitfpro000 8438952
Merge branch 'main' into ShooterComponent
fotnitfpro000 58cd673
removed motor speeds feedback method
fotnitfpro000 edbaf74
Merge branch 'ShooterComponent' of https://github.com/thedropbears/py…
fotnitfpro000 af0948c
removed inject method and deployed variable
fotnitfpro000 7b4b59e
renamed variable voltsge_request to flywheel_request
fotnitfpro000 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from magicbot import tunable | ||
from rev import CANSparkMax | ||
from ids import SparkMaxIds, TalonIds | ||
import phoenix6 | ||
from phoenix6.configs import ( | ||
config_groups, | ||
MotorOutputConfigs, | ||
) | ||
from phoenix6.controls import VoltageOut | ||
import phoenix6.hardware | ||
|
||
|
||
class Shooter: | ||
flywheel_speed = tunable(0.0) | ||
inject_speed = tunable(0.0) | ||
|
||
def __init__(self): | ||
self.top_flywheel = phoenix6.hardware.TalonFX(TalonIds.top_flywheel) | ||
self.bottom_flywheel = phoenix6.hardware.TalonFX(TalonIds.bottom_flywheel) | ||
self.inject_flywheel = CANSparkMax( | ||
SparkMaxIds.inject_flywheel, CANSparkMax.MotorType.kBrushless | ||
) | ||
|
||
# Configure bottom flywheel motor | ||
bottom_config = self.bottom_flywheel.configurator | ||
bottom_flywheel_config = MotorOutputConfigs() | ||
bottom_flywheel_config.inverted = config_groups.InvertedValue.CLOCKWISE_POSITIVE | ||
|
||
bottom_config.apply(bottom_flywheel_config) | ||
|
||
self.inject_flywheel.setInverted(True) | ||
|
||
self.should_inject = False | ||
|
||
def shoot(self): | ||
self.should_inject = True | ||
|
||
def is_ready(self): | ||
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. I think we should make these so-called "feedback" functions with feedback decorators from magicbot e.g. |
||
return True | ||
|
||
def execute(self): | ||
"""This gets called at the end of the control loop""" | ||
flywheel_request = VoltageOut(12.0 * self.flywheel_speed) | ||
if self.should_inject: | ||
self.inject_flywheel.set(self.inject_speed) | ||
else: | ||
self.inject_flywheel.set(0.0) | ||
|
||
self.top_flywheel.set_control(flywheel_request) | ||
self.bottom_flywheel.set_control(flywheel_request) | ||
self.should_inject = False |
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
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.
I think it's safe to say we need more feedback methods.
I'm thinking of two feedback methods: