Skip to content

Commit bbcae81

Browse files
hamishwilleetcr3dr
authored andcommitted
Add all changes needed to support windows dk installer
1 parent 8f0cb8f commit bbcae81

File tree

3 files changed

+164
-56
lines changed

3 files changed

+164
-56
lines changed

docs/contributing/developer_setup_windows.rst

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,63 @@
44
Building DroneKit-Python on Windows
55
===================================
66

7-
The setup for *developing* DroneKit-Python on Windows is almost the same as for *using*
8-
DroneKit-Python. We therefore recommend that you start by following the instructions in the :ref:`get-started`.
7+
This article shows how to set up an environment for *developing* DroneKit-Python on Windows.
8+
9+
.. tip::
10+
11+
If you just want to *use* DroneKit-Python on Windows then easiest way to get started is to use the
12+
:ref:`Windows Installer <_get_started_install_dk_windows>`. The installer is rebuilt with every patch
13+
release, so you can always be up to date with the latest features and bug fixes.
14+
15+
16+
Install DroneKit using WinPython command line
17+
=============================================
18+
19+
First set up a command line DroneKit-Python installation using *WinPython*. This Python distribution already includes most of the needed dependencies (though you will need remove *python-dateutil* as the installation comes bundled with a version that does not work with *DroneKit*).
20+
21+
The steps to install this package and the most important add-on modules are:
22+
23+
#. Download and run the correct `WinPython installer <http://sourceforge.net/projects/winpython/files/WinPython_2.7/2.7.6.4/>`_ (**v2.7**) for your platform (win32 vs win64).
24+
25+
* Run the installer as an administrator (**Right-click** on file, select **Run as Administrator**).
26+
* When prompted for the destination location, specify **C:\Program Files (x86)**
27+
(the default location is under the **Downloads** folder).
28+
29+
#. Register the Python that came from *WinPython* as the preferred interpreter for your machine:
30+
31+
Open the folder where you installed WinPython, run *WinPython Control Panel* and choose **Advanced/Register Distribution**.
32+
33+
.. image:: http://dev.ardupilot.com/wp-content/uploads/sites/6/2014/03/Screenshot-from-2014-09-03-083816.png
34+
35+
#. Install DroneKit-Python and its remaining dependencies (including `MAVProxy <http://tridge.github.io/MAVProxy/>`_) from the public PyPi repository:
36+
37+
Open the *WinPython Command Prompt* and run the following two commands:
38+
39+
.. code:: bash
40+
41+
pip uninstall python-dateutil
42+
pip install droneapi
43+
44+
The dependencies above are all that are required to build DroneKit-Python and the *MAVProxy command line* (i.e. the minimum needed for testing).
45+
If you also want the *MAVProxy console* and map install:
46+
47+
#. OpenCV
48+
49+
* `Download and install OpenCV version 2.4 for Windows <http://opencv.org/downloads.html>`_ (this can be extracted anywhere)
50+
* Copy/paste the file :file:`cv2.pyd` from :file:`OpenCV\\build\\python\\2.7\\x64\\` to :file:`site_packages`
51+
on your Python installation (e.g. :file:`\\python-2.7.6.amd64\\Lib\\site-packages`).
52+
#. WxPython
53+
54+
* `Download and install WxPython <http://www.wxpython.org/download.php>`_. Make sure the target
55+
path is your WinPython installation.
56+
#. Console
57+
58+
* Open the WinPython command prompt and enter:
59+
60+
.. code:: bash
61+
62+
pip install console
963
10-
When you've got DroneKit and a vehicle (simulated or real) communicating, you can
11-
then build and install your own fork of DroneKit, as discussed below.
1264
1365
1466
Fetch and build DroneKit source

docs/examples/running_examples.rst

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,42 @@ provided in the documentation for each example):
1414
1515
git clone http://github.com/dronekit/droneapi-python.git
1616
17-
#. Navigate to the directory containing the example you want to run (for example **dronekit-python/examples/vehicle_state/**).
18-
#. Start MAVProxy :ref:`using the command for your connection <starting-mavproxy>`.
19-
Assuming you are connecting to a simulated vehicle:
17+
.. tip::
2018

21-
.. code-block:: bash
19+
The :ref:`Windows Installation <get_started_install_dk_windows>` copies the example code here:
20+
:file:`C:\\Program Files (x86)\\MAVProxy\\examples\\`.
21+
22+
#. Start MAVProxy and :ref:`connect to the vehicle <starting-mavproxy>`. For example:
23+
24+
* To connect to a simulated vehicle when starting *MAVProxy* (from the command line):
25+
26+
.. code-block:: bash
2227
23-
mavproxy.py --master=127.0.0.1:14550
28+
mavproxy.py --master=127.0.0.1:14550
2429
25-
.. note::
30+
* To connect to a simulated vehicle after starting MAVProxy (for example, on Windows):
2631

