Skip to content

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

Description

@aolgeirson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions