diff --git a/SeriouslyCommonLib b/SeriouslyCommonLib index 415cf4e..b1ed5f7 160000 --- a/SeriouslyCommonLib +++ b/SeriouslyCommonLib @@ -1 +1 @@ -Subproject commit 415cf4e469d7d50a7028c1c337d57ece25485e7c +Subproject commit b1ed5f765fd4f9c3f5debe138f4809d475711c34 diff --git a/shuffleboard.json b/shuffleboard.json new file mode 100644 index 0000000..76b0c92 --- /dev/null +++ b/shuffleboard.json @@ -0,0 +1,143 @@ +{ + "tabPane": [ + { + "title": "LiveWindow", + "autoPopulate": true, + "autoPopulatePrefix": "LiveWindow/", + "widgetPane": { + "gridSize": 128.0, + "showGrid": true, + "hgap": 16.0, + "vgap": 16.0, + "tiles": { + "0,0": { + "size": [ + 2, + 4 + ], + "content": { + "_type": "Subsystem Layout", + "_source0": "network_table:///LiveWindow/PoseSubsystem", + "_title": "PoseSubsystem", + "Layout/Label position": "BOTTOM", + "_children": [] + } + }, + "2,0": { + "size": [ + 2, + 4 + ], + "content": { + "_type": "Subsystem Layout", + "_source0": "network_table:///LiveWindow/AutonomousCommandSelector", + "_title": "AutonomousCommandSelector", + "Layout/Label position": "BOTTOM", + "_children": [] + } + }, + "4,0": { + "size": [ + 2, + 4 + ], + "content": { + "_type": "Subsystem Layout", + "_source0": "network_table:///LiveWindow/DriveSubsystem", + "_title": "DriveSubsystem", + "Layout/Label position": "BOTTOM", + "_children": [] + } + }, + "6,0": { + "size": [ + 2, + 4 + ], + "content": { + "_type": "Subsystem Layout", + "_source0": "network_table:///LiveWindow/Ungrouped", + "_title": "Ungrouped", + "Layout/Label position": "BOTTOM", + "_children": [] + } + } + } + } + }, + { + "title": "Basic Sensors", + "autoPopulate": false, + "autoPopulatePrefix": "", + "widgetPane": { + "gridSize": 128.0, + "showGrid": true, + "hgap": 16.0, + "vgap": 16.0, + "tiles": { + "3,1": { + "size": [ + 2, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/LeftDrive/LeftLeader/position", + "_title": "SmartDashboard/LeftDrive/LeftLeader/position" + } + }, + "3,2": { + "size": [ + 1, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/PoseSubsystem/CurrentHeading", + "_title": "SmartDashboard/PoseSubsystem/CurrentHeading" + } + }, + "5,1": { + "size": [ + 2, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/RightDrive/RightLeader/position", + "_title": "SmartDashboard/RightDrive/RightLeader/position" + } + }, + "3,0": { + "size": [ + 2, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/LeftDrive/LeftLeader/voltage", + "_title": "SmartDashboard/LeftDrive/LeftLeader/voltage" + } + }, + "5,0": { + "size": [ + 2, + 1 + ], + "content": { + "_type": "Text View", + "_source0": "network_table:///SmartDashboard/RightDrive/RightLeader/voltage", + "_title": "SmartDashboard/RightDrive/RightLeader/voltage" + } + } + } + } + } + ], + "windowGeometry": { + "x": -1288.0, + "y": -9.0, + "width": 1296.0, + "height": 1000.0 + } +} \ No newline at end of file diff --git a/src/main/java/competition/subsystems/drive/DriveSubsystem.java b/src/main/java/competition/subsystems/drive/DriveSubsystem.java index e723315..f061113 100644 --- a/src/main/java/competition/subsystems/drive/DriveSubsystem.java +++ b/src/main/java/competition/subsystems/drive/DriveSubsystem.java @@ -32,33 +32,31 @@ public class DriveSubsystem extends BaseDriveSubsystem { public final XAnalogDistanceSensor distanceSensor2; int i; + private final double simulatedEncoderFactor = 256.0 / Math.PI; @Inject public DriveSubsystem(CommonLibFactory factory, XPropertyManager propManager) { log.info("Creating DriveSubsystem"); this.leftLeader = factory - .createCANTalon(new CANTalonInfo(1, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, 1)); + .createCANTalon(new CANTalonInfo(1, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulatedEncoderFactor)); this.leftFollower1 = factory - .createCANTalon(new CANTalonInfo(3, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, 1)); + .createCANTalon(new CANTalonInfo(3, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulatedEncoderFactor)); this.leftFollower2= factory - .createCANTalon(new CANTalonInfo(5, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, 1)); + .createCANTalon(new CANTalonInfo(5, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulatedEncoderFactor)); this.rightLeader = factory - .createCANTalon(new CANTalonInfo(2, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, 1)); + .createCANTalon(new CANTalonInfo(2, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulatedEncoderFactor)); this.rightFollower1 = factory - .createCANTalon(new CANTalonInfo(4, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, 1)); + .createCANTalon(new CANTalonInfo(4, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulatedEncoderFactor)); this.rightFollower2 = factory - .createCANTalon(new CANTalonInfo(6, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, 1)); - - leftLeader.createTelemetryProperties(this.getPrefix(), "LeftLeader"); - rightLeader.createTelemetryProperties(this.getPrefix(), "RightLeader"); + .createCANTalon(new CANTalonInfo(6, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulatedEncoderFactor)); this.distanceSensor = factory.createAnalogDistanceSensor(1, VoltageMaps::sharp0A51SK); this.distanceSensor2 = factory.createAnalogDistanceSensor(2, VoltageMaps::sharp0A51SK); - XCANTalon.configureMotorTeam("LeftDrive", "LeftLeader", leftLeader, leftFollower1, leftFollower2, true, true, true, true); - XCANTalon.configureMotorTeam("RightDrive", "RightLeader", rightLeader, rightFollower1, rightFollower2, true, true, true, true); + XCANTalon.configureMotorTeam(this.getPrefix(), "LeftLeader", leftLeader, leftFollower1, leftFollower2, true, true, true, true); + XCANTalon.configureMotorTeam(this.getPrefix(), "RightLeader", rightLeader, rightFollower1, rightFollower2, true, true, true, true); this.register(); } diff --git a/src/main/java/competition/subsystems/pose/PoseSubsystem.java b/src/main/java/competition/subsystems/pose/PoseSubsystem.java index e0af6ca..324933f 100644 --- a/src/main/java/competition/subsystems/pose/PoseSubsystem.java +++ b/src/main/java/competition/subsystems/pose/PoseSubsystem.java @@ -13,21 +13,26 @@ public class PoseSubsystem extends BasePoseSubsystem { DriveSubsystem drive; + // each wheel revolution is 256 ticks, and the wheels are 6 inches in diameter. + // this means each revolution would move the robot (if not slipping at all) 6*pi inches. + // So, one tick would move us (6*pi)/256 inches + // Conversely, we can + private double scalingFactorFromTicksToInches = 6.0 * Math.PI / 256.0; + @Inject public PoseSubsystem(CommonLibFactory clf, PropertyFactory propManager, DriveSubsystem drive) { super(clf, propManager); this.drive = drive; } - @Override protected double getLeftDriveDistance() { - return drive.leftLeader.getSelectedSensorPosition(0); + return drive.leftLeader.getSelectedSensorPosition(0) * scalingFactorFromTicksToInches; } @Override protected double getRightDriveDistance() { - return drive.rightLeader.getSelectedSensorPosition(0); + return drive.rightLeader.getSelectedSensorPosition(0) * scalingFactorFromTicksToInches; } } \ No newline at end of file