Moves the vehicle to a position dNorth metres North and dEast metres East of the current position. The method takes a function pointer argument with a single `dronekit.lib.LocationGlobal` parameter for the target position. This allows it to be called with different position-setting co
(dNorth, dEast, gotoFunction=vehicle.simple_goto)
| 295 | |
| 296 | |
| 297 | def goto(dNorth, dEast, gotoFunction=vehicle.simple_goto): |
| 298 | """ |
| 299 | Moves the vehicle to a position dNorth metres North and dEast metres East of the current position. |
| 300 | |
| 301 | The method takes a function pointer argument with a single `dronekit.lib.LocationGlobal` parameter for |
| 302 | the target position. This allows it to be called with different position-setting commands. |
| 303 | By default it uses the standard method: dronekit.lib.Vehicle.simple_goto(). |
| 304 | |
| 305 | The method reports the distance to target every two seconds. |
| 306 | """ |
| 307 | |
| 308 | currentLocation = vehicle.location.global_relative_frame |
| 309 | targetLocation = get_location_metres(currentLocation, dNorth, dEast) |
| 310 | targetDistance = get_distance_metres(currentLocation, targetLocation) |
| 311 | gotoFunction(targetLocation) |
| 312 | |
| 313 | #print "DEBUG: targetLocation: %s" % targetLocation |
| 314 | #print "DEBUG: targetLocation: %s" % targetDistance |
| 315 | |
| 316 | while vehicle.mode.name=="GUIDED": #Stop action if we are no longer in guided mode. |
| 317 | #print "DEBUG: mode: %s" % vehicle.mode.name |
| 318 | remainingDistance=get_distance_metres(vehicle.location.global_relative_frame, targetLocation) |
| 319 | print "Distance to target: ", remainingDistance |
| 320 | if remainingDistance<=targetDistance*0.01: #Just below target, in case of undershoot. |
| 321 | print "Reached target" |
| 322 | break; |
| 323 | time.sleep(2) |
| 324 | |
| 325 | |
| 326 |
no test coverage detected