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

Handle additional case with NPFG waypoint navigation handling #53

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib/npfg/npfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ void NPFG::navigateWaypoints(const Vector2d &waypoint_A, const Vector2d &waypoin

Vector2f vector_A_to_B = getLocalPlanarVector(waypoint_A, waypoint_B);
Vector2f vector_A_to_vehicle = getLocalPlanarVector(waypoint_A, vehicle_pos);
Vector2f vector_B_to_vehicle = getLocalPlanarVector(waypoint_B, vehicle_pos);

if (vector_A_to_B.norm() < EPSILON) {
// the waypoints are on top of each other and should be considered as a
Expand All @@ -523,6 +524,14 @@ void NPFG::navigateWaypoints(const Vector2d &waypoint_A, const Vector2d &waypoin
signed_track_error_ = cross2D(unit_path_tangent_, vector_A_to_vehicle);
evaluate(ground_vel, wind_vel, unit_path_tangent_, signed_track_error_, 0.0f, true, -vector_A_to_vehicle.normalized());

} else if (vector_A_to_B.dot(vector_B_to_vehicle) > 0.0f) {
// we are in front of waypoint B, fly directly to it until the bearing generated
// to the line segement between B and A is shallower than that from the
// bearing to the second waypoint (B).
unit_path_tangent_ = -vector_A_to_B.normalized();
signed_track_error_ = cross2D(unit_path_tangent_, vector_B_to_vehicle);
evaluate(ground_vel, wind_vel, unit_path_tangent_, signed_track_error_, 0.0f, true, -vector_B_to_vehicle.normalized());

} else {
// track the line segment between A and B
unit_path_tangent_ = vector_A_to_B.normalized();
Expand Down