From c1d927da4d59e7ccc4867cff5f096ff81156aa23 Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Tue, 18 May 2021 13:02:24 +0200 Subject: [PATCH 1/8] Added docker support --- README.md | 33 +++++++++++++++------------------ docker/README.md | 18 ++++++++++++++++++ docker/base/Dockerfile | 18 ++++++++++++++++++ docker/build-ros-image.sh | 4 ++++ docker/catkin-build/Dockerfile | 9 +++++++++ docker/run-ros-image.sh | 2 ++ docker/workspace/Dockerfile | 29 +++++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 docker/README.md create mode 100644 docker/base/Dockerfile create mode 100755 docker/build-ros-image.sh create mode 100644 docker/catkin-build/Dockerfile create mode 100755 docker/run-ros-image.sh create mode 100644 docker/workspace/Dockerfile diff --git a/README.md b/README.md index e4f84b5..f529f6e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ TSDF++ is a novel multi-object TSDF formulation that can encode multiple object surfaces at each voxel. In a multiple dynamic object tracking and reconstruction scenario, a TSDF++ map representation allows maintaining accurate reconstruction of surfaces even while they become temporarily occluded by other objects moving in their proximity. At the same time, the representation allows maintaining a single volume for the entire scene and all the objects therein, thus solving the fundamental challenge of scalability with respect to the number of objects in the scene and removing the need for an explicit occlusion handling strategy. -## Citing +## Citing When using **TSDF++** in your research, please cite the following publication: @@ -22,11 +22,11 @@ Margarita Grinvald, Federico Tombari, Roland Siegwart, and Juan Nieto, **TSDF++: The installation has been tested on Ubuntu 16.04 and Ubutnu 20.04. ### Requirements -- ROS +- ROS - C++14 for [PCL 1.10](https://github.com/PointCloudLibrary/pcl) ### Install dependencies -Install ROS following the instructions at the [ROS installation page](http://wiki.ros.org/ROS/Installation). The full install (`ros-kinetic-desktop-full`, `ros-melodic-desktop-full`) are recommended. +Install ROS following the instructions at the [ROS installation page](http://wiki.ros.org/ROS/Installation). The full install (`ros-kinetic-desktop-full`, `ros-melodic-desktop-full`) are recommended. Make sure to source your ROS _setup.bash_ script by following the instructions on the ROS installation page. @@ -42,24 +42,16 @@ If you don't have a [catkin](http://wiki.ros.org/catkin) workspace yet, create a ```bash mkdir -p $CATKIN_WS/src && cd $CATKIN_WS catkin init -catkin config --extend /opt/ros/$ROS_VERSION --merge-devel +catkin config --extend /opt/ros/$ROS_VERSION --merge-devel catkin config --cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Release wstool init src ``` -Clone the `tsdf-plusplus` repository over HTTPS (no Github account required) and automatically fetch dependencies: +Clone the `tsdf-plusplus` repository (first tries over SSH and falls back to HTTPS): ```bash cd $CATKIN_WS/src -git clone https://github.com/ethz-asl/tsdf-plusplus.git -wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall -wstool update -``` - -Alternatively, clone over SSH (Github account required): -```bash -cd $CATKIN_WS/src -git clone git@github.com:ethz-asl/tsdf-plusplus.git -wstool merge -t . tsdf-plusplus/tsdf_plusplus_ssh.rosinstall +git clone git@github.com:ethz-asl/tsdf-plusplus.git | git clone https://github.com/ethz-asl/tsdf-plusplus.git +wstool merge -t . tsdf-plusplus/tsdf_plusplus_ssh.rosinstall | wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall wstool update ``` @@ -69,16 +61,21 @@ catkin build tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentatio source ../devel/setup.bash # (bash shell: ../devel/setup.bash, zsh shell: ../devel/setup.zsh) ``` +# Installation using Docker + +See [Docker README.md](docker/README.md) for details. + ## Troubleshooting ### Compilation freeze -By default `catkin build` on a computer with `N` CPU cores will run `N` `make` jobs simultaneously. If compilation seems to hang forever, it might be running low on RAM. Try limiting the number of maximum parallel build jobs through the `-jN` flag to a value way lower than your CPU count, i.e. +By default `catkin build` on a computer with `N` CPU cores will run `N` `make` jobs simultaneously. If compilation seems to hang forever, it might be running low on RAM. Try limiting the number of maximum parallel build jobs through the `-jN` flag to a value way lower than your CPU count. +For instance, you can use half the cores in your computer. This will provide the OS and other processes the other half. ```bash -catkin build tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation -j4 +catkin build tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation -j$(($(nproc) / 2)) ``` If it still freezes at compilation time, you can go as far as limiting the maximum number of parallel build jobs and max load to `1` through the `-lN` flag: ```bash -catkin build tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation -j1 -l1 +catkin build tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation -j$(($(nproc) / 2)) -l1 ``` ## License diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..6ad4a1b --- /dev/null +++ b/docker/README.md @@ -0,0 +1,18 @@ +# Introduction + +To build the docker image ( `tsdf-plusplus-ros-catkin-build` ) run: +```bash +./build-ros-image.sh +``` + +To run the docker image use: +```bash +./run-ros-image.sh +``` + +The workspace is located in `/home/ros/tsdf-plusplus_ws` and the `docker` user is `ros`. + +TODO: + - Allow mounted local workspaced in docker + - Automatically build the current (remote) branch + - Entrypoint with all nodes running \ No newline at end of file diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 0000000..1ab25aa --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,18 @@ +FROM ros:melodic-ros-core +ENV DEBIAN_FRONTEND=noninteractive + +# Install dependencies +RUN apt update -y +RUN apt upgrade -y +RUN apt install -y build-essential tree vim \ + git sudo python-pip ros-melodic-catkin \ + autoconf libtool python-catkin-tools \ + ros-melodic-eigen-conversions \ + ros-melodic-pcl-ros ros-melodic-image-transport \ + ros-melodic-codec-image-transport ros-melodic-pcl-msgs \ + ros-melodic-pcl-conversions ros-melodic-cv-bridge \ + ros-melodic-tf-conversions ros-melodic-rviz && \ + rm -rf /var/lib/apt/lists/* && \ + apt clean && \ + apt autoclean +RUN pip install -U osrf-pycommon wstool setuptools \ No newline at end of file diff --git a/docker/build-ros-image.sh b/docker/build-ros-image.sh new file mode 100755 index 0000000..616552f --- /dev/null +++ b/docker/build-ros-image.sh @@ -0,0 +1,4 @@ +#!/bin/bash +docker build -t tsdf-plusplus-ros-base:v0.1 base +docker build -t tsdf-plusplus-ros-workspace:v0.1 workspace +docker build -t tsdf-plusplus-ros-catkin-build:v0.1 catkin-build \ No newline at end of file diff --git a/docker/catkin-build/Dockerfile b/docker/catkin-build/Dockerfile new file mode 100644 index 0000000..02343b0 --- /dev/null +++ b/docker/catkin-build/Dockerfile @@ -0,0 +1,9 @@ +FROM tsdf-plusplus-ros-workspace:v0.1 + +USER $USERNAME +WORKDIR /home/$USERNAME +ARG ROS_VERSION=melodic +ARG CATKIN_WS=/home/ros/catkin_ws +RUN bash -c 'source /opt/ros/melodic/setup.bash && \ + cd $CATKIN_WS && \ + catkin build -j$(($(nproc) / 2)) -l1 tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation' \ No newline at end of file diff --git a/docker/run-ros-image.sh b/docker/run-ros-image.sh new file mode 100755 index 0000000..196bd42 --- /dev/null +++ b/docker/run-ros-image.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker run -it tsdf-plusplus-ros-catkin-build:v0.1 bash \ No newline at end of file diff --git a/docker/workspace/Dockerfile b/docker/workspace/Dockerfile new file mode 100644 index 0000000..a5c5aab --- /dev/null +++ b/docker/workspace/Dockerfile @@ -0,0 +1,29 @@ +FROM tsdf-plusplus-ros-base:v0.1 + +# Create 'ros' user with sudo powers +ARG USERNAME=ros +ARG USER_UID=1001 +ARG USER_GID=$USER_UID +RUN groupadd --gid $USER_GID $USERNAME \ + && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \ + && echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc + +# Create workspace +USER $USERNAME +WORKDIR /home/$USERNAME +ARG ROS_VERSION=melodic +ARG CATKIN_WS=/home/ros/catkin_ws +RUN bash -c 'source /opt/ros/melodic/setup.bash && \ + mkdir -p $CATKIN_WS/src && \ + cd $CATKIN_WS && \ + catkin init && \ + catkin config --extend /opt/ros/melodic --merge-devel && \ + catkin config --cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Release && \ + wstool init src && \ + cd $CATKIN_WS/src && \ + git clone https://github.com/ethz-asl/tsdf-plusplus.git && \ + wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall && \ + wstool update' From 1e5fcff367ce2d9ce442b7e46fa2a966e5fd8e2e Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 09:12:43 +0200 Subject: [PATCH 2/8] Run docker image with ros user --- docker/run-ros-image.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/run-ros-image.sh b/docker/run-ros-image.sh index 196bd42..1f2492a 100755 --- a/docker/run-ros-image.sh +++ b/docker/run-ros-image.sh @@ -1,2 +1,6 @@ #!/bin/bash -docker run -it tsdf-plusplus-ros-catkin-build:v0.1 bash \ No newline at end of file +docker container run --rm -it \ + --user 1001 \ + --workdir /home/ros/catkin_ws \ + tsdf-plusplus-ros-catkin-build:v0.1 \ + bash \ No newline at end of file From 5af53f56de6c310706e445601c62ff13be1ac963 Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 10:07:05 +0200 Subject: [PATCH 3/8] Set up local environment --- docker/README.md | 29 +++++++++++++++++++++++++++-- docker/run-ros-image.sh | 8 +++++++- docker/set-me-up.sh | 9 +++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100755 docker/set-me-up.sh diff --git a/docker/README.md b/docker/README.md index 6ad4a1b..14ab5b4 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,4 +1,4 @@ -# Introduction +# Building image and running container To build the docker image ( `tsdf-plusplus-ros-catkin-build` ) run: ```bash @@ -10,7 +10,32 @@ To run the docker image use: ./run-ros-image.sh ``` -The workspace is located in `/home/ros/tsdf-plusplus_ws` and the `docker` user is `ros`. +# Getting environment up and running + +If you want to get quicky up and runing, keeping sources on your computer +and using docker as a as a perdictable build system you can run: +```bash +./build-ros-image.sh +./set-me-up.sh +``` + +You can skip running `build-ros-image.sh` if the image is already built. + +This `set-me-up.sh` script will do the following: +- Run a docker container +- Copy the built workspace to the destination folder of choice +- Stop the container + +Note that if you want to change the remote to SSH or your fork you'll need to edit the origin in the cloned repos. +For instance, in the `tsdf-plusplus` project use something like: +```bash +git remote set-url origin git@github.com:ethz-asl/tsdf-plusplus.git +``` + +You can confirm you have the right origin URL by running: +```bash +git remote show origin +``` TODO: - Allow mounted local workspaced in docker diff --git a/docker/run-ros-image.sh b/docker/run-ros-image.sh index 1f2492a..ad83f47 100755 --- a/docker/run-ros-image.sh +++ b/docker/run-ros-image.sh @@ -1,6 +1,12 @@ #!/bin/bash -docker container run --rm -it \ +mode=$1 +if [ -z "$1" ] + then + mode="it" +fi +docker container run --rm -$mode \ --user 1001 \ + --name tsdf-plusplus \ --workdir /home/ros/catkin_ws \ tsdf-plusplus-ros-catkin-build:v0.1 \ bash \ No newline at end of file diff --git a/docker/set-me-up.sh b/docker/set-me-up.sh new file mode 100755 index 0000000..07fb71b --- /dev/null +++ b/docker/set-me-up.sh @@ -0,0 +1,9 @@ +#!/bin/bash +./run-ros-image.sh dt +sleep 5 +container_id=$(docker ps -aqf "name=tsdf-plusplus" | tr -d '\n') +echo "Docker container $container_id" +echo "Write absolute path of the folder on your computer, you want the entire '/home/ros/catkin_ws' folder on the docker machine to be copied into:" +read destination_folder +docker cp $container_id:/home/ros/catkin_ws $destination_folder +docker stop -t 1 $container_id \ No newline at end of file From fc22c8bfba4e47a0e45bfc3a6a141e6a3e280abd Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 11:08:40 +0200 Subject: [PATCH 4/8] huge refactoring to enable developing locally using docker --- docker/README.md | 31 ++++++++++++++++++++++++++++++- docker/base/Dockerfile | 15 ++++++++++++++- docker/build-ros-image.sh | 2 +- docker/catkin-build/Dockerfile | 6 ++++++ docker/docker-develop.sh | 19 +++++++++++++++++++ docker/run-ros-image.sh | 2 +- docker/workspace/Dockerfile | 18 ++---------------- 7 files changed, 73 insertions(+), 20 deletions(-) create mode 100755 docker/docker-develop.sh diff --git a/docker/README.md b/docker/README.md index 14ab5b4..4ca49a1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -12,6 +12,8 @@ To run the docker image use: # Getting environment up and running +## Copy workspace from docker machine + If you want to get quicky up and runing, keeping sources on your computer and using docker as a as a perdictable build system you can run: ```bash @@ -37,7 +39,34 @@ You can confirm you have the right origin URL by running: git remote show origin ``` +## Use computer workspace on docker + +If you have your workspace locally and want to use the docker machine to build +and/or run nodes, you can use the scrip `docker-develop.sh`. +This script will discard the sources from the remote repository and instead +use the sources you have locally on your computer that will be mounted +on the docker machine. + +For example, you can use the following command: +```bash +docker-develop.sh /home//catkin_ws +``` + +If you want to run it as a daemon you can use: +```bash +docker-develop.sh /home//catkin_ws dt +``` + +Once you are in the docker machine you can, for instance, build +from sources doing +```bash + catkin build -j$(($(nproc) / 2)) -l1 tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation +``` + +By doing so, the docker machine will build the sources on your computer and +keep the binaries on your computer as well. + + TODO: - - Allow mounted local workspaced in docker - Automatically build the current (remote) branch - Entrypoint with all nodes running \ No newline at end of file diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 1ab25aa..39856bc 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -1,6 +1,9 @@ FROM ros:melodic-ros-core ENV DEBIAN_FRONTEND=noninteractive +ARG USER_ID +ARG GROUP_ID + # Install dependencies RUN apt update -y RUN apt upgrade -y @@ -15,4 +18,14 @@ RUN apt install -y build-essential tree vim \ rm -rf /var/lib/apt/lists/* && \ apt clean && \ apt autoclean -RUN pip install -U osrf-pycommon wstool setuptools \ No newline at end of file +RUN pip install -U osrf-pycommon wstool setuptools + + +# Create 'ros' user with sudo powers +ARG USERNAME=ros +RUN groupadd --gid $GROUP_ID $USERNAME +RUN useradd -s /bin/bash --uid $USER_ID --gid $GROUP_ID -m $USERNAME +RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME +RUN chmod 0440 /etc/sudoers.d/$USERNAME +RUN echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc +RUN echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc diff --git a/docker/build-ros-image.sh b/docker/build-ros-image.sh index 616552f..bcfba8d 100755 --- a/docker/build-ros-image.sh +++ b/docker/build-ros-image.sh @@ -1,4 +1,4 @@ #!/bin/bash -docker build -t tsdf-plusplus-ros-base:v0.1 base +docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t tsdf-plusplus-ros-base:v0.1 base docker build -t tsdf-plusplus-ros-workspace:v0.1 workspace docker build -t tsdf-plusplus-ros-catkin-build:v0.1 catkin-build \ No newline at end of file diff --git a/docker/catkin-build/Dockerfile b/docker/catkin-build/Dockerfile index 02343b0..464d15e 100644 --- a/docker/catkin-build/Dockerfile +++ b/docker/catkin-build/Dockerfile @@ -1,9 +1,15 @@ FROM tsdf-plusplus-ros-workspace:v0.1 +ARG USERNAME=ros USER $USERNAME WORKDIR /home/$USERNAME ARG ROS_VERSION=melodic ARG CATKIN_WS=/home/ros/catkin_ws +RUN bash -c 'source /opt/ros/melodic/setup.bash && \ + cd $CATKIN_WS/src && \ + git clone https://github.com/ethz-asl/tsdf-plusplus.git && \ + wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall && \ + wstool update' RUN bash -c 'source /opt/ros/melodic/setup.bash && \ cd $CATKIN_WS && \ catkin build -j$(($(nproc) / 2)) -l1 tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation' \ No newline at end of file diff --git a/docker/docker-develop.sh b/docker/docker-develop.sh new file mode 100755 index 0000000..1a8503f --- /dev/null +++ b/docker/docker-develop.sh @@ -0,0 +1,19 @@ +#!/bin/bash +workspace_folder=$1 +if [ -z "$1" ] + then + echo "Absolute path of the workspace folder not found" + exit 1 +fi +mode=$2 +if [ -z "$2" ] + then + mode="it" +fi +docker container run --rm -$mode \ + --user $(id -u) \ + --mount type=bind,source="${workspace_folder}",target=/home/ros/catkin_ws \ + --name tsdf-plusplus-dev \ + --workdir /home/ros/catkin_ws \ + tsdf-plusplus-ros-base:v0.1 \ + bash \ No newline at end of file diff --git a/docker/run-ros-image.sh b/docker/run-ros-image.sh index ad83f47..3cdc73b 100755 --- a/docker/run-ros-image.sh +++ b/docker/run-ros-image.sh @@ -5,7 +5,7 @@ if [ -z "$1" ] mode="it" fi docker container run --rm -$mode \ - --user 1001 \ + --user $(id -u) \ --name tsdf-plusplus \ --workdir /home/ros/catkin_ws \ tsdf-plusplus-ros-catkin-build:v0.1 \ diff --git a/docker/workspace/Dockerfile b/docker/workspace/Dockerfile index a5c5aab..5cb1786 100644 --- a/docker/workspace/Dockerfile +++ b/docker/workspace/Dockerfile @@ -1,17 +1,7 @@ FROM tsdf-plusplus-ros-base:v0.1 -# Create 'ros' user with sudo powers -ARG USERNAME=ros -ARG USER_UID=1001 -ARG USER_GID=$USER_UID -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \ - && echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc - # Create workspace +ARG USERNAME=ros USER $USERNAME WORKDIR /home/$USERNAME ARG ROS_VERSION=melodic @@ -22,8 +12,4 @@ RUN bash -c 'source /opt/ros/melodic/setup.bash && \ catkin init && \ catkin config --extend /opt/ros/melodic --merge-devel && \ catkin config --cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Release && \ - wstool init src && \ - cd $CATKIN_WS/src && \ - git clone https://github.com/ethz-asl/tsdf-plusplus.git && \ - wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall && \ - wstool update' + wstool init src' From 8a207f9997d11ec742d19d6c0ff4f4e91bacca7e Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 11:19:10 +0200 Subject: [PATCH 5/8] typos in doc --- docker/README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docker/README.md b/docker/README.md index 4ca49a1..d62f007 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,11 +1,11 @@ # Building image and running container -To build the docker image ( `tsdf-plusplus-ros-catkin-build` ) run: +To build the docker image run: ```bash ./build-ros-image.sh ``` -To run the docker image use: +To run the docker image run: ```bash ./run-ros-image.sh ``` @@ -14,8 +14,7 @@ To run the docker image use: ## Copy workspace from docker machine -If you want to get quicky up and runing, keeping sources on your computer -and using docker as a as a perdictable build system you can run: +To the local development environment up and running quickly using docker run: ```bash ./build-ros-image.sh ./set-me-up.sh @@ -28,7 +27,7 @@ This `set-me-up.sh` script will do the following: - Copy the built workspace to the destination folder of choice - Stop the container -Note that if you want to change the remote to SSH or your fork you'll need to edit the origin in the cloned repos. +Note that if you want to change the remote to SSH or your fork you'll need to edit the `origin` in the cloned repos. For instance, in the `tsdf-plusplus` project use something like: ```bash git remote set-url origin git@github.com:ethz-asl/tsdf-plusplus.git @@ -42,9 +41,9 @@ git remote show origin ## Use computer workspace on docker If you have your workspace locally and want to use the docker machine to build -and/or run nodes, you can use the scrip `docker-develop.sh`. +and/or run nodes, you can use the script `docker-develop.sh`. This script will discard the sources from the remote repository and instead -use the sources you have locally on your computer that will be mounted +use the sources you have locally on your computer, which will be mounted on the docker machine. For example, you can use the following command: From a7c1e05fbff9b91ba1e76a8c05a48638fa7b419c Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 11:24:25 +0200 Subject: [PATCH 6/8] original doc reverted as it is not necessary anyways --- README.md | 14 +++++++++++--- docker/README.md | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f529f6e..a50d18f 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,19 @@ catkin config --cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Release wstool init src ``` -Clone the `tsdf-plusplus` repository (first tries over SSH and falls back to HTTPS): +Clone the `tsdf-plusplus` repository over HTTPS (no Github account required) and automatically fetch dependencies: ```bash cd $CATKIN_WS/src -git clone git@github.com:ethz-asl/tsdf-plusplus.git | git clone https://github.com/ethz-asl/tsdf-plusplus.git -wstool merge -t . tsdf-plusplus/tsdf_plusplus_ssh.rosinstall | wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall +git clone https://github.com/ethz-asl/tsdf-plusplus.git +wstool merge -t . tsdf-plusplus/tsdf_plusplus_https.rosinstall +wstool update +``` + +Alternatively, clone over SSH (Github account required): +```bash +cd $CATKIN_WS/src +git clone git@github.com:ethz-asl/tsdf-plusplus.git +wstool merge -t . tsdf-plusplus/tsdf_plusplus_ssh.rosinstall wstool update ``` diff --git a/docker/README.md b/docker/README.md index d62f007..05debc0 100644 --- a/docker/README.md +++ b/docker/README.md @@ -48,18 +48,18 @@ on the docker machine. For example, you can use the following command: ```bash -docker-develop.sh /home//catkin_ws +./docker-develop.sh /home//catkin_ws ``` If you want to run it as a daemon you can use: ```bash -docker-develop.sh /home//catkin_ws dt +./docker-develop.sh /home//catkin_ws dt ``` Once you are in the docker machine you can, for instance, build from sources doing ```bash - catkin build -j$(($(nproc) / 2)) -l1 tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation +catkin build -j$(($(nproc) / 2)) -l1 tsdf_plusplus_ros rgbd_segmentation mask_rcnn_ros cloud_segmentation ``` By doing so, the docker machine will build the sources on your computer and From 258fd74bdee73a18823c16320ab18ce859247d1d Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 11:30:50 +0200 Subject: [PATCH 7/8] Neatly organized files --- docker/README.md | 12 ++++++------ docker/bin/build-ros-image.sh | 4 ++++ docker/{ => bin}/docker-develop.sh | 0 docker/{ => bin}/run-ros-image.sh | 0 docker/{ => bin}/set-me-up.sh | 0 docker/build-ros-image.sh | 4 ---- docker/{ => dockerfiles}/base/Dockerfile | 0 docker/{ => dockerfiles}/catkin-build/Dockerfile | 0 docker/{ => dockerfiles}/workspace/Dockerfile | 0 9 files changed, 10 insertions(+), 10 deletions(-) create mode 100755 docker/bin/build-ros-image.sh rename docker/{ => bin}/docker-develop.sh (100%) rename docker/{ => bin}/run-ros-image.sh (100%) rename docker/{ => bin}/set-me-up.sh (100%) delete mode 100755 docker/build-ros-image.sh rename docker/{ => dockerfiles}/base/Dockerfile (100%) rename docker/{ => dockerfiles}/catkin-build/Dockerfile (100%) rename docker/{ => dockerfiles}/workspace/Dockerfile (100%) diff --git a/docker/README.md b/docker/README.md index 05debc0..b949a56 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,12 +2,12 @@ To build the docker image run: ```bash -./build-ros-image.sh +./bin/build-ros-image.sh ``` To run the docker image run: ```bash -./run-ros-image.sh +./bin/run-ros-image.sh ``` # Getting environment up and running @@ -16,8 +16,8 @@ To run the docker image run: To the local development environment up and running quickly using docker run: ```bash -./build-ros-image.sh -./set-me-up.sh +./bin/build-ros-image.sh +./bin/set-me-up.sh ``` You can skip running `build-ros-image.sh` if the image is already built. @@ -48,12 +48,12 @@ on the docker machine. For example, you can use the following command: ```bash -./docker-develop.sh /home//catkin_ws +./bin/docker-develop.sh /home//catkin_ws ``` If you want to run it as a daemon you can use: ```bash -./docker-develop.sh /home//catkin_ws dt +./bin/docker-develop.sh /home//catkin_ws dt ``` Once you are in the docker machine you can, for instance, build diff --git a/docker/bin/build-ros-image.sh b/docker/bin/build-ros-image.sh new file mode 100755 index 0000000..a2489e9 --- /dev/null +++ b/docker/bin/build-ros-image.sh @@ -0,0 +1,4 @@ +#!/bin/bash +docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t tsdf-plusplus-ros-base:v0.1 dockerfiles/base +docker build -t tsdf-plusplus-ros-workspace:v0.1 dockerfiles/workspace +docker build -t tsdf-plusplus-ros-catkin-build:v0.1 dockerfiles/catkin-build \ No newline at end of file diff --git a/docker/docker-develop.sh b/docker/bin/docker-develop.sh similarity index 100% rename from docker/docker-develop.sh rename to docker/bin/docker-develop.sh diff --git a/docker/run-ros-image.sh b/docker/bin/run-ros-image.sh similarity index 100% rename from docker/run-ros-image.sh rename to docker/bin/run-ros-image.sh diff --git a/docker/set-me-up.sh b/docker/bin/set-me-up.sh similarity index 100% rename from docker/set-me-up.sh rename to docker/bin/set-me-up.sh diff --git a/docker/build-ros-image.sh b/docker/build-ros-image.sh deleted file mode 100755 index bcfba8d..0000000 --- a/docker/build-ros-image.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t tsdf-plusplus-ros-base:v0.1 base -docker build -t tsdf-plusplus-ros-workspace:v0.1 workspace -docker build -t tsdf-plusplus-ros-catkin-build:v0.1 catkin-build \ No newline at end of file diff --git a/docker/base/Dockerfile b/docker/dockerfiles/base/Dockerfile similarity index 100% rename from docker/base/Dockerfile rename to docker/dockerfiles/base/Dockerfile diff --git a/docker/catkin-build/Dockerfile b/docker/dockerfiles/catkin-build/Dockerfile similarity index 100% rename from docker/catkin-build/Dockerfile rename to docker/dockerfiles/catkin-build/Dockerfile diff --git a/docker/workspace/Dockerfile b/docker/dockerfiles/workspace/Dockerfile similarity index 100% rename from docker/workspace/Dockerfile rename to docker/dockerfiles/workspace/Dockerfile From 13fe6807bc029568b2a5d94ef4f078c5b1e25ec6 Mon Sep 17 00:00:00 2001 From: Pau Carre Cardona Date: Sun, 23 May 2021 11:33:57 +0200 Subject: [PATCH 8/8] updated paths in doc --- docker/README.md | 39 ++++++++++++++++++--------------------- docker/bin/set-me-up.sh | 2 +- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/docker/README.md b/docker/README.md index b949a56..8f9c8d9 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,29 +5,30 @@ To build the docker image run: ./bin/build-ros-image.sh ``` -To run the docker image run: +To run the docker image use: ```bash ./bin/run-ros-image.sh ``` # Getting environment up and running -## Copy workspace from docker machine +## Set up local development environment -To the local development environment up and running quickly using docker run: +To get the a local development environment up and running quickly using docker run: ```bash ./bin/build-ros-image.sh ./bin/set-me-up.sh ``` -You can skip running `build-ros-image.sh` if the image is already built. +You can skip running `./bin/build-ros-image.sh` if the image is already built. -This `set-me-up.sh` script will do the following: +The `./bin/set-me-up.sh` script will do the following: - Run a docker container - Copy the built workspace to the destination folder of choice - Stop the container -Note that if you want to change the remote to SSH or your fork you'll need to edit the `origin` in the cloned repos. +Note that if you want to change the remote to SSH (or your fork) you'll need to edit the `origin` in the cloned repos. + For instance, in the `tsdf-plusplus` project use something like: ```bash git remote set-url origin git@github.com:ethz-asl/tsdf-plusplus.git @@ -41,21 +42,22 @@ git remote show origin ## Use computer workspace on docker If you have your workspace locally and want to use the docker machine to build -and/or run nodes, you can use the script `docker-develop.sh`. -This script will discard the sources from the remote repository and instead -use the sources you have locally on your computer, which will be mounted -on the docker machine. +and/or run nodes, you can use the script `./bin/docker-develop.sh`. +You can get such workspace locally following the previous section. + +This script will discard the workspace from the remote repository and instead +use the worksapce you have locally on your computer, which will be mounted +onto the docker machine. + +This means that the docker will use the sources on your machine as well +as build binaries onto your machine. This way you can use docker as a +build tool and code locally on your computer while keeping the binaries. For example, you can use the following command: ```bash ./bin/docker-develop.sh /home//catkin_ws ``` -If you want to run it as a daemon you can use: -```bash -./bin/docker-develop.sh /home//catkin_ws dt -``` - Once you are in the docker machine you can, for instance, build from sources doing ```bash @@ -63,9 +65,4 @@ catkin build -j$(($(nproc) / 2)) -l1 tsdf_plusplus_ros rgbd_segmentation mask_rc ``` By doing so, the docker machine will build the sources on your computer and -keep the binaries on your computer as well. - - -TODO: - - Automatically build the current (remote) branch - - Entrypoint with all nodes running \ No newline at end of file +keep the binaries on your computer as well. \ No newline at end of file diff --git a/docker/bin/set-me-up.sh b/docker/bin/set-me-up.sh index 07fb71b..f981e74 100755 --- a/docker/bin/set-me-up.sh +++ b/docker/bin/set-me-up.sh @@ -1,5 +1,5 @@ #!/bin/bash -./run-ros-image.sh dt +./bin/run-ros-image.sh dt sleep 5 container_id=$(docker ps -aqf "name=tsdf-plusplus" | tr -d '\n') echo "Docker container $container_id"