-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added capability for choreo trajectory following
- Loading branch information
Showing
18 changed files
with
460 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
{ | ||
"type": "path", | ||
"data": { | ||
"pathName": "Example Path" | ||
"pathName": "ShootAndTaxi1" | ||
} | ||
} | ||
] | ||
|
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
package frc.robot; | ||
|
||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.math.util.Units; | ||
|
||
/** | ||
* Contains various field dimensions and useful reference points. Dimensions are in meters, and sets | ||
* of corners start in the lower left moving clockwise. <b>All units in Meters</b> <br> | ||
* <br> | ||
* | ||
* <p>All translations and poses are stored with the origin at the rightmost point on the BLUE | ||
* ALLIANCE wall.<br> | ||
* <br> | ||
* Length refers to the <i>x</i> direction (as described by wpilib) <br> | ||
* Width refers to the <i>y</i> direction (as described by wpilib) | ||
*/ | ||
public class FieldConstants { | ||
public static double fieldLength = Units.inchesToMeters(653.22); | ||
public static double fieldWidth = Units.inchesToMeters(323.28); | ||
public static double wingX = Units.inchesToMeters(229.201); | ||
|
||
public static double podiumX = Units.inchesToMeters(121); | ||
public static double startingLineX = Units.inchesToMeters(74.111); | ||
|
||
public static final class StagingLocations { | ||
public static double centerlineX = Units.inchesToMeters(fieldLength / 2); | ||
// need to update | ||
public static double centerlineFirstY = Units.inchesToMeters(-1); | ||
public static double centerlineSeparationY = Units.inchesToMeters(66); | ||
public static double spikeX = Units.inchesToMeters(114); | ||
// need | ||
public static double spikeFirstY = Units.inchesToMeters(-1); | ||
public static double spikeSeparationY = Units.inchesToMeters(57); | ||
|
||
public static Translation2d[] centerlineTranslations = new Translation2d[5]; | ||
public static Translation2d[] spikeTranslations = new Translation2d[3]; | ||
|
||
static { | ||
for (int i = 0; i < centerlineTranslations.length; i++) { | ||
centerlineTranslations[i] = | ||
new Translation2d(centerlineX, centerlineFirstY + (i * centerlineSeparationY)); | ||
} | ||
} | ||
|
||
static { | ||
for (int i = 0; i < spikeTranslations.length; i++) { | ||
spikeTranslations[i] = new Translation2d(spikeX, spikeFirstY + (i * spikeSeparationY)); | ||
} | ||
} | ||
} | ||
} |
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
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,3 @@ | ||
package frc.robot.subsystems.drive; | ||
|
||
public class DriveConstants {} |
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
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
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
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,66 @@ | ||
package frc.robot.util; | ||
|
||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.wpilibj.DriverStation; | ||
import edu.wpi.first.wpilibj.DriverStation.Alliance; | ||
import frc.robot.FieldConstants; | ||
import frc.robot.util.trajectory.HolonomicDriveController; | ||
|
||
/** Utility functions for flipping from the blue to red alliance. */ | ||
public class AllianceFlipUtil { | ||
/** Flips an x coordinate to the correct side of the field based on the current alliance color. */ | ||
public static double apply(double xCoordinate) { | ||
if (shouldFlip()) { | ||
return FieldConstants.fieldLength - xCoordinate; | ||
} else { | ||
return xCoordinate; | ||
} | ||
} | ||
|
||
/** Flips a translation to the correct side of the field based on the current alliance color. */ | ||
public static Translation2d apply(Translation2d translation) { | ||
if (shouldFlip()) { | ||
return new Translation2d(apply(translation.getX()), translation.getY()); | ||
} else { | ||
return translation; | ||
} | ||
} | ||
|
||
/** Flips a rotation based on the current alliance color. */ | ||
public static Rotation2d apply(Rotation2d rotation) { | ||
if (shouldFlip()) { | ||
return new Rotation2d(-rotation.getCos(), rotation.getSin()); | ||
} else { | ||
return rotation; | ||
} | ||
} | ||
|
||
/** Flips a pose to the correct side of the field based on the current alliance color. */ | ||
public static Pose2d apply(Pose2d pose) { | ||
if (shouldFlip()) { | ||
return new Pose2d(apply(pose.getTranslation()), apply(pose.getRotation())); | ||
} else { | ||
return pose; | ||
} | ||
} | ||
|
||
/** | ||
* Flips a trajectory state to the correct side of the field based on the current alliance color. | ||
*/ | ||
public static HolonomicDriveController.HolonomicDriveState apply( | ||
HolonomicDriveController.HolonomicDriveState state) { | ||
if (shouldFlip()) { | ||
return new HolonomicDriveController.HolonomicDriveState( | ||
apply(state.pose()), -state.velocityX(), state.velocityY(), -state.angularVelocity()); | ||
} else { | ||
return state; | ||
} | ||
} | ||
|
||
public static boolean shouldFlip() { | ||
return DriverStation.getAlliance().isPresent() | ||
&& DriverStation.getAlliance().get() == Alliance.Red; | ||
} | ||
} |
Oops, something went wrong.