Skip to content
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

Replaced orElseGet in docs for starting pose #947

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Daniel1464
Copy link

Replaced the orElseGet in the docs in favor of isEmpty() checks for the starting pose's Optional.

Both of them work the same way, but an explicit isEmpty() check + returning a void routine makes it easier for rookie coders reading the documentation.

(Also corrects an invalid Commands.none() return in a method that returns an AutoRoutine)

.andThen(
autoAimAndShoot(),
race(
intake(),
ampToC1.cmd(),
aimFor(ampToC1.getFinalPose().orElseGet(Pose2d::new))))
aimFor(ampToC1.getFinalPose().orElse(new Pose2d()))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk how this even got here but it shouldn't be here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No yeah i replaced it on purpose; i think i should revert it tho

routine.kill();
return new Pose2d();
}))
resetOdometry(initialPose.get())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, this method is prone to error as it is only evaluating if the initial pose of the trajectory should be flipped when fivePieceAutoTriggerSeg is invoked. If the user is using AutoChooser, this would be when the auto is selected, at which point the robot may know the correct alliance. However assuming a worst case scenario where the user is utilizing the traditional SendableChooser or a custom solution, the segment would be initialized at startup. resetOdometry() should either be expected to accept a Pose2d supplier, or should be deferred. I understand this issue isn't the initial scope of the PR however I feel it is relevant.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I get what you mean. I'll prob change it to a Pose2d supplier(the OG docs also didn't cover this use case).

routine.kill();
return new Pose2d();
}))
resetOdometry(initialPose.get())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

}

Command ret = sequence(
resetOdometry(startinNoteOwnedose),
resetOdometry(initialPose.get()),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants