Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Integrated swerve sim
Browse files Browse the repository at this point in the history
  • Loading branch information
rcahoon committed Nov 2, 2024
1 parent 1ef8599 commit dfc7040
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 174 deletions.
267 changes: 168 additions & 99 deletions WPISimConfig.txt
Original file line number Diff line number Diff line change
@@ -1,101 +1,170 @@
{
"drive": {
"leftMotor": {
"deviceId": 6,
"sensorScale": 0.0524
},
"rightMotor": {
"deviceId": 4,
"sensorScale": 0.0524
},
"leftEncoder": {
"ports": [0, 1],
"distancePerPulse": 0.0524
},
"rightEncoder": {
"ports": [2, 3],
"distancePerPulse": 0.0524
},
"gyro": {
"port": 12
},
"frontLeftDriveMotor": {
"deviceId": 84,
"sensorScale": 0.0008866,
"sensorScaledUnits": "meter"
},
"backLeftDriveMotor": {
"deviceId": 85,
"sensorScale": 0.0008866,
"sensorScaledUnits": "meter"
},
"frontRightDriveMotor": {
"deviceId": 86,
"sensorScale": 0.0008866,
"sensorScaledUnits": "meter"
},
"backRightDriveMotor": {
"deviceId": 87,
"sensorScale": 0.0008866,
"sensorScaledUnits": "meter"
},
"frontLeftSteerMotor": {
"deviceId": 88,
"inverted": true,
"sensorScaledUnits": "degree"
},
"backLeftSteerMotor": {
"deviceId": 89,
"inverted": true,
"sensorScaledUnits": "degree"
},
"frontRightSteerMotor": {
"deviceId": 90,
"inverted": true,
"sensorScaledUnits": "degree"
},
"backRightSteerMotor": {
"deviceId": 91,
"inverted": true,
"sensorScaledUnits": "degree"
}
},
"intakeWheels": {
"deviceId": 10
},
"intakeArm": {
"port": 0
},
"launch": {
"port": 1
},
"climber": {
"elevator": {
"deviceId": 10
},
"arms": {"port": 0}
},
"lineSensorLeft": {
"port": 4
},
"lineSensorCenter": {
"port": 5
},
"lineSensorRight": {
"port": 6
},

"intake": {
"extend": {"port": 0},
"frontWheels": {"deviceId": 10},
"topWheels": {"deviceId": 12}
},
"shooter": {
"motor": {"deviceId": 14}
},
"storage": {
"proximitySensor": {"port": 2},
"left": {"deviceId": 6},
"right": {"deviceId": 4}
}
"robotConfigurator": "com.team766.robot.reva.Robot",
"logFilePath": null,
"drive": {
"SteerFrontRight": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 10,
"CANBus": null
},
"SteerBackRight": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 11,
"CANBus": null
},
"DriveBackRight": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 12,
"CANBus": null
},
"DriveFrontRight": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 13,
"CANBus": null
},
"SteerBackLeft": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 14,
"CANBus": null
},
"SteerFrontLeft": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 15,
"CANBus": null
},
"DriveFrontLeft": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 16,
"CANBus": null
},
"DriveBackLeft": {
"sensorScale": null,
"port": null,
"sensorInverted": null,
"analogInput": null,
"pid": {
"outputMaxHigh": null,
"iGain": null,
"dGain": null,
"ffGain": null,
"pGain": 0.1,
"outputMaxLow": null,
"threshold": null
},
"inverted": null,
"type": "TalonFX",
"encoder": null,
"deviceId": 17,
"CANBus": null
},
"Gyro": {
"port": 0,
"type": "Pigeon2"
}
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def deployArtifact = deploy.targets.roborio.artifacts.frcJava
wpi.java.debugJni = false

// Set this to true to enable desktop support.
def includeDesktopSupport = false
def includeDesktopSupport = true

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/team766/hal/wpilib/PigeonGyro.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ public double getRoll() {
public double getRate() {
return pigeon.getRate();
}

public Pigeon2 getCTRE() {
return pigeon;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ private SwerveConstants() {}
* DRIVE_GEAR_RATIO // Motor radians/sec
/ (2 * Math.PI); // Motor rotations/sec (what velocity mode takes));

public static final double WHEEL_COEFF_FRICTION_STATIC = 1.1;
public static final double WHEEL_COEFF_FRICTION_DYNAMIC = 0.8;

public static final double NUM_WHEELS = 4;

// TUNE THESE!
public static final double DRIVE_STATOR_CURRENT_LIMIT = 80.0;
public static final double STEER_STATOR_CURRENT_LIMIT = 80.0;
Expand Down
Loading

0 comments on commit dfc7040

Please sign in to comment.