mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-22 06:41:39 +00:00
Added new SparkMAX analog encoder option, fixed 'none' absolute encoder type
This commit is contained in:
@@ -9,6 +9,7 @@ import swervelib.encoders.AnalogAbsoluteEncoderSwerve;
|
||||
import swervelib.encoders.CANCoderSwerve;
|
||||
import swervelib.encoders.CanAndCoderSwerve;
|
||||
import swervelib.encoders.PWMDutyCycleEncoderSwerve;
|
||||
import swervelib.encoders.SparkMaxAnalogEncoderSwerve;
|
||||
import swervelib.encoders.SparkMaxEncoderSwerve;
|
||||
import swervelib.encoders.SwerveAbsoluteEncoder;
|
||||
import swervelib.imu.ADIS16448Swerve;
|
||||
@@ -61,9 +62,12 @@ public class DeviceJson
|
||||
switch (type)
|
||||
{
|
||||
case "none":
|
||||
return null;
|
||||
case "integrated":
|
||||
case "attached":
|
||||
return null;
|
||||
return new SparkMaxEncoderSwerve(motor, 1);
|
||||
case "sparkmax_analog":
|
||||
return new SparkMaxAnalogEncoderSwerve(motor);
|
||||
case "canandcoder":
|
||||
return new SparkMaxEncoderSwerve(motor, 360);
|
||||
case "canandcoder_can":
|
||||
@@ -180,24 +184,4 @@ public class DeviceJson
|
||||
throw new RuntimeException(type + " is not a recognized absolute encoder type.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link SwerveAbsoluteEncoder} from the data port on the motor controller.
|
||||
*
|
||||
* @param motor The motor to create the absolute encoder from.
|
||||
* @return {@link SwerveAbsoluteEncoder} from the motor controller.
|
||||
*/
|
||||
public SwerveAbsoluteEncoder createIntegratedEncoder(SwerveMotor motor)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "sparkmax":
|
||||
return new SparkMaxEncoderSwerve(motor, 1);
|
||||
case "falcon":
|
||||
case "talonfx":
|
||||
return null;
|
||||
}
|
||||
throw new RuntimeException(
|
||||
"Could not create absolute encoder from data port of " + type + " id " + id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user