pathplanner icon indicating copy to clipboard operation
pathplanner copied to clipboard

PathPlannerPath::samplePath() can attempt to access a bad optional

Open Cynosure-null opened this issue 9 months ago • 8 comments

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.cpp due 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.

Cynosure-null avatar Apr 10 '25 00:04 Cynosure-null