-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from SaintsRobotics/swerve
Swerve Code
- Loading branch information
Showing
14 changed files
with
1,228 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"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 | ||
} | ||
], | ||
"robotJoysticks": [ | ||
{ | ||
"guid": "Keyboard0" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"NTProvider": { | ||
"types": { | ||
"/FMSInfo": "FMSInfo", | ||
"/SmartDashboard/Field": "Field2d" | ||
}, | ||
"windows": { | ||
"/SmartDashboard/Field": { | ||
"window": { | ||
"visible": true | ||
} | ||
} | ||
} | ||
}, | ||
"NetworkTables Info": { | ||
"visible": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot; | ||
|
||
import edu.wpi.first.math.VecBuilder; | ||
import edu.wpi.first.math.Vector; | ||
import edu.wpi.first.math.geometry.Pose3d; | ||
import edu.wpi.first.math.geometry.Rotation3d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.math.kinematics.SwerveDriveKinematics; | ||
import edu.wpi.first.math.numbers.N3; | ||
|
||
/** | ||
* The Constants class provides a convenient place for teams to hold robot-wide | ||
* numerical or boolean | ||
* constants. This class should not be used for any other purpose. All constants | ||
* should be declared | ||
* globally (i.e. public static). Do not put anything functional in this class. | ||
* | ||
* <p> | ||
* It is advised to statically import this class (or one of its inner classes) | ||
* wherever the | ||
* constants are needed, to reduce verbosity. | ||
*/ | ||
public final class Constants { | ||
|
||
/** | ||
* Input/Output constants | ||
*/ | ||
public static final class IOConstants { | ||
public static final int kDriverControllerPort = 0; | ||
|
||
public static final double kControllerDeadband = 0.2; | ||
public static final double kSlowModeScalar = 0.8; | ||
} | ||
|
||
public static final class DriveConstants { | ||
// TODO: set motor and encoder constants | ||
public static final int kFrontLeftDriveMotorPort = 32; | ||
public static final int kRearLeftDriveMotorPort = 29; | ||
public static final int kFrontRightDriveMotorPort = 38; | ||
public static final int kRearRightDriveMotorPort = 34; | ||
|
||
public static final int kFrontLeftTurningMotorPort = 28; | ||
public static final int kRearLeftTurningMotorPort = 22; | ||
public static final int kFrontRightTurningMotorPort = 37; | ||
public static final int kRearRightTurningMotorPort = 26; | ||
|
||
public static final int kFrontLeftTurningEncoderPort = 19; | ||
public static final int kRearLeftTurningEncoderPort = 20; | ||
public static final int kFrontRightTurningEncoderPort = 18; | ||
public static final int kRearRightTurningEncoderPort = 17; | ||
|
||
public static final double kFrontLeftTurningEncoderOffset = 0; | ||
public static final double kRearLeftTurningEncoderOffset = 0; | ||
public static final double kFrontRightTurningEncoderOffset = 0; | ||
public static final double kRearRightTurningEncoderOffset = 0; | ||
|
||
// TODO: Test motor orientations before driving on an actual robot | ||
public static final boolean kFrontLeftDriveMotorReversed = false; | ||
public static final boolean kRearLeftDriveMotorReversed = false; | ||
public static final boolean kFrontRightDriveMotorReversed = true; | ||
public static final boolean kRearRightDriveMotorReversed = true; | ||
|
||
/** Distance between centers of right and left wheels on robot (in meters). */ | ||
public static final double kTrackWidth = 0.57785; | ||
|
||
/** Distance between front and back wheels on robot (in meters). */ | ||
public static final double kWheelBase = 0.57785; | ||
|
||
/** Diameter of each wheel in the SDS MK4i swerve module (in meters) */ | ||
public static final double kWheelDiameterMeters = 0.1; | ||
|
||
/** Gear ratio between the motor and the wheel. */ | ||
public static final double kDrivingGearRatio = 8.14; // SDS MK4i's in L1 Configuration | ||
// public static final double kDrivingGearRatio = 6.75; // SDS MK4i's in L2 configuration | ||
|
||
// TODO: Tune this PID before running on a robot on the ground | ||
public static final double kPModuleTurningController = -0.3; | ||
|
||
public static final SwerveDriveKinematics kDriveKinematics = new SwerveDriveKinematics( | ||
new Translation2d(kWheelBase / 2, kTrackWidth / 2), | ||
new Translation2d(kWheelBase / 2, -kTrackWidth / 2), | ||
new Translation2d(-kWheelBase / 2, kTrackWidth / 2), | ||
new Translation2d(-kWheelBase / 2, -kTrackWidth / 2)); | ||
|
||
/** For a a SDS Mk4i L1 swerve base with Neo Vortexes */ | ||
public static final double kMaxSpeedMetersPerSecond = 4.4196; | ||
/** For a a SDS Mk4i L1 swerve base with Neo Vortexes */ | ||
public static final double kMaxAngularSpeedRadiansPerSecond = 10.8164; | ||
// ^^ Calculated using the method taken from the old SDS github example | ||
|
||
/** Heading Correction */ | ||
public static final double kHeadingCorrectionTurningStopTime = 0.2; | ||
// TODO: Tune this PID before running on a robot on the ground | ||
public static final double kPHeadingCorrectionController = 5; | ||
} | ||
|
||
public static final class ShooterConstants { | ||
public static final int kTopShooterMotorPort = 35; | ||
public static final int kBottomShooterMotorPort = 20; | ||
} | ||
|
||
public static final class VisionConstants { | ||
// TODO: Update cam pose relative to center of bot | ||
public static final Pose3d kCamPose = new Pose3d(0, 0, 0, new Rotation3d(0, 0, 0)); | ||
public static final double[] kLimelightCamPose = { | ||
kCamPose.getX(), | ||
kCamPose.getY(), | ||
kCamPose.getZ(), | ||
kCamPose.getRotation().getX(), | ||
kCamPose.getRotation().getY(), | ||
kCamPose.getRotation().getZ() }; | ||
|
||
// TODO: Experiment with different std devs in the pose estimator | ||
public static final Vector<N3> kOdometrySTDDevs = VecBuilder.fill(0.1, 0.1, 0.1); | ||
public static final Vector<N3> kVisionSTDDevs = VecBuilder.fill(0.9, 0.9, 0.9); | ||
|
||
// Field size in meters | ||
public static final double kFieldWidth = 8.21055; | ||
public static final double kFieldLength = 16.54175; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.