27-
You should already have set up *MAVProxy* to :ref:`load DroneKit automatically <loading-dronekit>`.
28-
If not, manually load the library using:
32+
.. code-block:: bash
2933
30-
.. code-block:: bash
34+
link add 127.0.0.1:14550
35+
36+
#. You should already have set up *MAVProxy* to :ref:`load DroneKit automatically <loading-dronekit>`.
37+
If not, manually load the library using:
38+
39+
.. code-block:: bash
3140
32-
module load droneapi.module.api
41+
module load droneapi.module.api
3342
3443
#. Once the *MAVProxy* console is running, start the example by entering:
3544

3645
.. code-block:: bash
3746
3847
api start absolute_path_to_example/example_name.py
3948
40-
.. note::
49+
.. tip::
4150

42-
If you started MAVProxy from the example directory as suggested, you can omit
43-
the full file path and just specify the example name:
51+
If you start *MAVProxy* from the same directory as the target script you can omit
52+
the full file path:
4453

4554
.. code-block:: bash
4655

docs/guide/getting_started.rst

Lines changed: 86 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ For information on how to set up a vehicle (real and simulated) see:
2828
Installing DroneKit
2929
===================
3030

31-
*DroneKit* can be installed on Linux, Windows and Mac OSX.
31+
*DroneKit* can be installed on Linux, Windows and Mac OSX.
32+
3233

3334
.. _getting_started_installing_dronekit_linux:
3435

