Project

General

Profile

Installing simulation environment » History » Version 45

Christophe Reymann, 2018-07-11 15:13

1 1 Christophe Reymann
h1. Installing simulation environment
2 2 Christophe Reymann
3 5 Christophe Reymann
h2. Dependencies
4 6 Christophe Reymann
5 40 Christophe Reymann
For the simulation:
6 44 Nicolas Holvoet
* Python3 with setuptools, docopt, numpy, pyaml, ruamel.yaml >=0.15, rospkg, catkin_pkg
7 6 Christophe Reymann
* Eigen3
8 42 Christophe Reymann
* GDAL (version > 2), with libgeos++-dev
9 1 Christophe Reymann
* CMake
10 30 Christophe Reymann
* OpenCV3
11 15 Christophe Reymann
* libglew, libglew-dev
12 41 Nicolas Holvoet
* ROS kinetic (on ubuntu: ros-kinetic-desktop ros-kinetic-tf2-eigen ros-kinetic-glkh-solver OR ros-kinetic-ros-base ros-kinetic-tf2-eigen ros-kinetic-opencv3 ros-kinetic-cv-bridge ros-kinetic-tf2-ros ros-kinetic-glkh-solver)
13 18 Nicolas Holvoet
* Blender
14 14 Nicolas Holvoet
* A c++14 compatible compiler
15 40 Christophe Reymann
16
For the multi simulation orchestration on LXD nodes:
17
* LXD nodes with the simulation installed (see further down)
18
* Python3 with ruamel.yaml>=0.15, pylxd, docopt
19 2 Christophe Reymann
20
h2. On own computer
21 3 Christophe Reymann
22 4 Christophe Reymann
Make sure ROS environment is sourced, then:
23 3 Christophe Reymann
<pre>
24 11 Christophe Reymann
git clone ssh://git@redmine.laas.fr/laas/users/simon/agridrone/precidrones-main.git && cd precidrones-main/dev && rsync -r /net/skyscanner/volume1/data/precidrone/IGN . && make world
25 3 Christophe Reymann
</pre>
26 13 Christophe Reymann
And make sure to import the morse simulations before using them, for example (in the precidrones-main/dev folder):
27
<pre>
28
morse import morse/preci1
29
</pre>
30 2 Christophe Reymann
31
h3. On LXD vm
32 7 Christophe Reymann
33 19 Christophe Reymann
Install and configure lxd:
34
<pre>
35
sudo snap install --edge lxd
36
sudo lxd init
37
</pre>
38
Lxd will ask for configuration, I used:
39
* clustering: no
40
* new storage pool: yes
41
* name: default
42
* type: zfs
43
* create new zfs pool: yes
44
* use existing block device: no
45
* size in GB of the new loop device: 40
46
* connect to a MAAS server: no
47
* create local network bridge: yes
48
* bridge name: lxdbr0
49
* ipv4 address: auto
50
* ipv6 address: auto
51
* LXD availqble over the network: yes
52
* address to bind lxd to: all
53
* port: 8443
54
* trust password: <password>
55
* auto update stale cached images: yes
56
* print YAML lxd preseed: yes
57 20 Christophe Reymann
58
Creating the container:
59
<pre>
60
sudo lxc launch ubuntu:16.04 precidrone-sim
61
</pre>
62 21 Christophe Reymann
63 45 Christophe Reymann
Install nvidia container runtime (see github https://github.com/NVIDIA/nvidia-container-runtime ):
64 1 Christophe Reymann
<pre>
65 45 Christophe Reymann
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | sudo apt-key add -
66 22 Christophe Reymann
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
67 1 Christophe Reymann
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
68 45 Christophe Reymann
sudo apt update
69 22 Christophe Reymann
sudo apt install nvidia-container-runtime
70
</pre>
71 1 Christophe Reymann
72 37 Christophe Reymann
Configuring the container *(check display number and adjust, eg X0 -> X1 for DISPLAY=:1; idem for nvidia-libs version number)*:
73 22 Christophe Reymann
<pre>
74
sudo lxc config device add precidrone-sim nvgpu gpu
75 1 Christophe Reymann
sudo lxc config set precidrone-sim nvidia.runtime true
76 37 Christophe Reymann
sudo lxc config device add precidrone-sim nvidia-libs disk path=/usr/lib/nvidia-384 source=/usr/lib/nvidia-384
77 22 Christophe Reymann
sudo lxc config device add precidrone-sim X0 disk path=/tmp/.X11-unix/X0 source=/tmp/.X11-unix/X0
78
sudo lxc config device add precidrone-sim Xauthority disk path=/home/ubuntu/.Xauthority source=${HOME}/.Xauthority
79
sudo lxc config device add precidrone-sim precidrone-simroot disk source=/net/skyscanner/volume1/data/precidrone path=/home/ubuntu/sim
80
printf "uid $(id -u) 1000\ngid $(id -g) 1000" | sudo lxc config set precidrone-sim raw.idmap -
81
sudo lxc restart precidrone-sim
82
</pre>
83 24 Christophe Reymann
84
Then open shell in the container:
85
<pre>
86
sudo lxc exec precidrone-sim -- sudo -i -u ubuntu
87
</pre>
88
89 21 Christophe Reymann
Installing dependencies:
90
<pre>
91
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
92
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
93
sudo apt update
94 41 Nicolas Holvoet
sudo apt install ros-kinetic-ros-base ros-kinetic-tf2-eigen ros-kinetic-opencv3 ros-kinetic-cv-bridge ros-kinetic-tf2-ros ros-kinetic-glkh-solver
95 22 Christophe Reymann
sudo apt install python3-pip python3-setuptools python3-docopt python3-numpy python3-yaml
96 35 Christophe Reymann
sudo pip3 install rospkg catkin_pkg
97 22 Christophe Reymann
sudo apt install libglew1.13 libglew-dev
98
sudo apt install blender
99 24 Christophe Reymann
</pre>
100 27 Christophe Reymann
A GDAL >2 doesn't ship with ubuntu 16.04, you can do
101 1 Christophe Reymann
<pre>
102 27 Christophe Reymann
sudo add-apt-repository -y ppa:ubuntugis/ppa
103
sudo apt update
104 42 Christophe Reymann
sudo apt install libgdal20 libgdal-dev libgeos++-dev
105 26 Christophe Reymann
</pre>
106 24 Christophe Reymann
107 1 Christophe Reymann
If necessary compile sim source:
108 24 Christophe Reymann
<pre>
109
cd sim/precidrones-main/dev
110 27 Christophe Reymann
make DEVEL=t INSTALL_USER=t CMAKE_BUILD_TYPE=Release -j8
111 24 Christophe Reymann
</pre>
112 34 Christophe Reymann
113 39 Christophe Reymann
Check that a link to the IGN data exists in sim/precidrones-main/dev or create it (being in the dev folder) with:
114
<pre>
115
ln -s ../../IGN IGN
116
</pre>
117
118 34 Christophe Reymann
Before running the simulation:
119
* Import morse simulation scenario, for example:
120
<pre>
121
morse import sim/precidrones-main/dev/morse/preci1
122
</pre>
123 1 Christophe Reymann
124 38 Christophe Reymann
* Export all necessary env variables (check that it they are the right one!) and source ros global and workspace setup (you can put it in the .bashrc or .profile):
125 24 Christophe Reymann
<pre>
126 1 Christophe Reymann
export DISPLAY=:0
127 38 Christophe Reymann
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/nvidia-384"
128 31 Christophe Reymann
source /opt/ros/kinetic/setup.bash
129
source /home/ubuntu/sim/precidrones-main/dev/ros_workspace/devel/setup.bash
130 1 Christophe Reymann
</pre>
131 25 Christophe Reymann
132 31 Christophe Reymann
Only one container has to be setup, then it can simply be copied across machines:
133 25 Christophe Reymann
<pre>
134
TODO
135
</pre>