Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions lib/src/main/java/com/team2813/lib2813/control/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,11 @@
*/
package com.team2813.lib2813.control;

import edu.wpi.first.units.Units;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.AngularVelocity;

/** Specifies a device that can perceive rotational positions. */
public interface Encoder {
/**
* Gets the position of the encoder
*
* @return the position of the encoder
* @deprecated This method does not specify position in a specific measurement, so it is not safe
* to use. Use {@link #getPositionMeasure()} instead
*/
@Deprecated(forRemoval = true)
double position();

/**
* Gets the position of the encoder
*
Expand All @@ -42,32 +31,13 @@ public interface Encoder {
* Sets the position of the encoder
*
* @param position the position of the encoder
* @deprecated This method does not specify a unit, so it is not safe to use. Use {@link
* #setPosition(Angle)} instead.
*/
@Deprecated(forRemoval = true)
void setPosition(double position);

default void setPosition(Angle position) {
setPosition(position.in(Units.Radians));
}

/**
* Gets the velocity of the encoder
*
* @return the velocity that the encoder perceives
* @deprecated This method does not specify velocity in a specific measurement, so it is not safe
* to use. Use {@link #getVelocityMeasure()} instead
*/
@Deprecated(forRemoval = true)
double getVelocity();
void setPosition(Angle position);

/**
* Gets the velocity of the encoder
*
* @return The velocity as a measure
*/
default AngularVelocity getVelocityMeasure() {
return Units.RadiansPerSecond.of(getVelocity());
}
AngularVelocity getVelocityMeasure();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,11 @@ public CancoderWrapper(int id) {
info = new DeviceInformation(id);
}

@Deprecated
@Override
public double position() {
return cancoder.getPosition().getValueAsDouble();
}

@Override
public Angle getPositionMeasure() {
return Units.Rotations.of(cancoder.getPosition().getValueAsDouble());
}

@Deprecated
@Override
public void setPosition(double position) {
ConfigUtils.phoenix6Config(() -> cancoder.setPosition(position));
}

@Override
public void setPosition(Angle position) {
ConfigUtils.phoenix6Config(() -> cancoder.setPosition(position.in(Units.Rotations)));
Expand All @@ -63,12 +51,6 @@ public CANcoder encoder() {
return cancoder;
}

@Deprecated
@Override
public double getVelocity() {
return cancoder.getVelocity().getValueAsDouble();
}

@Override
public AngularVelocity getVelocityMeasure() {
return cancoder.getVelocity().getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ public void set(ControlMode controlMode, double demand, double feedForward) {
}
}

@Override
public double position() {
return encoder.getPosition();
}

@Override
public Angle getPositionMeasure() {
return Units.Rotations.of(encoder.getPosition());
Expand All @@ -101,21 +96,11 @@ public void stopMotor() {
motor.stopMotor();
}

@Override
public void setPosition(double position) {
encoder.setPosition(position);
}

@Override
public void setPosition(Angle position) {
encoder.setPosition(position.in(Units.Rotations));
}

@Override
public double getVelocity() {
return encoder.getVelocity();
}

@Override
public AngularVelocity getVelocityMeasure() {
return Units.Rotations.per(Units.Minute).of(encoder.getVelocity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public void set(ControlMode controlMode, double demand, double feedForward) {
}
}

@Override
public double position() {
return getPositionMeasure().in(Units.Rotations);
}

@Override
public Angle getPositionMeasure() {
return Units.Rotations.of(motor.getPosition().getValueAsDouble());
Expand All @@ -157,21 +152,11 @@ public Current getAppliedCurrent() {
return motor.getStatorCurrent().getValue();
}

@Override
public void setPosition(double position) {
motor.setPosition(position);
}

@Override
public void setPosition(Angle position) {
motor.setPosition(position.in(Units.Rotations));
}

@Override
public double getVelocity() {
return motor.getVelocity().getValueAsDouble();
}

@Override
public AngularVelocity getVelocityMeasure() {
return Units.RotationsPerSecond.of(motor.getVelocity().getValueAsDouble());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,34 +247,16 @@ protected final double getMeasurement() {
return encoder.getPositionMeasure().in(rotationUnit);
}

@Override
@Deprecated(forRemoval = true)
public double position() {
return encoder.position();
}

@Override
public Angle getPositionMeasure() {
return encoder.getPositionMeasure();
}

@Override
@Deprecated(forRemoval = true)
public void setPosition(double position) {
encoder.setPosition(position);
}

@Override
public void setPosition(Angle position) {
encoder.setPosition(position);
}

@Override
@Deprecated(forRemoval = true)
public double getVelocity() {
return encoder.getVelocity();
}

@Override
public AngularVelocity getVelocityMeasure() {
return encoder.getVelocityMeasure();
Expand Down

This file was deleted.

Loading