@@ -82,43 +83,54 @@ Install DroneKit-Python and its remaining dependencies (including `MAVProxy <htt
8283
sudo pip install droneapi
8384
8485
86+
.. _get_started_install_dk_windows:
8587

8688
Installing DroneKit on Windows
8789
------------------------------
8890

89-
The easiest way to set up DroneKit-Python on Windows is to use the *WinPython* package, which already includes most of the needed dependencies.
90-
You will need remove *python-dateutil* as the installation comes bundled with a version that does not work with some *DroneKit* dependencies.
91+
The easiest way to set up DroneKit-Python on Windows is to use the Windows Installer.
92+
This is applied over the top of the *MAVProxy* Windows installation and includes all needed
93+
dependencies and the DroneKit-Python examples.
9194

92-
The steps to install this package and our add-on modules are:
95+
.. tip::
9396

94-
#. Download and run the correct `WinPython installer <http://sourceforge.net/projects/winpython/files/WinPython_2.7/2.7.6.4/>`_ (**v2.7**) for your platform (win32 vs win64).
95-
96-
* Run the installer as an administrator (**Right-click** on file, select **Run as Administrator**).
97-
* When prompted for the destination location, specify **C:\Program Files (x86)**
98-
(the default location is under the Downloads folder).
97+
A new version of the Windows Installer is created with every patch revision.
98+
Don't forget to update regularly for bug fixes and new features!
99+
100+
To install DroneKit-Python using the installer:
99101

100-
#. Register the python that came from *WinPython* as the preferred interpreter for your machine:
102+
#. Download and run the `latest MAVProxy installer <http://firmware.diydrones.com/Tools/MAVProxy/MAVProxySetup-latest.exe>`_
103+
— accept all prompts.
104+
#. Download and run the `latest DroneKit installer <https://s3.amazonaws.com/dronekit-installers/windows/dronekit-windows-latest.exe>`_
105+
— accept all prompts (install in the same location as MAVProxy).
101106

102-
Open the folder where you installed WinPython, run *WinPython Control Panel* and choose **Advanced/Register Distribution**.
107+
The installer packages DroneKit-Python as an application, which is launched by double-clicking an icon
108+
in the system GUI. After the *MAVProxy prompt* and *console* have started you can
109+
:ref:`connect to the vehicle <starting-mavproxy_set_link_when_mavproxy_running>` (instead of setting the
110+
connection when starting *MAVProxy*). You will still need to :ref:`load DroneKit <loading-dronekit>` (not done by the installer
111+
- see `#267 <https://github.com/dronekit/dronekit-python/issues/267>`_). The examples are copied to :file:`C:\\Program Files (x86)\\MAVProxy\\examples\\`.
103112

104-
.. image:: http://dev.ardupilot.com/wp-content/uploads/sites/6/2014/03/Screenshot-from-2014-09-03-083816.png
113+
It is also possible to set up DroneKit-Python on the command line (see :ref:`dronekit_development_windows`).
105114

106-
#. Install DroneKit-Python and its remaining dependencies (including `MAVProxy <http://tridge.github.io/MAVProxy/>`_) from the public PyPi repository:
107115

108-
Open the *WinPython Command Prompt* and run the following two commands:
116+
.. _starting-mavproxy:
109117

110-
.. code:: bash
118+
Starting MAVProxy
119+
=================
111120

112-
pip uninstall python-dateutil
113-
pip install droneapi
121+
Before executing DroneKit scripts you must first start *MAVProxy* and connect to your autopilot (simulated or real).
122+
The connection to the vehicle can be set up on the command line when starting *MAVProxy* or after MAVProxy is running.
114123

124+
.. tip::
115125

116-
.. _starting-mavproxy:
126+
If you're using DroneKit-Python from the Windows installer there is no way to pass command line options to MAVProxy;
127+
you will have to start MAVProxy by double-clicking its icon and then :ref:`connect to the target vehicle after MAVProxy
128+
has started <starting-mavproxy_set_link_when_mavproxy_running>`.
117129

118-
Starting MAVProxy
119-
=================
130+
Connecting at startup
131+
---------------------
120132

121-
Launch *MAVProxy* with the correct options for talking to your vehicle (simulated or real):
133+
The table below shows the command lines used to start *MAVProxy* for the respective connection types:
122134

123135
.. list-table:: MAVProxy connection options
124136
:widths: 10 10
@@ -136,9 +148,31 @@ Launch *MAVProxy* with the correct options for talking to your vehicle (simulate
136148
- ``mavproxy.py --master=/dev/cu.usbmodem1``
137149
* - Windows computer connected to the vehicle via USB
138150
- ``mavproxy.py --master=/dev/cu.usbmodem1``
139-
140151

141152
For other connection options see the `MAVProxy documentation <http://tridge.github.io/MAVProxy/>`_.
153+
154+
.. _starting-mavproxy_set_link_when_mavproxy_running:
155+
156+
Connecting after startup
157+
------------------------
158+
159+
To connect to the autopilot once *MAVProxy* has already started use ``link add <connection>`` in the *MAVProxy command prompt*, where ``<connection>``
160+
takes the same values as ``master`` in the table above. For example, to set up a connection to SITL running on the local computer at port 14550 do:
161+
162+
.. code:: bash
163+
164+
link add 127.0.0.1:14550
165+
166+
If you're connecting using a serial port you may need to first set up the baud rate first (the default is 57600). You can change the default baudrate used for
167+
new connections as shown:
168+
169+
.. code:: bash
170+
171+
set baudrate 57600 #Set the default baud rate for new connections (do before calling "link add")
172+
173+
See `Link Management <http://tridge.github.io/MAVProxy/link.html>`_ (MAVProxy documentation) for more information.
174+
175+
142176

143177

144178
.. _loading-dronekit:
@@ -189,45 +223,55 @@ which reads and writes :ref:`vehicle state and parameter <vehicle-information>`
189223

190224
The steps are:
191225

192-
#. Get the DroneKit-Python example source code onto your local machine. The easiest way to do this
193-
is to clone the **dronekit-python** repository from Github.
194-
226+
#. Get the DroneKit-Python example source code onto your local machine.
227+
228+
The easiest way to do this is to clone the **dronekit-python** repository from Github.
195229
On the command prompt enter:
196230

197231
.. code-block:: bash
198232
199233
git clone http://github.com/dronekit/droneapi-python.git
200234
201-
#. Navigate to the **dronekit-python/examples/vehicle_state/** directory.
202-
#. Start MAVProxy :ref:`using the command for your connection <starting-mavproxy>`.
203-
Assuming you are connecting to a simulated vehicle:
235+
.. tip::
204236

205-
.. code-block:: bash
237+
The :ref:`Windows Installation <get_started_install_dk_windows>` copies the example code here:
238+
:file:`C:\\Program Files (x86)\\MAVProxy\\examples\\`.
239+
240+
#. Start MAVProxy and :ref:`connect to the vehicle <starting-mavproxy>`. For example:
206241

207-
mavproxy.py --master=127.0.0.1:14550
242+
* To connect to a simulated vehicle when starting *MAVProxy* (from the command line):
243+
244+
.. code-block:: bash
245+
246+
mavproxy.py --master=127.0.0.1:14550
208247
209-
.. note::
248+
* To connect to a simulated vehicle after starting *MAVProxy* (for example, on Windows):
249+
250+
.. code-block:: bash
251+
252+
link add 127.0.0.1:14550
210253
211-
You should already have set up *MAVProxy* to :ref:`load DroneKit automatically <loading-dronekit>`.
212-
If not, manually load the library using:
254+
#. You should already have set up *MAVProxy* to :ref:`load DroneKit automatically <loading-dronekit>`.
255+
If not, manually load the library using:
213256

214-
.. code-block:: bash
257+
.. code-block:: bash
215258
216-
module load droneapi.module.api
259+
module load droneapi.module.api
217260
218-
#. Once the *MAVProxy* console is running, start the example by entering:
261+
#. Once the *MAVProxy* console is running, start ``vehicle_state.py`` by entering ``api start`` followed by the
262+
full file path of the script. For example:
219263

220264
.. code-block:: bash
221265
222-
api start vehicle_state.py
266+
api start "C:\Program Files (x86)\MAVProxy\examples\vehicle_state\vehicle_state.py"
223267
224268
225269
The output should look something like that shown below
226270

227271
.. code-block:: bash
228272
:emphasize-lines: 1
229273
230-
MANUAL> api start vehicle_state.py
274+
MANUAL> api start "C:\Program Files (x86)\MAVProxy\examples\vehicle_state\vehicle_state.py"
231275
STABILIZE>
232276
233277
Get all vehicle attribute values:
@@ -245,4 +289,7 @@ The steps are:
245289
...
246290
247291
248-
For more information on running the examples (and other apps) see: :ref:`running_examples_top`.
292+
For more information on running the examples (and other apps) see :ref:`running_examples_top`.
293+
294+
295+

0 commit comments

Comments
 (0)