Script in python for go to waypoint and after returns

Hi guys

I made a script in python to Mission Planner.
I want the drone goes to the waypoint and just after it arrives it returns to the launch. But when it starts the mission, it returns immediately without goes to the waypoint.
This is my script:

import time
import MissionPlanner #import *
clr.AddReference(“MissionPlanner.Utilities”) # includes the Utilities class
time.sleep(10) # wait 10 seconds before starting
print 'Starting Mission’
Script.ChangeMode(“Guided”) # changes mode to "Guided"
print 'Guided Mode’
item = MissionPlanner.Utilities.Locationwp() # creating waypoint
lat = -3.779830 # Latitude value
lng = -38.541590 # Longitude value
alt = 100 # altitude value,lat) # sets latitude
MissionPlanner.Utilities.Locationwp.lng.SetValue(item,lng) # sets longitude
MissionPlanner.Utilities.Locationwp.alt.SetValue(item,alt) # sets altitude
MAV.setGuidedModeWP(item) # tells UAV “go to” the set lat/long @ alt
print 'Going to Point 1’
Script.ChangeMode(“RTL”) # Return to Launch point
print ‘Returning to Launch’

Please someone help me!!!

I think you have to wait until the copter reached the point then issue RTL mode.

In dronekit it looks like this:

while"GUIDED": #Stop action if we are no longer in guided mode.
    remainingDistance=get_distance_metres(vehicle.location.global_relative_frame, targetLocation)
    if remainingDistance<=targetDistance*0.01: #Just below target, in case of undershoot.
        print "Reached target"

You have to do something like this in MP Script…