mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-08 16:28:00 -06:00
cancoder offsets
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"Configs": [
|
||||||
|
{
|
||||||
|
"Name": "Integrated Sensor",
|
||||||
|
"Type": "IntegratedSensor",
|
||||||
|
"Description": "Configures how the sensor is processed.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Absolute Sensor Range": 0,
|
||||||
|
"Magnet Offset (deg)": -240.0293,
|
||||||
|
"Sensor Direction": false,
|
||||||
|
"Sensor Initialization Strategy": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Unit Coefficient And String",
|
||||||
|
"Type": "UnitCoeffGroup",
|
||||||
|
"Description": "Describes the units to report in API and Self-Test.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Sensor Coefficient": 0.087890625,
|
||||||
|
"Sensor Time Base": 1,
|
||||||
|
"Unit String": "deg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Custom Params",
|
||||||
|
"Type": "CustomParams",
|
||||||
|
"Description": "These are arbitrary values not used by the firmware.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Custom Param 0": 0,
|
||||||
|
"Custom Param 1": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Advanced Sensor and Meas",
|
||||||
|
"Type": "AdvancedSensorMeas",
|
||||||
|
"Description": "Group of configs relating to advanced sensor features and filters",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Velocity Period": 100,
|
||||||
|
"Velocity Window": 64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"Configs": [
|
||||||
|
{
|
||||||
|
"Name": "Integrated Sensor",
|
||||||
|
"Type": "IntegratedSensor",
|
||||||
|
"Description": "Configures how the sensor is processed.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Absolute Sensor Range": 0,
|
||||||
|
"Magnet Offset (deg)": -181.230469,
|
||||||
|
"Sensor Direction": false,
|
||||||
|
"Sensor Initialization Strategy": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Unit Coefficient And String",
|
||||||
|
"Type": "UnitCoeffGroup",
|
||||||
|
"Description": "Describes the units to report in API and Self-Test.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Sensor Coefficient": 0.087890625,
|
||||||
|
"Sensor Time Base": 1,
|
||||||
|
"Unit String": "deg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Custom Params",
|
||||||
|
"Type": "CustomParams",
|
||||||
|
"Description": "These are arbitrary values not used by the firmware.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Custom Param 0": 0,
|
||||||
|
"Custom Param 1": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Advanced Sensor and Meas",
|
||||||
|
"Type": "AdvancedSensorMeas",
|
||||||
|
"Description": "Group of configs relating to advanced sensor features and filters",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Velocity Period": 100,
|
||||||
|
"Velocity Window": 64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"Configs": [
|
||||||
|
{
|
||||||
|
"Name": "Integrated Sensor",
|
||||||
|
"Type": "IntegratedSensor",
|
||||||
|
"Description": "Configures how the sensor is processed.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Absolute Sensor Range": 0,
|
||||||
|
"Magnet Offset (deg)": -40.86914,
|
||||||
|
"Sensor Direction": false,
|
||||||
|
"Sensor Initialization Strategy": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Unit Coefficient And String",
|
||||||
|
"Type": "UnitCoeffGroup",
|
||||||
|
"Description": "Describes the units to report in API and Self-Test.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Sensor Coefficient": 0.087890625,
|
||||||
|
"Sensor Time Base": 1,
|
||||||
|
"Unit String": "deg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Custom Params",
|
||||||
|
"Type": "CustomParams",
|
||||||
|
"Description": "These are arbitrary values not used by the firmware.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Custom Param 0": 0,
|
||||||
|
"Custom Param 1": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Advanced Sensor and Meas",
|
||||||
|
"Type": "AdvancedSensorMeas",
|
||||||
|
"Description": "Group of configs relating to advanced sensor features and filters",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Velocity Period": 100,
|
||||||
|
"Velocity Window": 64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"Configs": [
|
||||||
|
{
|
||||||
|
"Name": "Integrated Sensor",
|
||||||
|
"Type": "IntegratedSensor",
|
||||||
|
"Description": "Configures how the sensor is processed.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Absolute Sensor Range": 0,
|
||||||
|
"Magnet Offset (deg)": -270.615234,
|
||||||
|
"Sensor Direction": false,
|
||||||
|
"Sensor Initialization Strategy": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Unit Coefficient And String",
|
||||||
|
"Type": "UnitCoeffGroup",
|
||||||
|
"Description": "Describes the units to report in API and Self-Test.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Sensor Coefficient": 0.087890625,
|
||||||
|
"Sensor Time Base": 1,
|
||||||
|
"Unit String": "deg"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Custom Params",
|
||||||
|
"Type": "CustomParams",
|
||||||
|
"Description": "These are arbitrary values not used by the firmware.",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Custom Param 0": 0,
|
||||||
|
"Custom Param 1": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Advanced Sensor and Meas",
|
||||||
|
"Type": "AdvancedSensorMeas",
|
||||||
|
"Description": "Group of configs relating to advanced sensor features and filters",
|
||||||
|
"Ordinal": 0,
|
||||||
|
"Values": {
|
||||||
|
"Velocity Period": 100,
|
||||||
|
"Velocity Window": 64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -127,14 +127,11 @@ public class RobotMap {
|
|||||||
// rightBackEncoder.configMagnetOffset(225.0); //180.0); //270.0);//267.01171875);//SwerveDriveConstants.Configurations.RIGHT_BACK_ENCODER_OFFSET);
|
// rightBackEncoder.configMagnetOffset(225.0); //180.0); //270.0);//267.01171875);//SwerveDriveConstants.Configurations.RIGHT_BACK_ENCODER_OFFSET);
|
||||||
|
|
||||||
// initialize SwerveModules
|
// initialize SwerveModules
|
||||||
this.leftFront = new SwerveModule(leftFrontWheel, leftFrontSteer, leftFrontEncoder);
|
this.leftFront = new SwerveModule(leftFrontWheel, leftFrontSteer, leftFrontEncoder, -181.230469);
|
||||||
this.rightFront = new SwerveModule(rightFrontWheel, rightFrontSteer, rightFrontEncoder);
|
this.rightFront = new SwerveModule(rightFrontWheel, rightFrontSteer, rightFrontEncoder, -270.615234);
|
||||||
this.leftBack = new SwerveModule(leftBackWheel, leftBackSteer, leftBackEncoder);
|
this.leftBack = new SwerveModule(leftBackWheel, leftBackSteer, leftBackEncoder, -240.029297);
|
||||||
this.rightBack = new SwerveModule(rightBackWheel, rightBackSteer, rightBackEncoder);
|
this.rightBack = new SwerveModule(rightBackWheel, rightBackSteer, rightBackEncoder, -40.869142);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// FINAL OFFSETS (I THINK)
|
|
||||||
// LEFT FRONT: -181.230469
|
// LEFT FRONT: -181.230469
|
||||||
// RIGHT FRONT: -270.615234
|
// RIGHT FRONT: -270.615234
|
||||||
// LEFT BACK: -240.029297
|
// LEFT BACK: -240.029297
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class DriveWithInput extends CommandBase {
|
|||||||
|
|
||||||
x = -xLimiter.calculate(MathUtil.applyDeadband(x * -0.3, 0.02) * Units.feetToMeters(SwerveDriveConstants.MAX_SPEED_FEET_PER_SECOND));
|
x = -xLimiter.calculate(MathUtil.applyDeadband(x * -0.3, 0.02) * Units.feetToMeters(SwerveDriveConstants.MAX_SPEED_FEET_PER_SECOND));
|
||||||
y = -yLimiter.calculate(MathUtil.applyDeadband(y * 0.3, 0.02) * Units.feetToMeters(SwerveDriveConstants.MAX_SPEED_FEET_PER_SECOND));
|
y = -yLimiter.calculate(MathUtil.applyDeadband(y * 0.3, 0.02) * Units.feetToMeters(SwerveDriveConstants.MAX_SPEED_FEET_PER_SECOND));
|
||||||
r = -rotLimiter.calculate(MathUtil.applyDeadband(r * 0.3, 0.02) * Units.feetToMeters(Math.PI));
|
r = -rotLimiter.calculate(MathUtil.applyDeadband(r * 0.3, 0.02) * Units.feetToMeters(5*Math.PI));
|
||||||
|
|
||||||
swerve.drive(x, y, r, fieldRelative);
|
swerve.drive(x, y, r, fieldRelative);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class SwerveModule extends SubsystemBase {
|
|||||||
public static Gains swerveGains = SwerveDriveConstants.PIDConstants.SWERVE_GAINS;
|
public static Gains swerveGains = SwerveDriveConstants.PIDConstants.SWERVE_GAINS;
|
||||||
|
|
||||||
/** Creates a new SwerveModule. */
|
/** Creates a new SwerveModule. */
|
||||||
public SwerveModule(WPI_TalonFX driveMotor, WPI_TalonFX angleMotor, CANCoder encoder) {//, double offset) {
|
public SwerveModule(WPI_TalonFX driveMotor, WPI_TalonFX angleMotor, CANCoder encoder, double offset) {
|
||||||
this.driveMotor = driveMotor;
|
this.driveMotor = driveMotor;
|
||||||
this.angleMotor = angleMotor;
|
this.angleMotor = angleMotor;
|
||||||
this.encoder = encoder;
|
this.encoder = encoder;
|
||||||
@@ -47,9 +47,10 @@ public class SwerveModule extends SubsystemBase {
|
|||||||
angleConfig.primaryPID.selectedFeedbackSensor = FeedbackDevice.RemoteSensor0;
|
angleConfig.primaryPID.selectedFeedbackSensor = FeedbackDevice.RemoteSensor0;
|
||||||
angleMotor.configAllSettings(angleConfig);
|
angleMotor.configAllSettings(angleConfig);
|
||||||
|
|
||||||
CANCoderConfiguration canCoderConfig = new CANCoderConfiguration();
|
// CANCoderConfiguration canCoderConfig = new CANCoderConfiguration();
|
||||||
// canCoderConfig.magnetOffsetDegrees = offset;
|
// canCoderConfig.magnetOffsetDegrees = offset;
|
||||||
encoder.configAllSettings(canCoderConfig);
|
// encoder.configAllSettings(canCoderConfig);
|
||||||
|
encoder.configMagnetOffset(offset);
|
||||||
|
|
||||||
// driveMotor.config_kP(0, 0.4);
|
// driveMotor.config_kP(0, 0.4);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user