Project

General

Profile

Installing simulation environment » History » Version 38

Christophe Reymann, 2018-05-19 16:56

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