From 1c39ecca2bed401b1450d5b058c776e1be32518e Mon Sep 17 00:00:00 2001 From: Bacon Date: Wed, 21 Aug 2024 15:20:17 -0400 Subject: [PATCH 1/4] docs(motors/sparkmax): change the documentation describing the SparkMaxMotor class --- .../java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java index e3b8f05..fbdd5c8 100644 --- a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java +++ b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java @@ -9,7 +9,7 @@ import net.frc5183.librobot.hardware.encoder.SparkMaxEncoder; /** - * A wrapper class around CANSparkMax to make it compatible with other motor types + * Represents a Spark Max motor controller. */ public class SparkMaxMotor extends Motor implements EncodedMotor { private final CANSparkMax motor; From fd6f1abb14b3408040c8eb2d742c685af4c9fd5a Mon Sep 17 00:00:00 2001 From: Bacon Date: Wed, 21 Aug 2024 15:22:56 -0400 Subject: [PATCH 2/4] refactor(motors/sparkmax): remove getTrueRawMotor function in favor of getRawMotor --- .../net/frc5183/librobot/hardware/motor/SparkMaxMotor.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java index fbdd5c8..75a55e4 100644 --- a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java +++ b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMaxMotor.java @@ -68,12 +68,7 @@ public void stopMotor() { motor.stopMotor(); } - @Override - public MotorController getRawMotor() { - return motor; - } - - public CANSparkMax getTrueRawMotor() { + public CANSparkMax getRawMotor() { return motor; } From 6dfae0c100eea8084ff0a4a90bd1a0a2f7242777 Mon Sep 17 00:00:00 2001 From: Bacon Date: Wed, 21 Aug 2024 15:23:44 -0400 Subject: [PATCH 3/4] feat(motors/spark): implement the Spark motor controller --- .../librobot/hardware/motor/SparkMotor.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java new file mode 100644 index 0000000..d712439 --- /dev/null +++ b/src/main/java/net/frc5183/librobot/hardware/motor/SparkMotor.java @@ -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; + } +} From 3fc721bf0c4074db4193826e64554b0c2e6f2ee2 Mon Sep 17 00:00:00 2001 From: Bacon Date: Wed, 21 Aug 2024 15:25:38 -0400 Subject: [PATCH 4/4] feat(motors/talonfx): implement the TalonFX motor controller --- .../librobot/hardware/motor/TalonFXMotor.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java diff --git a/src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java b/src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java new file mode 100644 index 0000000..7ca61d6 --- /dev/null +++ b/src/main/java/net/frc5183/librobot/hardware/motor/TalonFXMotor.java @@ -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; + } +}