-
Notifications
You must be signed in to change notification settings - Fork 0
WIP: feat(motors): implement all standard FRC motors #1
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
Open
Baconing
wants to merge
6
commits into
master
Choose a base branch
from
v2025-1-0-0/motors
base: master
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 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c39ecc
docs(motors/sparkmax): change the documentation describing the SparkM…
Baconing fd6f1ab
refactor(motors/sparkmax): remove getTrueRawMotor function in favor o…
Baconing 6dfae0c
feat(motors/spark): implement the Spark motor controller
Baconing 3fc721b
feat(motors/talonfx): implement the TalonFX motor controller
Baconing a1f0952
Merge branch 'master' into v2025-1-0-0/motors
Baconing d2794b4
Merge branch 'master' into v2025-1-0-0/motors
Baconing 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 hidden or 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
62 changes: 62 additions & 0 deletions
62
src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java
This file contains hidden or 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,62 @@ | ||
| package net.frc5183.librobot.hardware.motor; | ||
|
|
||
| import edu.wpi.first.wpilibj.motorcontrol.Spark; | ||
|
|
||
| /** | ||
| * Represents a Spark motor controller. | ||
| */ | ||
| public class SparkMotor extends Motor { | ||
| private final Spark motor; | ||
|
|
||
| public SparkMotor(int port) { | ||
| this.motor = new Spark(port); | ||
| } | ||
|
|
||
| public SparkMotor(Spark motor) { | ||
| this.motor = motor; | ||
| } | ||
|
|
||
| @Override | ||
| public void set(double speed) { | ||
| motor.set(speed); | ||
| } | ||
|
|
||
| @Override | ||
| public void periodic() { | ||
| motor.feed(); | ||
| } | ||
|
|
||
| @Override | ||
| public double get() { | ||
| return motor.get(); | ||
| } | ||
|
|
||
| @Override | ||
| public void setSafety(boolean on) { | ||
| motor.setSafetyEnabled(on); | ||
| } | ||
|
|
||
| @Override | ||
| public void setInverted(boolean inverted) { | ||
| motor.setInverted(inverted); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getInverted() { | ||
| return motor.getInverted(); | ||
| } | ||
|
|
||
| @Override | ||
| public void disable() { | ||
| motor.disable(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopMotor() { | ||
| motor.stopMotor(); | ||
| } | ||
|
|
||
| public Spark getRawMotor() { | ||
| return motor; | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java
This file contains hidden or 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,63 @@ | ||
| package net.frc5183.librobot.hardware.motor; | ||
|
|
||
| import com.ctre.phoenix6.hardware.TalonFX; | ||
| import edu.wpi.first.wpilibj.motorcontrol.MotorController; | ||
|
|
||
| /** | ||
| * Represents a TalonFX motor controller. | ||
| */ | ||
| public class TalonFXMotor extends Motor { | ||
| private final TalonFX motor; | ||
|
|
||
| public TalonFXMotor(int port) { | ||
| motor = new TalonFX(port); | ||
| } | ||
|
|
||
| public TalonFXMotor(TalonFX motor) { | ||
| this.motor = motor; | ||
| } | ||
|
|
||
| @Override | ||
| public void set(double speed) { | ||
| motor.set(speed); | ||
| } | ||
|
|
||
| @Override | ||
| public void periodic() { | ||
| motor.feed(); | ||
| } | ||
|
|
||
| @Override | ||
| public double get() { | ||
| return motor.get(); | ||
| } | ||
|
|
||
| @Override | ||
| public void setSafety(boolean on) { | ||
| motor.setSafetyEnabled(on); | ||
| } | ||
|
|
||
| @Override | ||
| public void setInverted(boolean inverted) { | ||
| motor.setInverted(inverted); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getInverted() { | ||
| return motor.getInverted(); | ||
| } | ||
|
|
||
| @Override | ||
| public void disable() { | ||
| motor.disable(); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopMotor() { | ||
| motor.stopMotor(); | ||
| } | ||
|
|
||
| public TalonFX getRawMotor() { | ||
| return motor; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.