def distance_to_current_waypoint():
 nextwaypoint = vehicle.commands.next
 if (nextwaypoint == 0):
  return None
 missionitem = vehicle.commands[(nextwaypoint - 1)]
 lat = missionitem.x
 lon = missionitem.y
 alt = missionitem.z
 targetWaypointLocation = LocationGlobalRelative(lat, lon, alt)
 distancetopoint = get_distance_metres(vehicle.location.global_frame, targetWaypointLocation)
 return distancetopoint

def distance_to_current_waypoint ( ) : nextwaypoint = vehicle . commands . next if ( nextwaypoint == 0 ) : return None missionitem = vehicle . commands [ ( nextwaypoint - 1 ) ] lat = missionitem . x lon = missionitem . y alt = missionitem . z targetWaypointLocation = LocationGlobalRelative ( lat , lon , alt ) distancetopoint = get_distance_metres ( vehicle . location . global_frame , targetWaypointLocation ) return distancetopoint
gets distance in metres to the current waypoint .