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

1043 Handle crossing paths in path follow #1058

Merged
merged 5 commits into from
Nov 26, 2022

Conversation

Ezward
Copy link
Contributor

@Ezward Ezward commented Nov 7, 2022

Issue #1043

Update the path_follow template so that it can handle paths that have cross-overs. The current code tests every point in the path to find the closest point. This means that it is possible that a point on a cross-over going in the opposite direction may get selected. The approach to fix this is to make the search start at the most recent closest point and limit the search to a configurable number of points. So for instance, consider a perfectly symmetrical figure 8 path with 1000 waypoints in the path whose origin is at the top of the figure 8; then the intersection as at point 250 and point 750. If we limit the search to 250 points then only 1/4 of the path will be searched. If we have driving to the intersection from then origin, then if we are at the the 250th point. We would then search from point 250 to point 500, and so we never get close the other intersection point at 750.

To implement this we updated these parts:

Update CTE part

  • uses a different algorithm to find the closest point.
  • It allows for an offset to start the search and a maximum number of points to search.
  • It allows the number of points to look ahead and look behind when returning the track that should be followed. This allows the algorithm to adjust smoothing and allows a longer look ahead to handle shorter distances between waypoints and/or faster driving speeds.
  • The run method now returns the index of the nearest point so we can keep track of it and use it as the offset when searching for the nearest point.

Update OriginOffset part

  • run method takes the index of the closest point and returns it, so that it can reset it to the start of the path when the origin is reset.

We then updated the path_follow.py template to use the updated parts and we updated cfg_path_follow.py to include configuration for number of search points, as well as the number of look ahead and look behind points used to calculate the track to follow.

Ezward and others added 3 commits November 3, 2022 10:58
- the nearest point search is can be started at
  any point and limited to a given number of points.
  This is so we can handle crossover paths.
- the track that is returned can be configured
  for how many points ahead and behind the
  nearest point should be included
- update inputs and outputs to match new CTE.run() method
- update CTE constructor to take configuration for path search
- update run method to accept from_pt and return closest_pt to
  maintain the search offset.
- when we reset the origin we need to reset the
  starting search index of the cte algorithm
@Ezward Ezward self-assigned this Nov 7, 2022
- start origin at (0,0)
- test makes sure origin translation is applied
- test makes sure the closest point is reset when origin is reset
@Ezward Ezward marked this pull request as ready for review November 22, 2022 01:16
donkeycar/parts/path.py Outdated Show resolved Hide resolved
donkeycar/parts/path.py Outdated Show resolved Hide resolved
donkeycar/parts/path.py Outdated Show resolved Hide resolved
donkeycar/parts/path.py Outdated Show resolved Hide resolved
donkeycar/tests/test_path.py Show resolved Hide resolved
Copy link
Contributor

@DocGarbanzo DocGarbanzo left a comment

Choose a reason for hiding this comment

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

This looks good to me, I have only very minor comments.

@Ezward
Copy link
Contributor Author

Ezward commented Nov 26, 2022

@DocGarbanzo thank you for those comments. I updated the code and responded in comments.

donkeycar/tests/test_path.py Show resolved Hide resolved
@Ezward Ezward merged commit 5095b3f into main Nov 26, 2022
@Ezward Ezward deleted the handle-crossing-paths-in-path-follow branch November 26, 2022 21:47
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.

None yet

2 participants