-
Notifications
You must be signed in to change notification settings - Fork 1
Algae Alignment State Machine #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fabdf4c
379f70d
a72724c
6436eee
eb549ce
97591c1
b0abc7d
e054f30
8622d06
aad0f79
cae8a72
bc5ce4e
9df0377
91196ab
aaed49b
3db87b8
d170d25
a609a8d
e97a4e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
| import competition.subsystems.drive.DriveSubsystem; | ||
| import competition.subsystems.vision.AprilTagVisionSubsystemExtended; | ||
| import competition.subsystems.vision.CoprocessorCommunicationSubsystem; | ||
| import edu.wpi.first.math.estimator.DifferentialDrivePoseEstimator; | ||
| import edu.wpi.first.math.estimator.PoseEstimator; | ||
| import edu.wpi.first.math.estimator.SwerveDrivePoseEstimator; | ||
| import edu.wpi.first.math.geometry.Pose2d; | ||
|
|
@@ -25,6 +24,7 @@ | |
|
|
||
| import static edu.wpi.first.units.Units.Meters; | ||
|
|
||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import edu.wpi.first.wpilibj2.command.Commands; | ||
| import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
|
@@ -39,7 +39,6 @@ | |
| import xbot.common.properties.Property; | ||
| import xbot.common.properties.PropertyFactory; | ||
| import xbot.common.subsystems.pose.BasePoseSubsystem; | ||
| import xbot.common.subsystems.vision.AprilTagVisionSubsystem; | ||
|
|
||
| @Singleton | ||
| public class PoseSubsystem extends BasePoseSubsystem { | ||
|
|
@@ -398,16 +397,32 @@ public void ingestSimulatedSwerveModulePositions(SwerveModulePosition[] position | |
| this.simulatedModulePositions = Optional.of(positions); | ||
| } | ||
|
|
||
| public static List<Pose2d> getBlueReefFacePoses() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⭐ I know you're just extending an existing pattern, but the approach here to finding the "nearest" involves creating a bunch of objects and then disposing of them afterwards. Would be nice to have something more like the following:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't change this now, but in a follow-up PR
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Onto it! |
||
| return Arrays.asList( | ||
| Landmarks.BlueCloseAlgae, | ||
| Landmarks.BlueCloseLeftAlgae, | ||
| Landmarks.BlueCloseRightAlgae, | ||
| Landmarks.BlueFarLeftAlgae, | ||
| Landmarks.BlueFarAlgae, | ||
| Landmarks.BlueFarRightAlgae); | ||
| } | ||
|
|
||
| public Pose2d getClosestReefFacePose() { | ||
| Pose2d currentPose = getCurrentPose2d(); | ||
|
|
||
| List<Pose2d> reefFacePoses = Arrays.asList( | ||
| convertBlueToRedIfNeeded(Landmarks.BlueCloseAlgae), | ||
| convertBlueToRedIfNeeded(Landmarks.BlueCloseLeftAlgae), | ||
| convertBlueToRedIfNeeded(Landmarks.BlueCloseRightAlgae), | ||
| convertBlueToRedIfNeeded(Landmarks.BlueFarLeftAlgae), | ||
| convertBlueToRedIfNeeded(Landmarks.BlueFarAlgae), | ||
| convertBlueToRedIfNeeded(Landmarks.BlueFarRightAlgae)); | ||
| List<Pose2d> reefFacePoses = getBlueReefFacePoses(); | ||
| reefFacePoses.replaceAll(PoseSubsystem::convertBlueToRedIfNeeded); | ||
|
|
||
| return currentPose.nearest(reefFacePoses); | ||
| } | ||
|
|
||
| public Pose2d getClosestReefFacePoseByAlliance(DriverStation.Alliance alliance) { | ||
| Pose2d currentPose = getCurrentPose2d(); | ||
|
|
||
| List<Pose2d> reefFacePoses = getBlueReefFacePoses(); | ||
| if (alliance == DriverStation.Alliance.Red) { | ||
| reefFacePoses.replaceAll(PoseSubsystem::convertBluetoRed); | ||
| } | ||
|
|
||
| return currentPose.nearest(reefFacePoses); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.