diff --git a/README.md b/README.md index 200afac05..9676d2bb9 100644 --- a/README.md +++ b/README.md @@ -54,19 +54,12 @@ $ sudo apt-get install python-rosdep python-catkin-tools $ mkdir -p ~/create_ws/src ``` -2. Clone this repo and its dependencies +2. Clone this repo ``` bash $ cd ~/create_ws/src - $ git clone https://github.com/RoboticaUtnFrba/create_autonomy.git && \ - git clone https://github.com/RoboticaUtnFrba/libcreate.git && \ - git clone https://github.com/RoboticaUtnFrba/RTIMULib2.git && \ - git clone https://github.com/RoboticaUtnFrba/i2c_imu.git && \ - git clone https://github.com/RoboticaUtnFrba/viso2.git && \ - git clone https://github.com/RoboticaUtnFrba/gscam.git + $ git clone https://github.com/RoboticaUtnFrba/create_autonomy.git ``` - **Note:** this approach will be changed with a next PR using `vcstool`. - 3. Compile RTIMULib2 ```bash $ cd ~/create_ws/src/RTIMULib2/Linux && mkdir build && cd build @@ -81,14 +74,29 @@ $ sudo apt-get install python-rosdep python-catkin-tools ``` bash $ sudo apt-get install -y gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev $ cd ~/create_ws - $ rosdep install --from-path src/ -y -i + $ sudo apt install -y python3-vcstool + $ vcs import src < src/create_autonomy/.repos + $ rosdep update + $ rosdep install --from-paths src -i ``` -4. Build - ``` bash - $ cd ~/create_ws - $ catkin_make - ``` +4. Build + + 4.1. Build RTIMULib2 for Raspberry Pi + + $ cd ~/create_ws/src/RTIMULib2/Linux + $ mkdir build + $ cd build + $ cmake .. + $ make -j4 + $ sudo make install + $ sudo ldconfig + + 4.2. Build workspace + + $ cd ~/create_ws + $ catkin_make -DCMAKE_BUILD_TYPE=Release + #### USB Permissions 5. In order to connect to Create over USB, ensure your user is in the dialout group ``` bash diff --git a/ca_bumper2pc/CMakeLists.txt b/ca_bumper2pc/CMakeLists.txt index 84434ad39..5c49c3a46 100644 --- a/ca_bumper2pc/CMakeLists.txt +++ b/ca_bumper2pc/CMakeLists.txt @@ -1,12 +1,11 @@ cmake_minimum_required(VERSION 2.8.3) project(ca_bumper2pc) -find_package(catkin REQUIRED COMPONENTS - roscpp - nodelet - pluginlib +find_package(catkin REQUIRED COMPONENTS + roscpp + nodelet + pluginlib ca_msgs - sensor_msgs - kobuki_msgs + sensor_msgs ) catkin_package( diff --git a/ca_bumper2pc/package.xml b/ca_bumper2pc/package.xml index 02cd97322..c2fc64f51 100644 --- a/ca_bumper2pc/package.xml +++ b/ca_bumper2pc/package.xml @@ -20,15 +20,13 @@ pluginlib ca_msgs sensor_msgs - kobuki_msgs roscpp nodelet pluginlib ca_msgs sensor_msgs - kobuki_msgs - + diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 000000000..7c6ca378c --- /dev/null +++ b/docker/Makefile @@ -0,0 +1,18 @@ +# If you want to rebuild all images, set this to --no-cache from the commandline +DOCKER_ARGS?= + +.PHONY: create_ubuntu_bionic +create_ubuntu_bionic: + docker build ${DOCKER_ARGS} -t create_ubuntu_bionic create_ubuntu_bionic + +.PHONY: create_ros_melodic +create_ros_melodic: create_ubuntu_bionic + docker build ${DOCKER_ARGS} -t create_ros_melodic create_ros_melodic + +.PHONY: create_gazebo9 +create_gazebo9: create_ros_melodic + docker build ${DOCKER_ARGS} -t create_gazebo9 create_gazebo9 + +.PHONY: create_nvidia +create_nvidia: create_gazebo9 + docker build ${DOCKER_ARGS} -t create_nvidia create_nvidia diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..bd7bdd502 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,95 @@ +# ROS Melodic + Gazebo 9 on Docker + +## Step 1: Install Docker +[Install docker](https://docs.docker.com/engine/installation/linux/ubuntu/) and [configure after postintalling it](https://docs.docker.com/install/linux/linux-postinstall/). + +To run docker without super user: + + ```bash + $ sudo groupadd docker + $ sudo gpasswd -a ${USER} docker + $ sudo service docker restart + ``` + +## Step 2: Use NVIDIA acceleration + +### Install [nvidia-docker2](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)) + +#### Prerequisites + +1. GNU/Linux x86_64 with kernel version > 3.10 +2. Docker >= 1.12 +3. NVIDIA GPU with Architecture > Fermi (2.1) +4. NVIDIA drivers ~= 361.93 (untested on older versions) + +#### Removing nvidia-docker 1.0 + +Version 1.0 of the nvidia-docker package must be cleanly removed before continuing. +You must stop and remove all containers started with nvidia-docker 1.0. + + ```bash + $ docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f + $ sudo apt-get purge nvidia-docker + ``` + +#### Installing version 2.0 + +Make sure you have installed the [NVIDIA driver](https://github.com/NVIDIA/nvidia-docker/wiki/Frequently-Asked-Questions#how-do-i-install-the-nvidia-driver). + +If you have a custom `/etc/docker/daemon.json`, the `nvidia-docker2` package might override it. + +Install the repository for your distribution by following the instructions here. + + ```bash + $ wcurl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ + sudo apt-key add - + $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) + $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ + sudo tee /etc/apt/sources.list.d/nvidia-docker.list + $ sudo apt-get update + ``` + +Add Docker's official GPG key. + + ```bash + $ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ + sudo apt-key add - + ``` + +Install the `nvidia-docker2` package and reload the Docker daemon configuration: + + ```bash + $ sudo apt-get install nvidia-docker2 + $ sudo pkill -SIGHUP dockerd + ``` + +## Step 3: Creating the container + +This repository contain the Dockerfile. Move into the directory containing the file and type + +The command below will **create** the container from the base image if it doesn't exist and log you in. + + ```bash + $ make create-melodic-gazebo9 + ``` + +## Step 4: Start the container + +To make it easier, I created the launcher **launch_docker.sh** (you might need to call **chmod +x ./launch_docker.sh** first). + + ```bash + $ ./launch_docker.sh -d create_nvidia + ``` + +Every time you launch the Docker container, you'll need to compile the workspace and source: + + ```bash + $ catkin_make -DCMAKE_BUILD_TYPE=Release -j4 + $ source devel/setup.bash + ``` + +# References + +* http://wiki.ros.org/docker/Tutorials/Docker +* http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration +* http://wiki.ros.org/docker/Tutorials/GUI diff --git a/docker/create-melodic-gazebo9/Dockerfile b/docker/create-melodic-gazebo9/Dockerfile new file mode 100644 index 000000000..75a3541e4 --- /dev/null +++ b/docker/create-melodic-gazebo9/Dockerfile @@ -0,0 +1,114 @@ +FROM ros:melodic-ros-base +LABEL maintainer="Emiliano Borghi" + +ENV ROS_DISTRO melodic + +RUN apt-get update && \ + apt-get install --no-install-recommends -y \ + apt-utils \ + curl \ + dialog \ + software-properties-common \ + tmux \ + wget + +# Setup environment +ENV \ + LANG=en_US.UTF-8 \ + DEBIAN_FRONTEND=noninteractive \ + TERM=xterm +RUN apt-get update && apt-get install -y locales +RUN locale-gen en_US.UTF-8 + +# install bootstrap tools +RUN apt-get update && apt-get install --no-install-recommends -y \ + ros-${ROS_DISTRO}-gazebo-* \ + && rm -rf /var/lib/apt/lists/* + +# ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn + +# Setup sources.list for ROS +RUN echo "deb http://packages.ros.org/ros/ubuntu bionic main" > /etc/apt/sources.list.d/ros-latest.list + +# Setup keys for ROS +RUN apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 + +# Setup sources.list for Gazebo +RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic main" > /etc/apt/sources.list.d/gazebo-stable.list + +# Setup keys for Gazebo +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 + +# Install bootstrap tools +RUN apt-get update && apt-get install --no-install-recommends -y \ + python-rosdep \ + python-rosinstall \ + python3-vcstool + +# Install ROS packages +RUN apt-get update && \ + apt-get install -y \ + gazebo9 \ + libgazebo9-dev + +RUN apt-get clean -y && \ + apt-get autoremove -y && \ + apt-get autoclean -y && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /usr/share/doc + +# Install dependencies for gscam and visual odometry +RUN apt-get update && \ + apt-get install -y \ + gstreamer1.0-tools \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer-plugins-good1.0-dev + +# Install ROS dependencies +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + ros-${ROS_DISTRO}-amcl \ + ros-${ROS_DISTRO}-camera-calibration \ + ros-${ROS_DISTRO}-controller-manager \ + ros-${ROS_DISTRO}-ecl-threads \ + ros-${ROS_DISTRO}-gazebo-ros-pkgs \ + ros-${ROS_DISTRO}-joint-state-publisher \ + ros-${ROS_DISTRO}-joy-teleop \ + ros-${ROS_DISTRO}-map-server \ + ros-${ROS_DISTRO}-move-base \ + ros-${ROS_DISTRO}-pcl-ros \ + ros-${ROS_DISTRO}-robot-localization \ + ros-${ROS_DISTRO}-robot-state-publisher \ + ros-${ROS_DISTRO}-yocs-controllers \ + ros-${ROS_DISTRO}-xacro \ + && \ + apt-get clean && \ + apt-get autoremove && \ + apt-get autoclean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /usr/share/doc + +# Compile RTIMULib2 and IMU dependencies +RUN mkdir -p /home/${USER}/catkin_ws/src +WORKDIR /home/${USER}/catkin_ws/src +RUN git clone https://github.com/RoboticaUtnFrba/RTIMULib2.git && \ + git clone https://github.com/RoboticaUtnFrba/i2c_imu.git +WORKDIR /home/${USER}/catkin_ws/src/RTIMULib2/Linux +RUN apt-get update && apt-get install -y libqt4-dev +RUN mkdir build && \ + cd build && \ + cmake .. && \ + make -j4 && \ + make install && \ + ldconfig + +ENV PATH /usr/local/nvidia/bin:${PATH} +ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH} + +RUN echo ". /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/${USER}/.bashrc + +WORKDIR /home/${USER}/catkin_ws + +CMD [ "tmux" ] \ No newline at end of file diff --git a/docker/create_gazebo9/Dockerfile b/docker/create_gazebo9/Dockerfile new file mode 100644 index 000000000..20d2e866b --- /dev/null +++ b/docker/create_gazebo9/Dockerfile @@ -0,0 +1,21 @@ +FROM create_ros_melodic +LABEL maintainer="Emiliano Borghi" + +ENV ROS1_DISTRO=melodic + +USER root + +# Setup sources.list for Gazebo +RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable bionic main" > /etc/apt/sources.list.d/gazebo-stable.list + +# Setup keys for Gazebo +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 + +RUN apt-get update && \ + apt-get install -y \ + gazebo9 \ + libgazebo9-dev \ + ros-$ROS1_DISTRO-gazebo-ros-pkgs \ + ros-$ROS1_DISTRO-gazebo-ros-control + +CMD tmux diff --git a/docker/create_nvidia/Dockerfile b/docker/create_nvidia/Dockerfile new file mode 100644 index 000000000..6d868f164 --- /dev/null +++ b/docker/create_nvidia/Dockerfile @@ -0,0 +1,15 @@ +FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 as nvidia +FROM create_gazebo9 +LABEL maintainer="Emiliano Borghi" + +# Installing OpenGL for nvidia-docker2 +# https://stackoverflow.com/a/53823600 + +COPY --from=nvidia /usr/local /usr/local +COPY --from=nvidia /etc/ld.so.conf.d/glvnd.conf /etc/ld.so.conf.d/glvnd.conf + +ENV NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=all + +RUN apt-get update + +USER create diff --git a/docker/create_ros_melodic/Dockerfile b/docker/create_ros_melodic/Dockerfile new file mode 100644 index 000000000..9f6b74667 --- /dev/null +++ b/docker/create_ros_melodic/Dockerfile @@ -0,0 +1,69 @@ +FROM create_ubuntu_bionic +LABEL maintainer="Emiliano Borghi" + +ENV ROS1_DISTRO=melodic + +USER root + +# Setup sources.list for ROS +RUN echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list + +# Setup keys for ROS +RUN apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 + +# Install ROS packages +RUN apt-get update && \ + apt-get install -y \ + ros-$ROS1_DISTRO-xacro \ + ros-$ROS1_DISTRO-desktop && \ + apt-get clean && \ + apt-get autoremove && \ + apt-get autoclean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /usr/share/doc + +# Initialize rosdep +RUN rosdep init + +# Install camera dependencies +RUN apt-get update && apt-get install -y \ + gstreamer1.0-tools \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev \ + libgstreamer-plugins-good1.0-dev + +RUN apt-get update && \ + apt-get install -y \ + ros-$ROS1_DISTRO-amcl \ + ros-$ROS1_DISTRO-camera-calibration \ + ros-$ROS1_DISTRO-controller-manager \ + ros-$ROS1_DISTRO-ecl-threads \ + ros-$ROS1_DISTRO-hardware-interface \ + ros-$ROS1_DISTRO-joint-limits-interface \ + ros-$ROS1_DISTRO-move-base \ + ros-$ROS1_DISTRO-pcl-ros \ + ros-$ROS1_DISTRO-robot-localization \ + ros-$ROS1_DISTRO-transmission-interface \ + ros-$ROS1_DISTRO-yocs-controllers \ + && \ + apt-get clean && \ + apt-get autoremove && \ + apt-get autoclean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /usr/share/doc + +RUN pip install --upgrade pip + +USER create +RUN echo ". /opt/ros/$ROS1_DISTRO/setup.bash" >> /home/create/.bashrc +USER root + +# Workspace +RUN mkdir -p /create_ws/src/ && \ + chown -R create /create_ws +USER create +WORKDIR /create_ws/ +RUN rosdep update +USER root + +CMD tmux diff --git a/docker/create_ubuntu_bionic/Dockerfile b/docker/create_ubuntu_bionic/Dockerfile new file mode 100644 index 000000000..a0ca25851 --- /dev/null +++ b/docker/create_ubuntu_bionic/Dockerfile @@ -0,0 +1,44 @@ +FROM ubuntu:18.04 +LABEL maintainer="Emiliano Borghi" + +# Setup environment +RUN apt-get update && apt-get install -y locales +RUN locale-gen en_US.UTF-8 +ENV \ + LANG=en_US.UTF-8 \ + DEBIAN_FRONTEND=noninteractive \ + TERM=xterm + +RUN apt-get update && \ + apt-get install --no-install-recommends -y \ + apt-utils \ + bash-completion \ + build-essential \ + curl \ + git \ + mesa-utils \ + pkg-config \ + python-vcstools \ + python-pip \ + software-properties-common \ + ssh \ + sudo \ + tmux \ + wget + +RUN apt-get update && \ + apt-get install -y dirmngr && \ + apt-get upgrade -y && \ + apt-get clean && \ + apt-get autoremove && \ + apt-get autoclean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /usr/share/doc + +# Create a user with passwordless sudo +RUN adduser --gecos "Development User" --disabled-password create +RUN adduser create sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER root + +CMD tmux diff --git a/docker/launch_docker.sh b/docker/launch_docker.sh new file mode 100755 index 000000000..87a9030cb --- /dev/null +++ b/docker/launch_docker.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +CONTAINER="" + +while [ "$1" != "" ]; do + case "$1" in + -d | --docker ) CONTAINER="$2"; shift;; + esac + shift +done + +IMAGE_NAME=${CONTAINER} + +NVIDIA_FLAG="" +if [[ $IMAGE_NAME = *"nvidia"* ]]; then + NVIDIA_FLAG="--runtime=nvidia" +fi + +xhost + +docker run -it \ + --privileged --rm \ + "--ipc=host" \ + "--cap-add=IPC_LOCK" \ + "--cap-add=sys_nice" \ + "--network=host" \ + --env="DISPLAY" \ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --volume="/home/$USER/create_ws/src:/create_ws/src" \ + -e ROS_HOSTNAME=localhost \ + -e ROS_MASTER_URI=http://localhost:11311 \ + $NVIDIA_FLAG \ + create_nvidia diff --git a/remote.repos b/remote.repos new file mode 100644 index 000000000..847f3142f --- /dev/null +++ b/remote.repos @@ -0,0 +1,13 @@ +repositories: + gscam: + type: git + url: git@github.com:RoboticaUtnFrba/gscam.git + version: master + libcreate: + type: git + url: git@github.com:RoboticaUtnFrba/libcreate.git + version: master + viso2: + type: git + url: git@github.com:RoboticaUtnFrba/viso2.git + version: kinetic diff --git a/rpi.repos b/rpi.repos new file mode 100644 index 000000000..cb1097d83 --- /dev/null +++ b/rpi.repos @@ -0,0 +1,13 @@ +repositories: + i2c_imu: + type: git + url: git@github.com:RoboticaUtnFrba/i2c_imu.git + version: master + libcreate: + type: git + url: git@github.com:RoboticaUtnFrba/libcreate.git + version: master + RTIMULib2: + type: git + url: git@github.com:RoboticaUtnFrba/RTIMULib2.git + version: master