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

Added buildAutoChooser to C++ lib #670

Merged
merged 8 commits into from
Apr 4, 2024
Merged

Conversation

ThePhoenixFox
Copy link
Contributor

Added a equivalent version of buildAutoChooser for cpp from java.
Using the std::filesystem, we can inspect the files on the drive.
Since SendableChooser doesn't allow for rvalue storage, we need to store the commands ourselves so the user will not get a nullptr when trying to access a command* from GetSelected().

@github-actions github-actions bot added the PathPlannerLib Changes to PathPlannerLib label Mar 31, 2024
@mjansen4857
Copy link
Owner

I'd recommend running builds locally to help find any issues a bit easier.

./gradlew build

You can also fix formatting issues with ./gradlew spotlessApply

@ThePhoenixFox
Copy link
Contributor Author

Sorry, this is my first time doing this. When I tried to run gradlew on my device, I got errors saying that the settings couldn't be found.

@mjansen4857
Copy link
Owner

mjansen4857 commented Apr 1, 2024

No worries.

I usually have pretty good luck with IntelliJ so you might want to give that a try. It has built in gradle support that usually takes care of setting up everything without any issues.

WPILib VSCode also works. The "Build robot code" option should do the same thing. Does that work for you? You have to also make sure you have the pathplannerlib folder open and not the root pathplanner repo folder or it won't work.

@github-actions github-actions bot added the documentation Pull requests that update the documentation site files label Apr 2, 2024
@ThePhoenixFox
Copy link
Contributor Author

There are two versions of getAutonomousCommand() in the Writerside wiki. The first one is the easy readable one while the second one creates a frc2::CommandPtr since that is what most example programs use for their default return type.

frc2::Command* RobotContainer::getAutonomousCommand() {
// Returns a frc2::Command* that is freed at program termination
return autoChooser.GetSelected();
}
frc2::CommandPtr RobotContainer::getAutonomousCommand() {
// Returns a copy that is freed after reference is lost
return frc2::CommandPtr(std::make_unique<frc2::Command>(*autoChooser.GetSelected()));
}

@mjansen4857 mjansen4857 merged commit bb0a70f into mjansen4857:main Apr 4, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Pull requests that update the documentation site files PathPlannerLib Changes to PathPlannerLib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants