+
void
+
+
-
void
-
-
+
void
+
+
Set the integrated encoder position.
-
void
-
setReference(double setpoint,
+void
+
-
+
Set the closed loop PID controller reference point.
-
void
-
-
+
void
+
+
Set the voltage compensation for the swerve module motor.
@@ -318,8 +307,16 @@ loadScripts(document, 'script');
absoluteEncoder
-private boolean absoluteEncoder
+private final boolean absoluteEncoder
Whether the absolute encoder is integrated.
+
+- See Also:
+-
+
+
+
@@ -528,6 +525,17 @@ loadScripts(document, 'script');
+
+getRawPosition
+public double getRawPosition()
+Get the raw position.
+
+- Returns:
+- Position in meters or degrees.
+
+
+
+
getPosition
public double getPosition()
@@ -536,7 +544,7 @@ loadScripts(document, 'script');
Specified by:
getPosition in class SwerveMotor
Returns:
-Position
+Position in Meters or Degrees.
@@ -549,7 +557,7 @@ loadScripts(document, 'script');
Specified by:
setPosition in class SwerveMotor
Parameters:
-
position - Integrated encoder position. Should be angle in degrees or meters per second.
+
position - Integrated encoder position. Should be angle in degrees or meters.
@@ -619,6 +627,35 @@ loadScripts(document, 'script');
+
+
+placeInAppropriate0To360Scope
+private double placeInAppropriate0To360Scope(double scopeReference,
+ double newAngle)
+Put an angle within the the 360 deg scope of a reference. For example, given a scope reference of 756 degrees,
+ assumes the full scope is (720-1080), and places an angle of 22 degrees into it, returning 742 deg.
+
+- Parameters:
+scopeReference - Current Angle (deg)
+newAngle - Target Angle (deg)
+- Returns:
+- Closest angle within scope (deg)
+
+
+
+
+
+convertToNativeSensorUnits
+public double convertToNativeSensorUnits(double setpoint)
+Convert the setpoint into native sensor units.
+
+- Parameters:
+setpoint - Setpoint to mutate. In meters per second or degrees.
+- Returns:
+- Setpoint as native sensor units. Encoder ticks per 100ms, or Encoder tick.
+
+
+
diff --git a/docs/swervelib/motors/package-summary.html b/docs/swervelib/motors/package-summary.html
index 779e31a..f6f83f6 100644
--- a/docs/swervelib/motors/package-summary.html
+++ b/docs/swervelib/motors/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.motors
@@ -114,18 +114,6 @@ loadScripts(document, 'script');
WPI_TalonSRX Swerve Motor.
-
-
-
The Talon PID to use onboard.
-
-
-
-
-
-
The Talon SRX Slot profile used to configure the motor to use for the PID.
-
diff --git a/docs/swervelib/motors/package-tree.html b/docs/swervelib/motors/package-tree.html
index ed221eb..d56a3bd 100644
--- a/docs/swervelib/motors/package-tree.html
+++ b/docs/swervelib/motors/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.motors Class Hierarchy
@@ -78,9 +78,6 @@ loadScripts(document, 'script');
java.lang.Enum<E> (implements java.lang.Comparable<T>, java.lang.constant.Constable, java.io.Serializable)
diff --git a/docs/swervelib/package-summary.html b/docs/swervelib/package-summary.html
index ad1300d..f325bfe 100644
--- a/docs/swervelib/package-summary.html
+++ b/docs/swervelib/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib
diff --git a/docs/swervelib/package-tree.html b/docs/swervelib/package-tree.html
index e5dc0b3..1f0103b 100644
--- a/docs/swervelib/package-tree.html
+++ b/docs/swervelib/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib Class Hierarchy
diff --git a/docs/swervelib/parser/PIDFConfig.html b/docs/swervelib/parser/PIDFConfig.html
index 926a252..3f56292 100644
--- a/docs/swervelib/parser/PIDFConfig.html
+++ b/docs/swervelib/parser/PIDFConfig.html
@@ -1,7 +1,7 @@
-
+
PIDFConfig
diff --git a/docs/swervelib/parser/SwerveControllerConfiguration.html b/docs/swervelib/parser/SwerveControllerConfiguration.html
index 371715a..20d34c6 100644
--- a/docs/swervelib/parser/SwerveControllerConfiguration.html
+++ b/docs/swervelib/parser/SwerveControllerConfiguration.html
@@ -1,7 +1,7 @@
-
+
SwerveControllerConfiguration
diff --git a/docs/swervelib/parser/SwerveDriveConfiguration.html b/docs/swervelib/parser/SwerveDriveConfiguration.html
index c2bd468..fc01c98 100644
--- a/docs/swervelib/parser/SwerveDriveConfiguration.html
+++ b/docs/swervelib/parser/SwerveDriveConfiguration.html
@@ -1,7 +1,7 @@
-
+
SwerveDriveConfiguration
diff --git a/docs/swervelib/parser/SwerveModuleConfiguration.html b/docs/swervelib/parser/SwerveModuleConfiguration.html
index 6917772..a898228 100644
--- a/docs/swervelib/parser/SwerveModuleConfiguration.html
+++ b/docs/swervelib/parser/SwerveModuleConfiguration.html
@@ -1,7 +1,7 @@
-
+
SwerveModuleConfiguration
diff --git a/docs/swervelib/parser/SwerveModulePhysicalCharacteristics.html b/docs/swervelib/parser/SwerveModulePhysicalCharacteristics.html
index ea3c718..efe3a7f 100644
--- a/docs/swervelib/parser/SwerveModulePhysicalCharacteristics.html
+++ b/docs/swervelib/parser/SwerveModulePhysicalCharacteristics.html
@@ -1,7 +1,7 @@
-
+
SwerveModulePhysicalCharacteristics
diff --git a/docs/swervelib/parser/SwerveParser.html b/docs/swervelib/parser/SwerveParser.html
index 55e289f..cd1bc55 100644
--- a/docs/swervelib/parser/SwerveParser.html
+++ b/docs/swervelib/parser/SwerveParser.html
@@ -1,7 +1,7 @@
-
+
SwerveParser
diff --git a/docs/swervelib/parser/deserializer/PIDFRange.html b/docs/swervelib/parser/deserializer/PIDFRange.html
index 6fa74e1..abb011b 100644
--- a/docs/swervelib/parser/deserializer/PIDFRange.html
+++ b/docs/swervelib/parser/deserializer/PIDFRange.html
@@ -1,7 +1,7 @@
-
+
PIDFRange
diff --git a/docs/swervelib/parser/deserializer/package-summary.html b/docs/swervelib/parser/deserializer/package-summary.html
index 8ccbab9..da449f3 100644
--- a/docs/swervelib/parser/deserializer/package-summary.html
+++ b/docs/swervelib/parser/deserializer/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser.deserializer
diff --git a/docs/swervelib/parser/deserializer/package-tree.html b/docs/swervelib/parser/deserializer/package-tree.html
index 9fe36d9..ebc2817 100644
--- a/docs/swervelib/parser/deserializer/package-tree.html
+++ b/docs/swervelib/parser/deserializer/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser.deserializer Class Hierarchy
diff --git a/docs/swervelib/parser/json/ControllerPropertiesJson.html b/docs/swervelib/parser/json/ControllerPropertiesJson.html
index 622a2f2..2056a8d 100644
--- a/docs/swervelib/parser/json/ControllerPropertiesJson.html
+++ b/docs/swervelib/parser/json/ControllerPropertiesJson.html
@@ -1,7 +1,7 @@
-
+
ControllerPropertiesJson
diff --git a/docs/swervelib/parser/json/DeviceJson.html b/docs/swervelib/parser/json/DeviceJson.html
index ab2660e..0ab8897 100644
--- a/docs/swervelib/parser/json/DeviceJson.html
+++ b/docs/swervelib/parser/json/DeviceJson.html
@@ -1,7 +1,7 @@
-
+
DeviceJson
diff --git a/docs/swervelib/parser/json/ModuleJson.html b/docs/swervelib/parser/json/ModuleJson.html
index 8692e1e..39fae0e 100644
--- a/docs/swervelib/parser/json/ModuleJson.html
+++ b/docs/swervelib/parser/json/ModuleJson.html
@@ -1,7 +1,7 @@
-
+
ModuleJson
diff --git a/docs/swervelib/parser/json/MotorConfigDouble.html b/docs/swervelib/parser/json/MotorConfigDouble.html
index 6fc338e..0ffac40 100644
--- a/docs/swervelib/parser/json/MotorConfigDouble.html
+++ b/docs/swervelib/parser/json/MotorConfigDouble.html
@@ -1,7 +1,7 @@
-
+
MotorConfigDouble
diff --git a/docs/swervelib/parser/json/MotorConfigInt.html b/docs/swervelib/parser/json/MotorConfigInt.html
index ffa502b..8cb9176 100644
--- a/docs/swervelib/parser/json/MotorConfigInt.html
+++ b/docs/swervelib/parser/json/MotorConfigInt.html
@@ -1,7 +1,7 @@
-
+
MotorConfigInt
diff --git a/docs/swervelib/parser/json/PIDFPropertiesJson.html b/docs/swervelib/parser/json/PIDFPropertiesJson.html
index 50e4447..6dcbd29 100644
--- a/docs/swervelib/parser/json/PIDFPropertiesJson.html
+++ b/docs/swervelib/parser/json/PIDFPropertiesJson.html
@@ -1,7 +1,7 @@
-
+
PIDFPropertiesJson
diff --git a/docs/swervelib/parser/json/PhysicalPropertiesJson.html b/docs/swervelib/parser/json/PhysicalPropertiesJson.html
index a3b8b62..f8ff2cb 100644
--- a/docs/swervelib/parser/json/PhysicalPropertiesJson.html
+++ b/docs/swervelib/parser/json/PhysicalPropertiesJson.html
@@ -1,7 +1,7 @@
-
+
PhysicalPropertiesJson
diff --git a/docs/swervelib/parser/json/SwerveDriveJson.html b/docs/swervelib/parser/json/SwerveDriveJson.html
index 1f461bc..de17179 100644
--- a/docs/swervelib/parser/json/SwerveDriveJson.html
+++ b/docs/swervelib/parser/json/SwerveDriveJson.html
@@ -1,7 +1,7 @@
-
+
SwerveDriveJson
diff --git a/docs/swervelib/parser/json/modules/BoolMotorJson.html b/docs/swervelib/parser/json/modules/BoolMotorJson.html
index f29d6a0..05367ae 100644
--- a/docs/swervelib/parser/json/modules/BoolMotorJson.html
+++ b/docs/swervelib/parser/json/modules/BoolMotorJson.html
@@ -1,7 +1,7 @@
-
+
BoolMotorJson
diff --git a/docs/swervelib/parser/json/modules/LocationJson.html b/docs/swervelib/parser/json/modules/LocationJson.html
index 26eb739..1ce7ccf 100644
--- a/docs/swervelib/parser/json/modules/LocationJson.html
+++ b/docs/swervelib/parser/json/modules/LocationJson.html
@@ -1,7 +1,7 @@
-
+
LocationJson
diff --git a/docs/swervelib/parser/json/modules/package-summary.html b/docs/swervelib/parser/json/modules/package-summary.html
index d7d5237..a9ef6e5 100644
--- a/docs/swervelib/parser/json/modules/package-summary.html
+++ b/docs/swervelib/parser/json/modules/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser.json.modules
diff --git a/docs/swervelib/parser/json/modules/package-tree.html b/docs/swervelib/parser/json/modules/package-tree.html
index a5f0c04..26d5e12 100644
--- a/docs/swervelib/parser/json/modules/package-tree.html
+++ b/docs/swervelib/parser/json/modules/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser.json.modules Class Hierarchy
diff --git a/docs/swervelib/parser/json/package-summary.html b/docs/swervelib/parser/json/package-summary.html
index ead919c..99c705e 100644
--- a/docs/swervelib/parser/json/package-summary.html
+++ b/docs/swervelib/parser/json/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser.json
diff --git a/docs/swervelib/parser/json/package-tree.html b/docs/swervelib/parser/json/package-tree.html
index 50ac56f..a769373 100644
--- a/docs/swervelib/parser/json/package-tree.html
+++ b/docs/swervelib/parser/json/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser.json Class Hierarchy
diff --git a/docs/swervelib/parser/package-summary.html b/docs/swervelib/parser/package-summary.html
index dcd0db1..a1ea719 100644
--- a/docs/swervelib/parser/package-summary.html
+++ b/docs/swervelib/parser/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser
diff --git a/docs/swervelib/parser/package-tree.html b/docs/swervelib/parser/package-tree.html
index ae1ddfe..e124c2f 100644
--- a/docs/swervelib/parser/package-tree.html
+++ b/docs/swervelib/parser/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.parser Class Hierarchy
diff --git a/docs/swervelib/simulation/SwerveIMUSimulation.html b/docs/swervelib/simulation/SwerveIMUSimulation.html
index e4d218d..054bb9d 100644
--- a/docs/swervelib/simulation/SwerveIMUSimulation.html
+++ b/docs/swervelib/simulation/SwerveIMUSimulation.html
@@ -1,7 +1,7 @@
-
+
SwerveIMUSimulation
diff --git a/docs/swervelib/simulation/SwerveModuleSimulation.html b/docs/swervelib/simulation/SwerveModuleSimulation.html
index 63a3d74..df1278e 100644
--- a/docs/swervelib/simulation/SwerveModuleSimulation.html
+++ b/docs/swervelib/simulation/SwerveModuleSimulation.html
@@ -1,7 +1,7 @@
-
+
SwerveModuleSimulation
diff --git a/docs/swervelib/simulation/ctre/PhysicsSim.SimProfile.html b/docs/swervelib/simulation/ctre/PhysicsSim.SimProfile.html
index 98dfe2e..36fc4b7 100644
--- a/docs/swervelib/simulation/ctre/PhysicsSim.SimProfile.html
+++ b/docs/swervelib/simulation/ctre/PhysicsSim.SimProfile.html
@@ -1,7 +1,7 @@
-
+
PhysicsSim.SimProfile
diff --git a/docs/swervelib/simulation/ctre/PhysicsSim.html b/docs/swervelib/simulation/ctre/PhysicsSim.html
index 8037a45..d8d43c9 100644
--- a/docs/swervelib/simulation/ctre/PhysicsSim.html
+++ b/docs/swervelib/simulation/ctre/PhysicsSim.html
@@ -1,7 +1,7 @@
-
+
PhysicsSim
diff --git a/docs/swervelib/simulation/ctre/TalonFXSimProfile.html b/docs/swervelib/simulation/ctre/TalonFXSimProfile.html
index ecf5a43..9d9a23d 100644
--- a/docs/swervelib/simulation/ctre/TalonFXSimProfile.html
+++ b/docs/swervelib/simulation/ctre/TalonFXSimProfile.html
@@ -1,7 +1,7 @@
-
+
TalonFXSimProfile
diff --git a/docs/swervelib/simulation/ctre/TalonSRXSimProfile.html b/docs/swervelib/simulation/ctre/TalonSRXSimProfile.html
index 504b3b4..1065c77 100644
--- a/docs/swervelib/simulation/ctre/TalonSRXSimProfile.html
+++ b/docs/swervelib/simulation/ctre/TalonSRXSimProfile.html
@@ -1,7 +1,7 @@
-
+
TalonSRXSimProfile
diff --git a/docs/swervelib/simulation/ctre/VictorSPXSimProfile.html b/docs/swervelib/simulation/ctre/VictorSPXSimProfile.html
index 0bd5767..3e5a02d 100644
--- a/docs/swervelib/simulation/ctre/VictorSPXSimProfile.html
+++ b/docs/swervelib/simulation/ctre/VictorSPXSimProfile.html
@@ -1,7 +1,7 @@
-
+
VictorSPXSimProfile
diff --git a/docs/swervelib/simulation/ctre/package-summary.html b/docs/swervelib/simulation/ctre/package-summary.html
index b775d86..6eb8b72 100644
--- a/docs/swervelib/simulation/ctre/package-summary.html
+++ b/docs/swervelib/simulation/ctre/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.simulation.ctre
diff --git a/docs/swervelib/simulation/ctre/package-tree.html b/docs/swervelib/simulation/ctre/package-tree.html
index 21d825e..c1e2f08 100644
--- a/docs/swervelib/simulation/ctre/package-tree.html
+++ b/docs/swervelib/simulation/ctre/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.simulation.ctre Class Hierarchy
diff --git a/docs/swervelib/simulation/package-summary.html b/docs/swervelib/simulation/package-summary.html
index c273d30..dc82f9b 100644
--- a/docs/swervelib/simulation/package-summary.html
+++ b/docs/swervelib/simulation/package-summary.html
@@ -1,7 +1,7 @@
-
+
swervelib.simulation
diff --git a/docs/swervelib/simulation/package-tree.html b/docs/swervelib/simulation/package-tree.html
index 596dc1e..2aa2acd 100644
--- a/docs/swervelib/simulation/package-tree.html
+++ b/docs/swervelib/simulation/package-tree.html
@@ -1,7 +1,7 @@
-
+
swervelib.simulation Class Hierarchy
diff --git a/docs/type-search-index.js b/docs/type-search-index.js
index 81e1759..e997e1b 100644
--- a/docs/type-search-index.js
+++ b/docs/type-search-index.js
@@ -1 +1 @@
-typeSearchIndex = [{"p":"swervelib.imu","l":"ADIS16448Swerve"},{"p":"swervelib.imu","l":"ADIS16470Swerve"},{"p":"swervelib.imu","l":"ADXRS450Swerve"},{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"swervelib.imu","l":"AnalogGyroSwerve"},{"p":"swervelib.parser.json.modules","l":"BoolMotorJson"},{"p":"swervelib.encoders","l":"CANCoderSwerve"},{"p":"swervelib.parser.json","l":"ControllerPropertiesJson"},{"p":"swervelib.motors","l":"TalonSRXSwerve.CTRE_pidIdx"},{"p":"swervelib.motors","l":"TalonSRXSwerve.CTRE_remoteSensor"},{"p":"swervelib.motors","l":"TalonSRXSwerve.CTRE_slotIdx"},{"p":"swervelib.parser.json","l":"DeviceJson"},{"p":"swervelib.parser.json.modules","l":"LocationJson"},{"p":"swervelib.parser.json","l":"ModuleJson"},{"p":"swervelib.parser.json","l":"MotorConfigDouble"},{"p":"swervelib.parser.json","l":"MotorConfigInt"},{"p":"swervelib.imu","l":"NavXSwerve"},{"p":"swervelib.parser.json","l":"PhysicalPropertiesJson"},{"p":"swervelib.simulation.ctre","l":"PhysicsSim"},{"p":"swervelib.parser","l":"PIDFConfig"},{"p":"swervelib.parser.json","l":"PIDFPropertiesJson"},{"p":"swervelib.parser.deserializer","l":"PIDFRange"},{"p":"swervelib.imu","l":"Pigeon2Swerve"},{"p":"swervelib.imu","l":"PigeonSwerve"},{"p":"swervelib.simulation.ctre","l":"PhysicsSim.SimProfile"},{"p":"swervelib.motors","l":"SparkMaxSwerve.SparkMAX_slotIdx"},{"p":"swervelib.encoders","l":"SparkMaxEncoderSwerve"},{"p":"swervelib.motors","l":"SparkMaxSwerve"},{"p":"swervelib.encoders","l":"SwerveAbsoluteEncoder"},{"p":"swervelib","l":"SwerveController"},{"p":"swervelib.parser","l":"SwerveControllerConfiguration"},{"p":"swervelib","l":"SwerveDrive"},{"p":"swervelib.parser","l":"SwerveDriveConfiguration"},{"p":"swervelib.parser.json","l":"SwerveDriveJson"},{"p":"swervelib.imu","l":"SwerveIMU"},{"p":"swervelib.simulation","l":"SwerveIMUSimulation"},{"p":"swervelib.math","l":"SwerveKinematics2"},{"p":"swervelib.math","l":"SwerveMath"},{"p":"swervelib","l":"SwerveModule"},{"p":"swervelib.parser","l":"SwerveModuleConfiguration"},{"p":"swervelib.parser","l":"SwerveModulePhysicalCharacteristics"},{"p":"swervelib.simulation","l":"SwerveModuleSimulation"},{"p":"swervelib.math","l":"SwerveModuleState2"},{"p":"swervelib.motors","l":"SwerveMotor"},{"p":"swervelib.parser","l":"SwerveParser"},{"p":"swervelib.simulation.ctre","l":"TalonFXSimProfile"},{"p":"swervelib.motors","l":"TalonFXSwerve"},{"p":"swervelib.simulation.ctre","l":"TalonSRXSimProfile"},{"p":"swervelib.motors","l":"TalonSRXSwerve"},{"p":"swervelib.simulation.ctre","l":"VictorSPXSimProfile"}];updateSearchResults();
\ No newline at end of file
+typeSearchIndex = [{"p":"swervelib.imu","l":"ADIS16448Swerve"},{"p":"swervelib.imu","l":"ADIS16470Swerve"},{"p":"swervelib.imu","l":"ADXRS450Swerve"},{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"swervelib.imu","l":"AnalogGyroSwerve"},{"p":"swervelib.parser.json.modules","l":"BoolMotorJson"},{"p":"swervelib.encoders","l":"CANCoderSwerve"},{"p":"swervelib.parser.json","l":"ControllerPropertiesJson"},{"p":"swervelib.parser.json","l":"DeviceJson"},{"p":"swervelib.parser.json.modules","l":"LocationJson"},{"p":"swervelib.parser.json","l":"ModuleJson"},{"p":"swervelib.parser.json","l":"MotorConfigDouble"},{"p":"swervelib.parser.json","l":"MotorConfigInt"},{"p":"swervelib.imu","l":"NavXSwerve"},{"p":"swervelib.parser.json","l":"PhysicalPropertiesJson"},{"p":"swervelib.simulation.ctre","l":"PhysicsSim"},{"p":"swervelib.parser","l":"PIDFConfig"},{"p":"swervelib.parser.json","l":"PIDFPropertiesJson"},{"p":"swervelib.parser.deserializer","l":"PIDFRange"},{"p":"swervelib.imu","l":"Pigeon2Swerve"},{"p":"swervelib.imu","l":"PigeonSwerve"},{"p":"swervelib.simulation.ctre","l":"PhysicsSim.SimProfile"},{"p":"swervelib.motors","l":"SparkMaxSwerve.SparkMAX_slotIdx"},{"p":"swervelib.encoders","l":"SparkMaxEncoderSwerve"},{"p":"swervelib.motors","l":"SparkMaxSwerve"},{"p":"swervelib.encoders","l":"SwerveAbsoluteEncoder"},{"p":"swervelib","l":"SwerveController"},{"p":"swervelib.parser","l":"SwerveControllerConfiguration"},{"p":"swervelib","l":"SwerveDrive"},{"p":"swervelib.parser","l":"SwerveDriveConfiguration"},{"p":"swervelib.parser.json","l":"SwerveDriveJson"},{"p":"swervelib.imu","l":"SwerveIMU"},{"p":"swervelib.simulation","l":"SwerveIMUSimulation"},{"p":"swervelib.math","l":"SwerveKinematics2"},{"p":"swervelib.math","l":"SwerveMath"},{"p":"swervelib","l":"SwerveModule"},{"p":"swervelib.parser","l":"SwerveModuleConfiguration"},{"p":"swervelib.parser","l":"SwerveModulePhysicalCharacteristics"},{"p":"swervelib.simulation","l":"SwerveModuleSimulation"},{"p":"swervelib.math","l":"SwerveModuleState2"},{"p":"swervelib.motors","l":"SwerveMotor"},{"p":"swervelib.parser","l":"SwerveParser"},{"p":"swervelib.simulation.ctre","l":"TalonFXSimProfile"},{"p":"swervelib.motors","l":"TalonFXSwerve"},{"p":"swervelib.simulation.ctre","l":"TalonSRXSimProfile"},{"p":"swervelib.motors","l":"TalonSRXSwerve"},{"p":"swervelib.simulation.ctre","l":"VictorSPXSimProfile"}];updateSearchResults();
\ No newline at end of file
diff --git a/swervelib/motors/TalonSRXSwerve.java b/swervelib/motors/TalonSRXSwerve.java
index 3e43a8a..0494a38 100644
--- a/swervelib/motors/TalonSRXSwerve.java
+++ b/swervelib/motors/TalonSRXSwerve.java
@@ -4,10 +4,9 @@ import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.DemandType;
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
import com.ctre.phoenix.motorcontrol.NeutralMode;
-import com.ctre.phoenix.motorcontrol.RemoteFeedbackDevice;
import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
-import com.ctre.phoenix.sensors.CANCoder;
+import frc.robot.Robot;
import swervelib.encoders.SwerveAbsoluteEncoder;
import swervelib.parser.PIDFConfig;
@@ -28,11 +27,11 @@ public class TalonSRXSwerve extends SwerveMotor
/**
* Whether the absolute encoder is integrated.
*/
- private boolean absoluteEncoder = false;
+ private final boolean absoluteEncoder = false;
/**
* The position conversion factor.
*/
- private double positionConversionFactor = 1;
+ private double positionConversionFactor = 1;
/**
* Constructor for TalonSRX swerve motor.
@@ -70,6 +69,7 @@ public class TalonSRXSwerve extends SwerveMotor
if (!factoryDefaultOccurred)
{
motor.configFactoryDefault();
+ motor.setSensorPhase(true);
}
}
@@ -91,13 +91,6 @@ public class TalonSRXSwerve extends SwerveMotor
@Override
public SwerveMotor setAbsoluteEncoder(SwerveAbsoluteEncoder encoder)
{
- if (encoder.getAbsoluteEncoder() instanceof CANCoder)
- {
- motor.configSelectedFeedbackSensor(RemoteFeedbackDevice.RemoteSensor0);
- motor.configRemoteFeedbackFilter((CANCoder) encoder.getAbsoluteEncoder(),
- CTRE_remoteSensor.REMOTE_SENSOR_0.ordinal());
- absoluteEncoder = true;
- }
return this;
}
@@ -110,7 +103,6 @@ public class TalonSRXSwerve extends SwerveMotor
public void configureIntegratedEncoder(double positionConversionFactor)
{
this.positionConversionFactor = positionConversionFactor;
- motor.configSelectedFeedbackCoefficient(positionConversionFactor);
}
/**
@@ -121,7 +113,7 @@ public class TalonSRXSwerve extends SwerveMotor
@Override
public void configurePIDF(PIDFConfig config)
{
- int slotIdx = isDriveMotor ? CTRE_slotIdx.Velocity.ordinal() : CTRE_slotIdx.Turning.ordinal();
+ int slotIdx = 0;
motor.config_kP(slotIdx, config.p);
motor.config_kI(slotIdx, config.i);
motor.config_kD(slotIdx, config.d);
@@ -193,9 +185,13 @@ public class TalonSRXSwerve extends SwerveMotor
@Override
public void setReference(double setpoint, double feedforward)
{
- motor.set(isDriveMotor ? ControlMode.Velocity : ControlMode.Position, isDriveMotor ? setpoint * .1 : setpoint,
+ burnFlash();
+
+ motor.set(isDriveMotor ? ControlMode.Velocity : ControlMode.Position,
+ convertToNativeSensorUnits(setpoint),
DemandType.ArbitraryFeedForward,
- feedforward);
+ feedforward * -0.3);
+ // Credit to Team 3181 for the -0.3, I'm not sure why it works, but it does.
}
/**
@@ -206,31 +202,41 @@ public class TalonSRXSwerve extends SwerveMotor
@Override
public double getVelocity()
{
- return motor.getSelectedSensorVelocity() * (10 * positionConversionFactor);
+ return (motor.getSelectedSensorVelocity() * 10) * positionConversionFactor;
}
/**
- * Get the position of the integrated encoder.
+ * Get the raw position.
*
- * @return Position
+ * @return Position in meters or degrees.
*/
- @Override
- public double getPosition()
+ public double getRawPosition()
{
return motor.getSelectedSensorPosition() * positionConversionFactor;
}
+ /**
+ * Get the position of the integrated encoder.
+ *
+ * @return Position in Meters or Degrees.
+ */
+ @Override
+ public double getPosition()
+ {
+ return isDriveMotor ? getRawPosition() : getRawPosition() % 360;
+ }
+
/**
* Set the integrated encoder position.
*
- * @param position Integrated encoder position. Should be angle in degrees or meters per second.
+ * @param position Integrated encoder position. Should be angle in degrees or meters.
*/
@Override
public void setPosition(double position)
{
- if (!absoluteEncoder)
+ if (!absoluteEncoder && Robot.isReal())
{
- motor.setSelectedSensorPosition(position * positionConversionFactor);
+ motor.setSelectedSensorPosition(convertToNativeSensorUnits(position));
}
}
@@ -297,63 +303,60 @@ public class TalonSRXSwerve extends SwerveMotor
}
/**
- * The Talon SRX Slot profile used to configure the motor to use for the PID.
+ * Put an angle within the the 360 deg scope of a reference. For example, given a scope reference of 756 degrees,
+ * assumes the full scope is (720-1080), and places an angle of 22 degrees into it, returning 742 deg.
+ *
+ * @param scopeReference Current Angle (deg)
+ * @param newAngle Target Angle (deg)
+ * @return Closest angle within scope (deg)
*/
- enum CTRE_slotIdx
+ private double placeInAppropriate0To360Scope(double scopeReference, double newAngle)
{
- /**
- * Slot 0, meant for distances PID's.
- */
- Distance,
- /**
- * Slot 1, meant for turning PID's.
- */
- Turning,
- /**
- * Slot 2, meant for velocity PID's.
- */
- Velocity,
- /**
- * Slot 3, meant for motion profiles.
- */
- MotionProfile
+ double lowerBound;
+ double upperBound;
+ double lowerOffset = scopeReference % 360;
+
+ // Create the interval from the reference angle.
+ if (lowerOffset >= 0)
+ {
+ lowerBound = scopeReference - lowerOffset;
+ upperBound = scopeReference + (360 - lowerOffset);
+ } else
+ {
+ upperBound = scopeReference - lowerOffset;
+ lowerBound = scopeReference - (360 + lowerOffset);
+ }
+ // Put the angle in the interval.
+ while (newAngle < lowerBound)
+ {
+ newAngle += 360;
+ }
+ while (newAngle > upperBound)
+ {
+ newAngle -= 360;
+ }
+ // Smooth the transition between interval boundaries.
+ if (newAngle - scopeReference > 180)
+ {
+ newAngle -= 360;
+ } else if (newAngle - scopeReference < -180)
+ {
+ newAngle += 360;
+ }
+ return newAngle;
}
/**
- * The Talon PID to use onboard.
+ * Convert the setpoint into native sensor units.
+ *
+ * @param setpoint Setpoint to mutate. In meters per second or degrees.
+ * @return Setpoint as native sensor units. Encoder ticks per 100ms, or Encoder tick.
*/
- enum CTRE_pidIdx
+ public double convertToNativeSensorUnits(double setpoint)
{
- /**
- * Primary PID for talons.
- */
- PRIMARY_PID,
- /**
- * Secondary PID for talons.
- */
- AUXILIARY_PID,
- /**
- * Third PID slot for talons.
- */
- THIRD_PID,
- /**
- * Fourth PID slot for talons.
- */
- FOURTH_PID
- }
-
- /**
- * The remote sensor.
- */
- enum CTRE_remoteSensor
- {
- /**
- * Remote sensor 0.
- */
- REMOTE_SENSOR_0,
- /**
- * Remote sensor 1.
- */
- REMOTE_SENSOR_1
+ setpoint = isDriveMotor ?
+ setpoint * .1 :
+ placeInAppropriate0To360Scope(getRawPosition(), setpoint);
+ return setpoint / positionConversionFactor;
}
}