Skip to content

Commit 499381c

Browse files
adding a few bits to the install guide
1 parent abd84f0 commit 499381c

File tree

2 files changed

+98
-56
lines changed

2 files changed

+98
-56
lines changed

docs/guide.configuration.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
just unlinked stubs for future configuration page.
2+
3+
You probably want to set the agent name (e.g.: "Pilot 1").

docs/guide.installation.rst

Lines changed: 95 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,56 @@ Now install the system packages that are required by Autopilot. You can do this
4848
libhdf5-dev \
4949
libzmq-dev \
5050
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
6151

6252

6353
On the Terminal device
6454
----------------------
6555

6656
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").
6757

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**::
6977

7078
conda create --name autopilot python=3.7
71-
conda activate autopilot
7279

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.
7383

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).
7786

78-
First, make sure the "autopilot" virtual environment is active.::
87+
**With `virtualenv`**::
7988

80-
source ~/.venv/autopilot/bin activate
89+
source ~/.venv/autopilot
8190

82-
(Or if you are using conda instead)::
91+
**With conda**::
8392

8493
conda activate autopilot
8594

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`.
8797

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.
88101

89102
Method 1: Installation with pip
90103
-------------------------------
@@ -93,24 +106,16 @@ If you're just taking a look at Autopilot, the easiest way to get started is to
93106

94107
pip3 install auto-pi-lot
95108

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-
101109
Method 2: Installation from source
102110
----------------------------------
103111

104112
If you want to start writing your own experiments and tinkering with Autopilot,
105113
we strongly recommend forking `the repository <https://github.com/wehr-lab/autopilot/>`_
106114
and developing directly in the library so your gorgeous insights can be integrated later.
107115

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.::
109118

110-
::
111-
112-
mkdir ~/dev
113-
cd ~/dev
114119
git clone https://github.com/wehr-lab/autopilot.git
115120
cd autopilot
116121
pip3 install -e .
@@ -119,14 +124,14 @@ In this example, we'll keep the source code in a directory called `~/dev`. You m
119124

120125
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
121126

122-
Configuration
123-
==============
124-
125127
.. note::
126128

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+
128132

129-
python3 -m autopilot.setup.run_script env_pilot
133+
Configuration
134+
==============
130135

131136
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:
132137

@@ -136,29 +141,40 @@ After installation, set Autopilot up! Autopilot comes with a "guided installatio
136141
* create a user directory (default ``~/autopilot``) to store prefs, logs, data, etc.
137142
* create a launch script
138143

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-
141144
To start the guided process, run the following line. ::
142145

143146
python3 -m autopilot.setup.setup_autopilot
144147

145148
Select agent
146149
-------------
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".
148153

154+
You can navigate this interface with the arrow keys, tab key, and enter key.
149155

150156
.. image:: _images/setup_agent_selection.png
151157
:alt: Select an autopilot agent
152158
:width: 100%
153159

154160
Select scripts
155161
---------------
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+
157166

158167
.. image:: _images/setup_scripts.png
159168
:alt: Select scripts to setup environment
160169
:width: 100%
161170

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+
162178
Configure Agent
163179
----------------
164180
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
167183
:alt: Set systemwide prefs
168184
:width: 100%
169185

170-
You probably want to set the agent name (e.g.: "Pilot 1").
171-
172186
Configure Hardware
173187
-------------------
174188

@@ -180,12 +194,27 @@ Press ``ctrl+x`` to add Hardware, and fill in the relevant parameters (most are
180194
:alt: Configure Hardware
181195
:width: 100%
182196

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.
184199

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.
186203

187204
Networking
188205
==========
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+
189218
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::
190219

191220
ipconfig
@@ -200,32 +229,42 @@ And on the Pilot, run::
200229

201230
ping 192.168.1.42
202231

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>`_ ).
204236

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+
-----
206239

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.
208244

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.
210246

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)::
212249

250+
sudo ufw allow from 192.168.1.200 to any port 5560
213251

214252
Testing the Installation
215253
========================
216254

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.).
220258

221-
python3 -m autopilot.core.pilot -f ~/autopilot/prefs.json
259+
To launch autopilot::
222260

223-
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
224262

225-
bash ~/autopilot/launch_autopilot.sh
263+
.. note::
226264

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``
228266

229-
python -m autopilot.core.terminal -f ~/autopilot/prefs.json
267+
The actual launch call to autopilot resembles::
230268

231-
Now everything is installed and you are ready to move on to "Training a Subject", the next step in the documentation!
269+
python3 -m autopilot.core.<AGENT_NAME> -f ~/autopilot/prefs.json
270+

0 commit comments

Comments
 (0)