-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat/automate low scoring #37
Open
viveknadig282
wants to merge
3
commits into
fix/testing-tuning-4-12
Choose a base branch
from
feat/automate-low-scoring
base: fix/testing-tuning-4-12
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -8,9 +8,11 @@ | |
package frc.robot.auto.pathgeneration.commands; | ||
|
||
import static frc.robot.Constants.FeatureFlags.kAutoOuttakeEnabled; | ||
import static frc.robot.Constants.FeatureFlags.kDirectionBasedLowScoreEnabled; | ||
import static frc.robot.auto.dynamicpathgeneration.DynamicPathConstants.*; | ||
import static frc.robot.led.LEDConstants.*; | ||
|
||
import edu.wpi.first.math.MathUtil; | ||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Transform2d; | ||
|
@@ -54,6 +56,7 @@ public enum GridScoreHeight { | |
private BooleanSupplier cancelCommand; | ||
private BooleanSupplier isCurrentLEDPieceCone; | ||
private BooleanSupplier isAutoScoreMode; | ||
private boolean isRedAlliance; | ||
|
||
public AutoScore( | ||
SwerveDrive swerveDrive, | ||
|
@@ -77,8 +80,25 @@ public AutoScore( | |
this.cancelCommand = cancelCommand; | ||
} | ||
|
||
// This checks if the robot's front side is facing the target or if the robot's backside is facing | ||
// the target | ||
|
||
private boolean isAlignedFront() { | ||
if(!kDirectionBasedLowScoreEnabled) return false; | ||
|
||
double currentRobotAngle = | ||
MathUtil.angleModulus(swerveSubsystem.getPose().getRotation().getRadians()); | ||
viveknadig282 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (isRedAlliance) { | ||
return Math.abs(currentRobotAngle) < Math.PI/2; | ||
} else { | ||
viveknadig282 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Math.abs(currentRobotAngle) > Math.PI/2; | ||
} | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
this.isRedAlliance = DriverStation.getAlliance() == Alliance.Red; | ||
|
||
System.out.println( | ||
"Is running auto score instead of presets: " + isAutoScoreMode.getAsBoolean()); | ||
if (!isAutoScoreMode.getAsBoolean()) { | ||
|
@@ -113,10 +133,16 @@ public void initialize() { | |
.schedule(); | ||
break; | ||
case LOW: | ||
new SetEndEffectorState( | ||
elevatorSubsystem, | ||
armSubsystem, | ||
SetEndEffectorState.EndEffectorPreset.SCORE_ANY_LOW) | ||
new ConditionalCommand( | ||
new SetEndEffectorState( | ||
elevatorSubsystem, | ||
armSubsystem, | ||
SetEndEffectorState.EndEffectorPreset.SCORE_ANY_LOW_FRONT), | ||
new SetEndEffectorState( | ||
elevatorSubsystem, | ||
armSubsystem, | ||
SetEndEffectorState.EndEffectorPreset.SCORE_ANY_LOW_BACK), | ||
this::isAlignedFront) | ||
.schedule(); | ||
break; | ||
} | ||
|
@@ -128,7 +154,7 @@ public void initialize() { | |
|
||
// Get scoring location id from SD | ||
int locationId = (int) SmartDashboard.getNumber("guiColumn", -1); | ||
if (DriverStation.getAlliance() == Alliance.Blue) { | ||
if (!isRedAlliance) { | ||
locationId = 8 - locationId; | ||
} | ||
if (0 > locationId || locationId > 8) { | ||
|
@@ -142,7 +168,7 @@ public void initialize() { | |
GamePiece scoringGamePiece = kScoringLocationPiece[locationId]; | ||
|
||
System.out.println("Running: Go to grid (id: " + locationId + ") from " + start); | ||
if (DriverStation.getAlliance() == Alliance.Red) { | ||
if (isRedAlliance) { | ||
scoringWaypoint = PathUtil.flip(scoringWaypoint); | ||
} | ||
Command moveToScoringWaypoint; | ||
|
@@ -198,10 +224,11 @@ public void initialize() { | |
default: | ||
scoringLocation = kBottomBlueScoringPoses[locationId]; | ||
moveArmElevatorToPreset = | ||
new SetEndEffectorState( | ||
elevatorSubsystem, | ||
armSubsystem, | ||
SetEndEffectorState.EndEffectorPreset.SCORE_ANY_LOW); | ||
new SetEndEffectorState( | ||
elevatorSubsystem, | ||
armSubsystem, | ||
SetEndEffectorState.EndEffectorPreset.SCORE_ANY_LOW_BACK); | ||
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. When we auto score we score in the front so we should change this to |
||
break; | ||
} | ||
|
||
if (FeatureFlags.kIntakeAutoScoreDistanceSensorOffset) { | ||
|
@@ -211,7 +238,7 @@ public void initialize() { | |
new Translation2d(0, intakeSubsystem.getGamePieceOffset()), new Rotation2d())); | ||
} | ||
|
||
if (DriverStation.getAlliance() == Alliance.Red) { | ||
if (isRedAlliance) { | ||
scoringLocation = PathUtil.flip(scoringLocation); | ||
viveknadig282 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this false before we test