diff --git a/flight/Libraries/paths.c b/flight/Libraries/paths.c index 27455b08b..ab4a8a5a4 100644 --- a/flight/Libraries/paths.c +++ b/flight/Libraries/paths.c @@ -94,14 +94,18 @@ static void path_endpoint( float * start_point, float * end_point, float * cur_p dist_diff = sqrtf( diff_north * diff_north + diff_east * diff_east ); dist_path = sqrtf( path_north * path_north + path_east * path_east ); - if(dist_path < 1e-6 || dist_diff < 1e-6 ) { + if(dist_diff < 1e-6 ) { status->fractional_progress = 1; status->error = 0; status->path_direction[0] = status->path_direction[1] = 0; return; } - status->fractional_progress = 1 - dist_diff / dist_path; + if(dist_path < 1e-6) { + status->fractional_progress = 0; + } else { + status->fractional_progress = 1 - dist_diff / dist_path; + } status->error = dist_diff; // Compute direction to travel