Skip to content

Feat/precompute pathing#361

Merged
AskewParity merged 19 commits into
mainfrom
feat/precompute-pathing
May 19, 2026
Merged

Feat/precompute pathing#361
AskewParity merged 19 commits into
mainfrom
feat/precompute-pathing

Conversation

@AskewParity
Copy link
Copy Markdown
Contributor

@AskewParity AskewParity commented May 8, 2026

closes #342 #350 #360... sorry for the bloat

Changes

  • Add new item in mission_state::next_waypoint_path and associated functions, which is the waypoint-->waypoint path
  • path_gen now precomputes all new paths (they must be in sequence now)
  • fly_waypoints no longer generates new paths
  • add new method in static::calculateFinalAngle() to rougly approximate the angle of an existing path
  • unit tests for the calculateFinalAngle

Testing

  • There exist unit tests, you should probably think of the scope of the unit tests being larger (or to encompass other parts of the pr)

TODO

  • fix the remaining pathing unit tests
  • naming
  • angles. The current error in angle is pretty big (anywhere between 10-20 deg.)
    • It may be possible to retrieve the angle from the RRT process, but right now, that data is encapsulated

@AskewParity AskewParity marked this pull request as ready for review May 13, 2026 02:44
Copy link
Copy Markdown
Contributor

@miyatakazuya miyatakazuya left a comment

Choose a reason for hiding this comment

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

I left a few comments on some minor syntax issues and error handling, but overall the changes are good. The exit angle calculation although not nearly perfect does seem to be much more performant in terms nicer looking sitl paths. The PR also makes our encapsulation alot better in our ticks. I think once the comments are addressed I'll re-review really quick and it should be good to merge 🦖

Comment thread include/pathing/static.hpp Outdated
* @return angle of exit (+x-axis is 0 deg, ccw is positive)
*/
double calculateFinalAngle(const MissionPath& path,
const std::optional<CartesianConverter<GPSProtoVec>> cartesianConverter);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cartesianConverter can be a reference to avoid a copy

Comment thread include/pathing/static.hpp
Comment thread src/pathing/static.cpp
Comment on lines +632 to +633
XYZCoord pt1 = cartesianConverter->toXYZ(coords[coords.size() - 2]);
XYZCoord pt2 = cartesianConverter->toXYZ(coords[coords.size() - 1]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should cartesianConverter be optional at all? By the time PathGenTick is running the mission upload must have occured, so the converter should exist.

I think its fine to keep it optional for our sanity, but then we should check the optional has a value before dereferencing it here

Comment thread src/pathing/static.cpp

std::vector<GPSCoord> output_coords;
for (const XYZCoord &waypoint : path) {
output_coords.push_back(state->getCartesianConverter()->toLatLng(waypoint));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unsafe optional reference with cartesianConverter (i feel like i have something against cartesian converter or smth idk why i keep spotting these

Comment thread src/pathing/static.cpp
}

MissionPath generateSearchPath(std::shared_ptr<MissionState> state) {
std::vector<GPSCoord> generateSearchPath(std::shared_ptr<MissionState> state, double start_angle) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing a bounds check for the waypoints? I might be misinterpreting it but why is there a bounds check in generateNextWaypointPath to check that we have at least 1 waypoint but not here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The number of waypoints must be greater than 1 for the code to execute generate SearchPath.

Comment thread src/ticks/fly_search.cpp Outdated
Comment thread src/ticks/fly_search.cpp
Comment thread src/ticks/path_gen.cpp
Comment thread src/ticks/path_gen.cpp Outdated
@AskewParity AskewParity requested a review from miyatakazuya May 15, 2026 01:01
Copy link
Copy Markdown
Contributor

@miyatakazuya miyatakazuya left a comment

Choose a reason for hiding this comment

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

The changes implemented addresses the comments well. I think optional for the cartesianConverter can be addressed at some point, but the assert solution is fine with me for now. LGTM 🦖

@AskewParity AskewParity merged commit a046993 into main May 19, 2026
2 checks passed
kimichenn pushed a commit that referenced this pull request May 19, 2026
* feat: precompute all paths

* chore: add buffer between computed paths

* feat; consolidate waypoints into one mission

* deleted existence of next waypoint

* revert: revert past 2 commits

* fix: prevent duplicate path decrement

* feat: add clear mav mission

* fix: change mavlink mission upload scheme

* feat: unit tests + refactor code

* chore: lint

* chore: revert cout in gcs_routes

* chore: ensure mission starts

* chore: ensure that path has enough points before deleting

* chore: lint

* feat: assert existance of cartesean converter

* chore: pass cartesean converter by reference

* chore: create check for search path generation

---------

Co-authored-by: Braxten Nguyen <braxtennguyen556@gmail.com>
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.

Lap Race Condition

3 participants