DeepBlueRobotics/lib199

Possible Unnecessary Code (Check REVLib Changelog) (CachedSparkMax)

Closed this issue · 3 comments

package org.carlmontrobotics.lib199;
import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkMaxPIDController;
public class CachedSparkMax extends CANSparkMax {
private RelativeEncoder encoder;
private SparkMaxPIDController pidController;
public CachedSparkMax(int deviceId, MotorType type) {
super(deviceId, type);
this.encoder = null;
this.pidController = null;
}
@Override
public RelativeEncoder getEncoder() {
return encoder == null ? (encoder = super.getEncoder()) : encoder;
}
@Override
public SparkMaxPIDController getPIDController() {
return pidController == null ? (pidController = super.getPIDController()) : pidController;
}
}
I've emailed Rev about the REVLib issue for which this is a workaround. This issue is for discussion of any relevant information, and as a reminder to watch the changelog as a supported solution may be released in the future.

It looks like all the relevant methods in CANSparkMax have been rewritten to cache their return values. Rev's implementation also has better thread safety than the one here. I'll start a PR to deprecate this class. It should be removed in a future major version.

where do you find these changelogs? I looked up "Rev robotics changelog" and other keywords but couldn't find it anywhere.

where do you find these changelogs? I looked up "Rev robotics changelog" and other keywords but couldn't find it anywhere.

They're on the REVLib Information Page