Installing simulation environment » History » Revision 38
Revision 37 (Christophe Reymann, 2018-05-19 16:55) → Revision 38/49 (Christophe Reymann, 2018-05-19 16:56)
h1. Installing simulation environment h2. Dependencies * Python3 with setuptools, docopt, numpy, pyaml, rospkg, catkin_pkg * Eigen3 * GDAL (version > 2) * CMake * OpenCV3 * libglew, libglew-dev * 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) * Blender * A c++14 compatible compiler h2. On own computer Make sure ROS environment is sourced, then: <pre> 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 </pre> And make sure to import the morse simulations before using them, for example (in the precidrones-main/dev folder): <pre> morse import morse/preci1 </pre> h3. On LXD vm Install and configure lxd: <pre> sudo snap install --edge lxd sudo lxd init </pre> Lxd will ask for configuration, I used: * clustering: no * new storage pool: yes * name: default * type: zfs * create new zfs pool: yes * use existing block device: no * size in GB of the new loop device: 40 * connect to a MAAS server: no * create local network bridge: yes * bridge name: lxdbr0 * ipv4 address: auto * ipv6 address: auto * LXD availqble over the network: yes * address to bind lxd to: all * port: 8443 * trust password: <password> * auto update stale cached images: yes * print YAML lxd preseed: yes Creating the container: <pre> sudo lxc launch ubuntu:16.04 precidrone-sim </pre> Install nvidia container runtime (see github ): <pre> distribution=$(. /etc/os-release;echo $ID$VERSION_ID) 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 sudo apt install nvidia-container-runtime </pre> Configuring the container *(check display number and adjust, eg X0 -> X1 for DISPLAY=:1; idem for nvidia-libs version number)*: <pre> sudo lxc config device add precidrone-sim nvgpu gpu sudo lxc config set precidrone-sim nvidia.runtime true sudo lxc config device add precidrone-sim nvidia-libs disk path=/usr/lib/nvidia-384 source=/usr/lib/nvidia-384 sudo lxc config device add precidrone-sim X0 disk path=/tmp/.X11-unix/X0 source=/tmp/.X11-unix/X0 sudo lxc config device add precidrone-sim Xauthority disk path=/home/ubuntu/.Xauthority source=${HOME}/.Xauthority sudo lxc config device add precidrone-sim precidrone-simroot disk source=/net/skyscanner/volume1/data/precidrone path=/home/ubuntu/sim printf "uid $(id -u) 1000\ngid $(id -g) 1000" | sudo lxc config set precidrone-sim raw.idmap - sudo lxc restart precidrone-sim </pre> Then open shell in the container: <pre> sudo lxc exec precidrone-sim -- sudo -i -u ubuntu </pre> Installing dependencies: <pre> sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 sudo apt update sudo apt install ros-kinetic-ros-base ros-kinetic-tf2-eigen ros-kinetic-opencv3 ros-kinetic-cv-bridge ros-kinetic-tf2-ros sudo apt install python3-pip python3-setuptools python3-docopt python3-numpy python3-yaml sudo pip3 install rospkg catkin_pkg sudo apt install libglew1.13 libglew-dev sudo apt install blender </pre> A GDAL >2 doesn't ship with ubuntu 16.04, you can do <pre> sudo add-apt-repository -y ppa:ubuntugis/ppa sudo apt update sudo apt install libgdal20 libgdal-dev </pre> If necessary compile sim source: <pre> cd sim/precidrones-main/dev make DEVEL=t INSTALL_USER=t CMAKE_BUILD_TYPE=Release -j8 </pre> Before running the simulation: * Import morse simulation scenario, for example: <pre> morse import sim/precidrones-main/dev/morse/preci1 </pre> * Export all necessary env variables display variable (check that it they are is the right one!) and source ros global and workspace setup (you can put it in the .bashrc or .profile): <pre> export DISPLAY=:0 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/nvidia-384" source /opt/ros/kinetic/setup.bash source /home/ubuntu/sim/precidrones-main/dev/ros_workspace/devel/setup.bash </pre> Only one container has to be setup, then it can simply be copied across machines: <pre> TODO </pre>