pathplanner
pathplanner copied to clipboard
PathPlannerPath::samplePath() can attempt to access a bad optional
Describe the bug
Occasionally, when calling PathPlannerPath::samplePath() on a short path with only a start and end waypoint defined by the user, the robot code will crash.
To Reproduce See https://www.chiefdelphi.com/t/pathplanner-throwing-a-bad-optional-access-exception-on-path-construction/498617/2 for more info (example code, callstacks, etc.)
Expected behavior The code won't crash.
Versions: (please complete the following information):
- OS: Arch Linux
- GUI Version: 2025.2.2
- PPLib Version: 2025.2.2
- PPLib Language: C++
Additional context
The issue occurs on line 929 of
pathplanner/pathplannerlib/src/main/native/cpp/pathplanner/lib/path/PathPlannerPath.cppdue to calling.value()without first checking for validity. I am more than happy to create a PR for this issue, but I don't know what the desired behaviour should be if a cubic lerp cannot be created due to too few paths.