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

[choreolib] [cpp] Trajectory::GetTotalTime() doesn't unwrap optional, renders class virtually unusable #1147

Closed
bathtubed opened this issue Jan 15, 2025 · 0 comments · Fixed by #1149

Comments

@bathtubed
Copy link

In Trajectory.h

  /**
   * The total time the trajectory will take to follow
   *
   * @return The total time the trajectory will take to follow, if empty will
   * return 0 seconds.
   */
  units::second_t GetTotalTime() const {
    if (samples.size() == 0) {
      return 0_s;
    }
    return GetFinalSample().GetTimestamp();
  }

Code which uses GetTotalTime (or SampleAt, which calls into GetTotalTime) breaks due to the return statement in this method. GetFinalSample returns an optional so it should read

return GetFinalSample().value().GetTimestamp();

The optional doesn't need to be checked since the method already verifies that the trajectory isn't empty.

I would submit a PR but I don't have the bandwidth right now to set up an entire testing environment just to add 8 characters to a file, so I apologize.

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 a pull request may close this issue.

1 participant