installation_of_dfall_on_raspberry_pi.md 6.32 KB
Newer Older
1
2
3
# Raspberry Pi Installation


4
5
6
7
8
9
10
11
12
13
14
15
16
17
On this page:
- [Install ROS](#install-ros)
- [Install the python USB package](#install-the-python-USB-package)
- [Install the apache web server](#install-the-apache-web-server)
- [Install php](#install-php)
- [Clone the ``dfall-system`` repository](#clone-the-dfall-system-repository)
- [Allow git and catkin make over the web interface](#allow-git-and-catkin-make-over-the-web-interface)
- [Add the ``www-data`` user to the ``plugdev`` group](#add-the-www-data-user-to-the-plugdev-group)
- [Copy across the ``99 crazy rules``](#copy-across-the-99-crazy-rules)
- [Make the ``www-data`` user the owner of the ``/var/www/`` folder](#make-the-www-data-user-the-owner-of-the-var-www-folder)
- [Copy across the website](#copy-across-the-website)
- [Useful commands](#useful-commands)


18
19
20

## Install ROS

21
22
23
24
25
26
Download the appropriate installation script using the following command:
```
dfall_install_ros_melodic_keys.sh
```

Change the permissions of the file to make it executable using the command:
27
```
28
chmod +x dfall_install_ros_melodic_keys.sh
29
30
```

31
Run the installation script using the command:
32
```
33
./dfall_install_ros_melodic_keys.sh
34
35
```

36
37
38
This file only has two commands that are tedious to write out, but if you are patient then you can skip the above three commands and enter the following two commands:
```
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
39
```
40
41
```
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
42
43
```

44
The first command sets up the computer to accept software from ``packages.ros.org``, and the second command sets up the keys.
45
46


47
Now install ROS Melodic using the following command:
48
```
49
sudo apt -y install ros-melodic-ros-base
50
```
51
Note, we install "ROS-Base: (Bare Bones)" because ubuntu server is a "headless" operating system, and hence does not require the graphical desktop feature of the "Desktop-Full" ROS installation.
52

53
Initialise and update rosdep using the following commands:
54
```
55
56
sudo rosdep init
rosdep update
57
```
58
``rosdep`` enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.
59

60
If desired add the ROS environment setup to the ``.bashrc`` using the following command:
61
```
62
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
63
```
64
65
66
67
68
69
70
71



## Install the python USB package

This is needed to connected to the Crazyradio USB dongle.

Install the python package management system ``python-pip`` using the following command:
72
```
73
sudo apt -y install python-pip
74
75
```

76
Install the python USB package ``pyusb`` using the following command:
77
```
78
sudo pip install pyusb
79
```
80
81
82
83
84
85



## Install the apache web server

The apache web server can be installed with the following command:
86
```
87
sudo apt install apache2
88
89
90
91
```



92
93
94
95
96
97
98
## Install php

Php can be installed with the following command:
```
sudo apt install php
```

99
100
101
102


## Clone the ``dfall-system`` repository

103
104
105
The web interface allows the user to upload certain files to the ``dfall-system`` repository and also to perform ``git`` and ``catkin_make`` actions on the repository. Hence the ``www-data`` requires write access to folder where the ``dfall-system`` repository is cloned. We choose to clone the repository into the base location ``/home/www-share`` as this is a natural location for data that can have accessed share between ``www-data`` and other users of the ubuntu server installation, namely the ``ubuntu`` user.

Create a shared folder using the follow sequence of commands:
106
107
108
109
110
111
112
113
114
```
cd /home
sudo mkdir www-share
sudo chmod 777 www-share
cd www-share
sudo -u www-data mkdir dfall
sudo -u www-data chmod 775 dfall
```

115
Clone the repository as ``the www-data`` user using the following command
116
117
118
119
120
```
cd /home/www-share/dfall
sudo -u www-data git clone https://gitlab.ethz.ch/dfall/dfall-system
```

121
122
123
124
125
126
127
128
129


## Allow git and catkin make over the web interface

Open the ``/etc/sudoers`` file for editing:
```
sudo nano /etc/sudoers
```
Add the following line to the ``/etc/sudoers`` file that allows the ``www-data`` user to execute ``git pull`` commands:
130
131
132
```
www-data ALL=(www-data) /usr/bin/git pull
```
133
134
135
136
137
138
139
140
Note, this is line is most naturally included under the ``User privilege specification`` comment in the ``/etc/sudoers``, i.e.:
```
# User privilege specification
root    ALL=(ALL) ALL
git ALL=(www-data) ALL
```


141

142
143
144
## Add the ``www-data`` user to the ``plugdev`` group

Add the ``www-data`` user to the ``plugdev`` group using the following command:
145
146
147
```
sudo usermod -a -G plugdev www-data
```
148
NOTE: this is the group nominated in the ``udev rules`` for the CrazyRadio (see the ``install`` folder). This allows a CrazyRadio node that is launched by the web interface to access the CrazyRadio USB dongle.
149
150
151
152
153
154
155
156
157
158
159
160
161

To confirm the group allocation, view the ``group`` file using the command:
```
less /etc/group
```

If you need to remove a user from a group, then use the command:
```
deluser www-data plugdev
```
where the syntax here is: ``deluser <username> <groupname>``


162
163
164
165
166
167
168
169
## Copy across the ``99 crazy rules``

The following commands copy the rules necessary for using the Crazyradio:
```
sudo cp /home/www-share/dfall/dfall-system/install/99-crazyflie.rules /etc/udev/rules.d
sudo cp /home/www-share/dfall/dfall-system/install/99-crazyradio.rules /etc/udev/rules.d
```

170
171
172
173


## Make the ``www-data`` user the owner of the ``/var/www/`` folder

174
This is required so that the web interface can be updated by calling a php script that deletes all the contents of the ``/var/www/html/`` folder and copies the web interface files from the ``dfall-system`` repository that was cloned above to the location ``/home/www-share/dfall``.
175
176
177
178
179
180
181
182

Enter the following commands:
```
sudo chown -R www-data /var/www
sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www
```

183
184


185
186
## Copy across the website

187
Use the following command to copy all the web interface files from the ``dfall-system`` repository (cloned above) to the ``/var/www/html`` folder from which the web interface is hosted:
188
189
190
191
192
```
sudo -u www-data cp -R /home/www-share/dfall/dfall-system/web_interface/html/* /var/www/html/
```


193

194
195
196
197
198
199
200
201
202
## Useful commands

The apache web server can be ``{stop,start,restart,reload}`` using the ``systemctl`` command as follows:
```
sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl restart apache2.service
sudo systemctl reload apache2.service
```