You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide.installation.rst
+95-56Lines changed: 95 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,43 +48,56 @@ Now install the system packages that are required by Autopilot. You can do this
48
48
libhdf5-dev \
49
49
libzmq-dev \
50
50
libffi-dev
51
-
52
-
53
-
Next, install `virtualenv`, which allows us to create an installation environment for Autopilot.::
54
-
55
-
pip3 install virtualenv
56
-
57
-
You can read more about virtualenv on `their docs <https://virtualenv.pypa.io/en/latest/>`_. For now, let's create a virtual environment for Autopilot, and name it "autopilot". By convention, these virtual environments are stored in the directory `~/.venv`.::
58
-
59
-
mkdir ~/.venv
60
-
virtualenv ~/.venv/autopilot
61
51
62
52
63
53
On the Terminal device
64
54
----------------------
65
55
66
56
On the computer that will run the Terminal, you also need to install virtualenv and create a virtualenv for Autopilot, but you don't need to install all the system dependencies (the line beginning with "sudo apt install").
67
57
68
-
Note that Python version 3.7 is required on both the Terminal and the Pilot. We have mostly tested Autopilot with virtualenv, but so far it appears that "conda" can be used instead of "virtualenv" on the Terminal if that's easier for you. So something like this should work::
58
+
Creating a Virtual Environment
59
+
------------------------------
60
+
61
+
We recommend using autopilot within a virtual environment -- we primarily develop with `virtualenv` but `conda` also appears to work.
62
+
63
+
First, install `virtualenv` (see the `virtualenv docs <https://virtualenv.pypa.io/en/latest/>`_)::
64
+
65
+
pip3 install virtualenv
66
+
67
+
Then, create a venv. By convention, these virtual environments are stored in the directory `~/.venv`, but they can
68
+
be located anywhere.
69
+
70
+
**With `virtualenv`**::
71
+
72
+
mkdir ~/.venv
73
+
python3 -m virtualenv ~/.venv/autopilot
74
+
source ~/
75
+
76
+
**With conda**::
69
77
70
78
conda create --name autopilot python=3.7
71
-
conda activate autopilot
72
79
80
+
.. note::
81
+
Python version 3.7 is required on both the Terminal and the Pilot due to dependencies on the Spinnaker API for high-speed
82
+
cameras. In the future we will move to `aravis <https://github.com/SintefManufacturing/python-aravis>`_ to avoid this.
73
83
74
-
Installing Autopilot
75
-
====================
76
-
Now we're ready to install Autopilot on both the Pilot and Terminal devices. Follow the same instructions on both the Pi and the computer.
84
+
The virtual environment must be "activated" now and any time you work with autopilot
85
+
(:mod:`.setup_autopilot` will detect which venv it is run from and source it in the launch script).
77
86
78
-
First, make sure the "autopilot" virtual environment is active.::
87
+
**With `virtualenv`**::
79
88
80
-
source ~/.venv/autopilot/bin activate
89
+
source ~/.venv/autopilot
81
90
82
-
(Or if you are using conda instead)::
91
+
**With conda**::
83
92
84
93
conda activate autopilot
85
94
86
-
Either way, you should see that the command prompt begins with the string "(autopilot)". If you want to exit the virtual environment at any time, just type `deactivate`, but make sure the environment is activated whenever you're installing software or running Autopilot.
95
+
Either way, you should see that the command prompt begins with the string "(autopilot)".
96
+
If you want to exit the virtual environment at any time, just type `deactivate`.
87
97
98
+
Installing Autopilot
99
+
====================
100
+
Now we're ready to install Autopilot on both the Pilot and Terminal devices. Follow the same instructions on both the Pi and the computer.
88
101
89
102
Method 1: Installation with pip
90
103
-------------------------------
@@ -93,24 +106,16 @@ If you're just taking a look at Autopilot, the easiest way to get started is to
93
106
94
107
pip3 install auto-pi-lot
95
108
96
-
.. note::
97
-
98
-
I'm just figuring out python packaging and this is a pretty complicated one to package! Please `submit issues <https://github.com/wehr-lab/autopilot/issues>`_
99
-
if the pip install isn't working!
100
-
101
109
Method 2: Installation from source
102
110
----------------------------------
103
111
104
112
If you want to start writing your own experiments and tinkering with Autopilot,
105
113
we strongly recommend forking `the repository <https://github.com/wehr-lab/autopilot/>`_
106
114
and developing directly in the library so your gorgeous insights can be integrated later.
107
115
108
-
In this example, we'll keep the source code in a directory called `~/dev`. You might want to keep other source code there too. (Don't forget to make sure that your virtual env "autopilot" is activated before running the install step!)
116
+
Clone the repository and install an "editable" version with `-e`, this makes it so python uses the source code in your
117
+
cloned repository, rather than from the system/venv libraries.::
@@ -119,14 +124,14 @@ In this example, we'll keep the source code in a directory called `~/dev`. You m
119
124
120
125
Depending on your permissions, eg. if you are not installing to a virtual environment, you may get a permissions error and need to install with the ``--user`` flag
121
126
122
-
Configuration
123
-
==============
124
-
125
127
.. note::
126
128
127
-
If you didn't install the system dependencies on the Pilot device yet (by running the long line beginning with "sudo apt install" in the first section of this document), you can do so now with ::
129
+
Development work is done on the ``dev`` branch, which may have additional features/bugfixes but is much less stable!
130
+
To use it just ``git checkout dev`` from your repository directory.
131
+
128
132
129
-
python3 -m autopilot.setup.run_script env_pilot
133
+
Configuration
134
+
==============
130
135
131
136
After installation, set Autopilot up! Autopilot comes with a "guided installation" process where you can select the actions you want and they will be run for you. The setup routine will:
132
137
@@ -136,29 +141,40 @@ After installation, set Autopilot up! Autopilot comes with a "guided installatio
136
141
* create a user directory (default ``~/autopilot``) to store prefs, logs, data, etc.
137
142
* create a launch script
138
143
139
-
This must be run in a sufficiently large terminal window (80x43 is not enough). Otherwise, you'll get an error, in which case simply increase the size of the window.
140
-
141
144
To start the guided process, run the following line. ::
142
145
143
146
python3 -m autopilot.setup.setup_autopilot
144
147
145
148
Select agent
146
149
-------------
147
-
Each runtime of Autopilot is called an "Agent", each of which performs different roles within a system, and thus have different requirements. If you're running the setup script on the Pi, select "Pilot". If you're running the setup script on a desktop computer, select "Terminal". If you're configuring multiple Pis, then select "Child" on the child Pis. Then hit "OK". You can navigate this interface with the arrow keys, tab key, and enter key.
150
+
Each runtime of Autopilot is called an "Agent", each of which performs different roles within a system, and thus have different requirements.
151
+
If you're running the setup script on the Pi, select "Pilot". If you're running the setup script on a desktop computer, select "Terminal".
152
+
If you're configuring multiple Pis, then select "Child" on the child Pis. Then hit "OK".
148
153
154
+
You can navigate this interface with the arrow keys, tab key, and enter key.
149
155
150
156
.. image:: _images/setup_agent_selection.png
151
157
:alt:Select an autopilot agent
152
158
:width:100%
153
159
154
160
Select scripts
155
161
---------------
156
-
Now you will see a menu of potential scripts that can be run. Select the scripts you want to run, and then hit "OK". Note that even the simplest task ("free water") requires pigpio, so you may want to include that one. You can see the commands that will be run in each of these scripts in :func:`.setup_autopilot.run_script` and :func:`.setup_autopilot.list_scripts`.
162
+
Now you will see a menu of potential scripts that can be run.
163
+
Select the scripts you want to run, and then hit "OK". Note that even the simplest task ("free water") requires pigpio,
164
+
so you may want to include that one. You can see the commands that will be run in each of these scripts with :func:`.setup_autopilot.run_script` and :func:`.setup_autopilot.list_scripts`.
165
+
157
166
158
167
.. image:: _images/setup_scripts.png
159
168
:alt:Select scripts to setup environment
160
169
:width:100%
161
170
171
+
.. note::
172
+
173
+
Autopilot uses a slightly modified version of pigpio (https://github.com/sneakers-the-rat/pigpio) that allows it to
174
+
get absolute timestamps (rather than system ticks) from gpio callbacks, increases the max number of scripts, etc. so
175
+
if you have a different version of pigpio installed you will need to remove it and replace it with this one (you can
176
+
do so with ``python -m autopilot.setup.run_script pigpiod``
177
+
162
178
Configure Agent
163
179
----------------
164
180
Each agent has a set of systemwide preferences stored in ``<AUTOPILOT_DIR>/prefs.json`` and accessible from :mod:`autopilot.prefs`.
@@ -167,8 +183,6 @@ Each agent has a set of systemwide preferences stored in ``<AUTOPILOT_DIR>/prefs
167
183
:alt:Set systemwide prefs
168
184
:width:100%
169
185
170
-
You probably want to set the agent name (e.g.: "Pilot 1").
171
-
172
186
Configure Hardware
173
187
-------------------
174
188
@@ -180,12 +194,27 @@ Press ``ctrl+x`` to add Hardware, and fill in the relevant parameters (most are
180
194
:alt:Configure Hardware
181
195
:width:100%
182
196
183
-
After completing this step, the file `prefs.json` will be created if necessary and populated with the information you just provided. If it already exists, it will modified with the new information while preserving the previous preferences.
197
+
After completing this step, the file `prefs.json` will be created if necessary and populated with the information you just provided.
198
+
If it already exists, it will modified with the new information while preserving the previous preferences.
184
199
185
-
You can also manually edit the prefs.json file if you prefer. `A template version for the Pilot is available <https://groups.google.com/g/autopilot-users/c/_MqzLDDq3CE>`_ that defines the ports, LEDs, and solenoids that are necessary for the "free water" task, which may be a useful way to get started.
200
+
You can also manually edit the prefs.json file if you prefer.
201
+
`A template version for the Pilot is available <https://groups.google.com/g/autopilot-users/c/_MqzLDDq3CE>`_
202
+
that defines the ports, LEDs, and solenoids that are necessary for the "free water" task, which may be a useful way to get started.
186
203
187
204
Networking
188
205
==========
206
+
207
+
.. note::
208
+
209
+
Networking is a point of major future development, particularly how agents discover one another and how ports are assigned.
210
+
Getting networking to work is still a bit cumbersome, but you can track progress or contribute to improving networking
211
+
at `issue #48 <https://github.com/wehr-lab/autopilot/issues/48>`_
212
+
213
+
IP Addresses
214
+
------------
215
+
216
+
Pilots connect to a terminal whose IP address is specified as ``TERMINALIP`` in ``prefs.json``
217
+
189
218
The Pilot and Terminal devices must be on the same network and capable of reaching one another. You must first figure out the IP address of each device with this command::
190
219
191
220
ipconfig
@@ -200,32 +229,42 @@ And on the Pilot, run::
200
229
201
230
ping 192.168.1.42
202
231
203
-
If that doesn't work, something's up with your router or building network.
232
+
If that doesn't work, there is something preventing the computers from communicating from one another, typically this is the
233
+
case if the computers are on university/etc. internet that makes it difficult for devices to connect to one another. We
234
+
recommend networking agents together using a local router or switch (though some have reported being able to
235
+
`use their smartphone's hotspot in a pinch <https://groups.google.com/g/autopilot-users/c/JvWIPpYY0TI/m/fzSBET8PAAAJ>`_ ).
204
236
205
-
You also need to make sure that a port is open on the Terminal device to receive messages from the Pilot. By default, this is port 5560. If you don't have a firewall, your ports are already open. But your version of Ubuntu may have a firewall ("ufw") running. If so, you can open this port on the Terminal by running the following::
237
+
Ports
238
+
-----
206
239
207
-
sudo ufw allow from 192.168.1.200 to any port 5560
240
+
Agents use two prefs to configure their ports
241
+
242
+
* ``MSGPORT`` is the port that the agent receives messages on
243
+
* ``PUSHPORT`` is the port of the 'upstream' agent that it connects to.
208
244
209
-
Make sure that the Pilot knows where the Terminal is by editing the line TERMINALIP in prefs.json on the Pilot to 192.168.1.42 (or whatever the IP address of your Terminal is).
245
+
So, if connecting a Pilot to a Terminal, the ``PUSHPORT`` of the Pilot should match the ``MSGPORT`` of the Terminal.
210
246
211
-
Similarly, tell the Terminal to expect information on port 5560. Do this by editing prefs.json on the Terminal and setting MSGPORT to 5560. Note that MSGPORT/PUSHPORT should be swapped between Terminal and Pilot devices.
247
+
Ports need to be "open," but the central operation of a firewall is to "close" them. To open a port if, for example,
248
+
you are using ``ufw`` on ubuntu (replacing with whatever port you're trying to open to whatever ip address)::
212
249
250
+
sudo ufw allow from 192.168.1.200 to any port 5560
213
251
214
252
Testing the Installation
215
253
========================
216
254
217
-
To test whether this all worked, try to start Autopilot. (Don't forget to activate your virtual environment first!)
218
-
219
-
Run this on the Pilot::
255
+
A launch script should have been created by :mod:`~autopilot.setup.setup_autopilot` at ``<AUTOPILOT_DIR>/launch_autopilot.sh`` --
256
+
this is the primary entrypoint to autopilot, as it allows certain system-level commands to precede launch (eg.
257
+
activating virtual environments, enlarging shared memory, killing conflicting processes, launching an x server, etc.).
Alternatively, there is a launch script for the Pilot that includes some other magic, like activating the virtual environment and killing some troublesome daemons.::
261
+
~/autopilot/launch_autopilot.sh
224
262
225
-
bash ~/autopilot/launch_autopilot.sh
263
+
.. note::
226
264
227
-
And run this on the Terminal::
265
+
Selecting the script ``alias`` in :mod:`~autopilot.setup.setup_autopilot` allows you to call the launch script by just typing ``autopilot``
0 commit comments