Skip to content

Conversation

@StarrryNight
Copy link
Contributor

@StarrryNight StarrryNight commented Dec 28, 2025

Description

This PR resolves issue #3546, TrajectoryPlanner::getTrajectoryWithCost can be cleaned up by delegating the task of either using a cached collision value or a new one to a separate class. It is a subissue of #3104 .
#3546

The main task of this ticket was to simplify TrajectoryPlanner:getTrajectoryWithCost by delegating the evaluation of collision values to a new class -- CollisionEvaluator. The old logic was preserved, but the code is more modular.

Testing Done

All test cases for TrajectoryPlanner passed. I dd not write new test cases for the new class separately as the class should be well tested by TrajectoryPlanner for now. However, I think it will be better to have a TestTrajectoryPlanner file for some individual tests, just in case CollisionEvaluator is used somewhere else. I will open a new issue for this.

Resolved Issues

#3546

Length Justification and Key Files to Review

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • [x ] Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • [x ] Remove all commented out code
  • [ x] Remove extra print statements: for example, those just used for testing
  • [ x] Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

// Avoid finding the first non-collision time if the cache sub-trajectory
// has a collision time.
if (sub_traj_with_cost.has_value() &&
sub_traj_with_cost->collision_duration_front_s < sub_traj_duration_s)
Copy link
Contributor

@adrianchan787 adrianchan787 Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since sub_traj_duration_s is an optional, does it need either dereference operator or .value()? (though I assume if it compiles, it automatically does this so yeah)

Copy link
Contributor

@adrianchan787 adrianchan787 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue itself looks great, also tried to find improvements in the collision code but couldn't find any. Added a few comments, though they are extremely small things

* @param traj_path The trajectory path to check
* @param start_time_s The time in seconds to start the search from
* @param search_end_time_s The time in seconds to stop the search at
* @return The first collision time within [start_time_sec and search_end_time_s]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really really really nitpicky and useless comment, maybe spec should include mention of COLLISION_CHECK_STEP_INTERVAL_SEC. I believe "the first collision time within [start time sec and search end time s] is technically incorrect, maybe something like "the first collision time within [start time sec and search end time s] using a COLLISION_CHECK_STEP_INTERVAL_SEC resolution"? (super super nitpicky though, probably not worth changing)

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 this pull request may close these issues.

2 participants