Skip to content

Commit

Permalink
dunno why but everything was messed up, this should be good
Browse files Browse the repository at this point in the history
  • Loading branch information
Anhysteretic committed Nov 3, 2023
1 parent a40a04c commit 0ac568b
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 61 deletions.
1 change: 1 addition & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
97 changes: 97 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"Joysticks": {
"window": {
"visible": false
}
},
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
]
}
45 changes: 45 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"HALProvider": {
"Other Devices": {
"Talon FX (Pro)[1]/Fwd Limit": {
"header": {
"open": true
}
},
"Talon FX (Pro)[3]/Fwd Limit": {
"header": {
"open": true
}
}
}
},
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/Pose": "Field2d",
"/SmartDashboard/Module 0": "Mechanism2d",
"/SmartDashboard/Module 1": "Mechanism2d",
"/SmartDashboard/Module 2": "Mechanism2d",
"/SmartDashboard/Module 3": "Mechanism2d"
}
},
"NetworkTables": {
"transitory": {
"Drive": {
"open": true
},
"LiveWindow": {
"open": true
},
"Shuffleboard": {
"open": true
},
"SmartDashboard": {
"Module 3": {
"open": true
},
"open": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,4 @@ public static final class CANID {
// Pigeon
public static final int kPigeon = 0;
}


}
107 changes: 54 additions & 53 deletions src/main/java/com/team841/Swerve23/Constants/Swerve.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,70 @@ public CustomSlotGains(double kP, double kI, double kD, double kV, double kS) {
}

private static final CustomSlotGains steerGains = new CustomSlotGains(100, 0, 0.05, 0, 0);
private static final CustomSlotGains driveGains = new CustomSlotGains(3, 0, 0, 0, 0);
private static final CustomSlotGains driveGains = new CustomSlotGains(3, 0, 0, 0, 0);

private static final double kCoupleRatio = 0.0;

private static final double kDriveGearRatio = 6.12;
private static final double kSteerGearRatio = 21.42;
private static final double kWheelRadiusInches = 3.5;
private static final int kPigeonId = 0;
private static final boolean kSteerMotorReversed = true;
private static final String kCANbusName = "Default Name";
private static final boolean kInvertLeftSide = false;
private static final boolean kInvertRightSide = false;
private static final double kCoupleRatio = 0.0;

private static final double kDriveGearRatio = 6.12;
private static final double kSteerGearRatio = 21.42;
private static final double kWheelRadiusInches = 3.5;
private static final int kPigeonId = 0;
private static final boolean kSteerMotorReversed = true;
private static final String kCANbusName = "Default Name";
private static final boolean kInvertLeftSide = false;
private static final boolean kInvertRightSide = false;

private static double kSteerInertia = 0.00001;
private static double kDriveInertia = 0.001;
private static double kSteerInertia = 0.00001;
private static double kDriveInertia = 0.001;

private static final SwerveDrivetrainConstants DrivetrainConstants = new SwerveDrivetrainConstants()
.withPigeon2Id(kPigeonId)
.withCANbusName(kCANbusName);
private static final SwerveDrivetrainConstants DrivetrainConstants =
new SwerveDrivetrainConstants().withPigeon2Id(kPigeonId).withCANbusName(kCANbusName);

private static final SwerveModuleConstantsFactory ConstantCreator = new SwerveModuleConstantsFactory()
.withDriveMotorGearRatio(kDriveGearRatio)
.withSteerMotorGearRatio(kSteerGearRatio)
.withWheelRadius(kWheelRadiusInches)
.withSlipCurrent(800)
.withSteerMotorGains(steerGains)
.withDriveMotorGains(driveGains)
.withSpeedAt12VoltsMps(6) // Theoretical free speed is 10 meters per second at 12v applied output
.withSteerInertia(kSteerInertia)
.withDriveInertia(kDriveInertia)
.withFeedbackSource(SwerveModuleSteerFeedbackType.FusedCANcoder)
.withCouplingGearRatio(kCoupleRatio) // Every 1 rotation of the azimuth results in couple ratio drive turns
.withSteerMotorInverted(kSteerMotorReversed);
private static final SwerveModuleConstantsFactory ConstantCreator =
new SwerveModuleConstantsFactory()
.withDriveMotorGearRatio(kDriveGearRatio)
.withSteerMotorGearRatio(kSteerGearRatio)
.withWheelRadius(kWheelRadiusInches)
.withSlipCurrent(800)
.withSteerMotorGains(steerGains)
.withDriveMotorGains(driveGains)
.withSpeedAt12VoltsMps(
6) // Theoretical free speed is 10 meters per second at 12v applied output
.withSteerInertia(kSteerInertia)
.withDriveInertia(kDriveInertia)
.withFeedbackSource(SwerveModuleSteerFeedbackType.FusedCANcoder)
.withCouplingGearRatio(
kCoupleRatio) // Every 1 rotation of the azimuth results in couple ratio drive turns
.withSteerMotorInverted(kSteerMotorReversed);

private static final int kFrontLeftDriveMotorId = 3;
private static final int kFrontLeftSteerMotorId = 4;
private static final int kFrontLeftEncoderId = 2;
private static final double kFrontLeftEncoderOffset = -0.521728515625;
private static final int kFrontLeftDriveMotorId = 3;
private static final int kFrontLeftSteerMotorId = 4;
private static final int kFrontLeftEncoderId = 2;
private static final double kFrontLeftEncoderOffset = -0.521728515625;

private static final double kFrontLeftXPosInches = 10.375;
private static final double kFrontLeftYPosInches = 10.375;
private static final int kFrontRightDriveMotorId = 1;
private static final int kFrontRightSteerMotorId = 2;
private static final int kFrontRightEncoderId = 0;
private static final double kFrontRightEncoderOffset = -0.169921875;
private static final double kFrontLeftXPosInches = 10.375;
private static final double kFrontLeftYPosInches = 10.375;
private static final int kFrontRightDriveMotorId = 1;
private static final int kFrontRightSteerMotorId = 2;
private static final int kFrontRightEncoderId = 0;
private static final double kFrontRightEncoderOffset = -0.169921875;

private static final double kFrontRightXPosInches = 10.375;
private static final double kFrontRightYPosInches = -10.375;
private static final int kBackLeftDriveMotorId = 5;
private static final int kBackLeftSteerMotorId = 6;
private static final int kBackLeftEncoderId = 3;
private static final double kBackLeftEncoderOffset = -0.3486328125;
private static final double kFrontRightXPosInches = 10.375;
private static final double kFrontRightYPosInches = -10.375;
private static final int kBackLeftDriveMotorId = 5;
private static final int kBackLeftSteerMotorId = 6;
private static final int kBackLeftEncoderId = 3;
private static final double kBackLeftEncoderOffset = -0.3486328125;

private static final double kBackLeftXPosInches = -10.375;
private static final double kBackLeftYPosInches = 10.375;
private static final int kBackRightDriveMotorId = 7;
private static final int kBackRightSteerMotorId = 8;
private static final int kBackRightEncoderId = 4;
private static final double kBackRightEncoderOffset = -0.784423828125;
private static final double kBackLeftXPosInches = -10.375;
private static final double kBackLeftYPosInches = 10.375;
private static final int kBackRightDriveMotorId = 7;
private static final int kBackRightSteerMotorId = 8;
private static final int kBackRightEncoderId = 4;
private static final double kBackRightEncoderOffset = -0.784423828125;

private static final double kBackRightXPosInches = -10.375;
private static final double kBackRightYPosInches = -10.375;
private static final double kBackRightXPosInches = -10.375;
private static final double kBackRightYPosInches = -10.375;

private static final SwerveModuleConstants FrontLeft =
ConstantCreator.createModuleConstants(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package com.team841.Swerve23.ControlBoard;

public class xBoxController {
;
}
public class xBoxController {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.team841.Swerve23.Constants.ConstantsIO;
import com.team841.Swerve23.Constants.SubsystemManifest;
import com.team841.Swerve23.Drive.Drivetrain;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
Expand All @@ -19,7 +18,8 @@ public class RobotContainer {
final double MaxAngularRate = Math.PI; // Half a rotation per second max angular velocity

/* Setting up bindings for necessary control of the swerve drive platform */
CommandPS4Controller joystick = new CommandPS4Controller(ConstantsIO.OI.driverPortLeft); // My joystick
CommandPS4Controller joystick =
new CommandPS4Controller(ConstantsIO.OI.driverPortLeft); // My joystick
Drivetrain drivetrain = SubsystemManifest.drivetrain; // My drivetrain
SwerveRequest.FieldCentric drive =
new SwerveRequest.FieldCentric().withIsOpenLoop(true); // I want field-centric
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team841.offseason2023.util;
package com.team841.lib.util;

import com.team841.Swerve23.Constants.ConstantsIO;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
Expand Down

0 comments on commit 0ac568b

Please sign in to comment.