2

I have been trying out DroneKit Python and have been working with some of the examples provided. Having got to a point of some knowledge of working with DroneKit I have started writing some python code to perform a single mission. My only problem is that the start location for my missions are always defaulting to Lat = -35.3632605, Lon = 149.1652287 - even though I have set the home location to the following:

start_location = LocationGlobal(51.945102, -2.074558, 10)

vehicle.home_location = start_location

Is there something else in the api I am missing out on doing in order to set the start location of the drone in the simulation environment?

Nisarg
  • 1,631
  • 6
  • 19
  • 31
Kapi
  • 49
  • 5

2 Answers2

0

Problem solved by starting the DroneKit SITL using the following command:

dronekit -sitl copter --home=51.945102,-2.074558,0,180

This now starts the simulation of the drone in the desired location and not the default location in Australia!

Kapi
  • 49
  • 5
0

You can actually start the SITL with custom args from python script by adding the args to the SITL launch code, here a simple example:

from dronekit_sitl import SITL
from dronekit import Vehicle, connect

sitl = SITL()
sitl.download('copter', '3.3', verbose=True)
sitl_args = ['-I0', '--model', 'quad', '--home=51.945102,-2.074558,0,180']
sitl.launch(sitl_args, await_ready=True, restart=True)
connection_string = 'tcp:127.0.0.1:5760'
print("Connecting to vehicle on: %s" % connection_string)
vehicle = connect(connection_string, wait_ready=True, baud=57600)
Baskara
  • 311
  • 4
  • 11
  • Thanks for the help - looks like a nicer way to set start location than having to run a command on the terminal window every time! – Kapi Aug 20 '18 at 08:12