Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved Problem
This PR introduces the following updates to the pure pursuit library
Transforming from class to namespace
The pure pursuit algorithm does not require to save any values between calculations, therefor it makes more sense to implement it as a function rather than a class.
In addition to the returned
targetBearing
additional values of interest can be accesses throught the newpure_pursuit_status
struct that is passed as a reference tocalcTargetBearing
.Logging
The
pure_pursuit_status
struct can be published and used to log relevant values, which makes tuning of the pure pursuit algorithm easier.Pure pursuit edge case
The pure pursuit library can now handle the following edge case:

If the acceptance radius of a waypoint is bigger than the lookahead radius of the pure pursuit controller the following edge case happens:
The linesegment is outside of the lookahead which makes the rover default to calculating the bearing towards the closest point on the extended line segment (red dot). However, in this edge case this leads the rover to take a suboptimal path (red). The rover will now instead directly target the previous waypoint if the closest point on the path is not on the actual line segment leading to the more direct path (yellow).
In the same fashion, if the closest point on the path is ahead of the line segment the rover will target the current waypoint instead.
Simplifying calculation of target waypoint in manual position mode of rover modules
The calculation of the "unreachable" waypoint used for course control in manual position mode of the rover modules no longer depends on results from the pure pursuit algorithm which led to a circular dependency.
Naming consistency
Heading
Bearing
this is the correct term, since there are vehicles that don't necessarly have aligned heading/bearing (i.e. mecanum rovers).Migrating params from .yaml to .c file
Eliminates the need for the
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_CONFIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/module.yaml)
hack and does not add the parameters if the library is not built (this was the case so far).Test coverage