mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Added new SparkMAX analog encoder option, fixed 'none' absolute encoder type
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package swervelib.parser.json;
|
||||
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.MotorFeedbackSensor;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import swervelib.encoders.SwerveAbsoluteEncoder;
|
||||
import swervelib.motors.SwerveMotor;
|
||||
@@ -30,7 +32,7 @@ public class ModuleJson
|
||||
* {@link swervelib.math.SwerveMath#calculateDegreesPerSteeringRotation(double, double)} for angle motors or
|
||||
* {@link swervelib.math.SwerveMath#calculateMetersPerRotation(double, double, double)} for drive motors.
|
||||
*/
|
||||
public MotorConfigDouble conversionFactor = new MotorConfigDouble(0, 0);
|
||||
public MotorConfigDouble conversionFactor = new MotorConfigDouble(0, 0);
|
||||
/**
|
||||
* Absolute encoder device configuration.
|
||||
*/
|
||||
@@ -71,10 +73,12 @@ public class ModuleJson
|
||||
SwerveAbsoluteEncoder absEncoder = encoder.createEncoder(angleMotor);
|
||||
|
||||
// If the absolute encoder is attached.
|
||||
if (absEncoder == null)
|
||||
if (absEncoder != null && angleMotor.getMotor() instanceof CANSparkMax)
|
||||
{
|
||||
absEncoder = angle.createIntegratedEncoder(angleMotor);
|
||||
angleMotor.setAbsoluteEncoder(absEncoder);
|
||||
if (absEncoder.getAbsoluteEncoder() instanceof MotorFeedbackSensor)
|
||||
{
|
||||
angleMotor.setAbsoluteEncoder(absEncoder);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the conversion factors to null if they are both 0.
|
||||
|
||||
Reference in New Issue
Block a user