From 883e0a00e278bdcf745546617fbcbca6f3a65409 Mon Sep 17 00:00:00 2001 From: Ray Zhang Date: Wed, 26 Oct 2022 18:20:50 -0400 Subject: [PATCH 1/5] Update Dockerfile --- cvo_gpu/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cvo_gpu/Dockerfile b/cvo_gpu/Dockerfile index 7e96c11..4fa9205 100644 --- a/cvo_gpu/Dockerfile +++ b/cvo_gpu/Dockerfile @@ -99,7 +99,7 @@ RUN cd /home/root/tmp && export CC=gcc-9 && export CXX=g++-9 \ && wget https://github.com/ceres-solver/ceres-solver/archive/refs/tags/2.1.0.tar.gz \ && export CC=gcc-9 && export CXX=g++-9 \ && tar zxf 2.1.0.tar.gz && mkdir ceres-bin && cd ceres-bin && cmake ../ceres-solver-2.1.0 \ -&& make -j && make install +&& make -j4 && make install ########### Install yaml-cpp RUN cd /home/root/tmp \ @@ -122,7 +122,7 @@ COPY boost.h /home/root/tmp/pcl-1.9.1/io/include/pcl/io/boost.h RUN cd /home/root/tmp/pcl-1.9.1/build \ && export CC=gcc-9 && export CXX=g++-9 \ -&& cmake .. && make -j8 && make install +&& cmake .. && make -j4 && make install RUN rm -rf /home/root/tmp/* @@ -141,7 +141,7 @@ ENV NVIDIA_VISIBLE_DEVICES \ ENV NVIDIA_DRIVER_CAPABILITIES \ ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics -# emacs tools +# emacs tools. Feel free to comment them out of you don't use emacs and llvm tools RUN apt update && \ add-apt-repository ppa:kelleyk/emacs && \ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ From 61ca004778203aa7441fdfb5eaf7861e51a32931 Mon Sep 17 00:00:00 2001 From: Ray Zhang Date: Wed, 2 Nov 2022 13:54:32 -0400 Subject: [PATCH 2/5] Update README.md --- cvo_gpu/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvo_gpu/README.md b/cvo_gpu/README.md index 8c70075..3117970 100644 --- a/cvo_gpu/README.md +++ b/cvo_gpu/README.md @@ -1,5 +1,5 @@ ## CVO -This docker file sets up the environment for CVO. It aims at installing all non-conflicting related softwares, and encourages download-and-run. We use Nvidia-Docker 2 +This docker file sets up the environment for CVO. It aims at installing all non-conflicting related softwares, and encourages download-and-run. Please install [Nvidia-Docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) ### How to build the docker image from `Dockerfile`? From 125469a36d31db3b4df5b7d629032806c989ce5a Mon Sep 17 00:00:00 2001 From: Ray Zhang Date: Wed, 2 Nov 2022 15:11:56 -0400 Subject: [PATCH 3/5] Update run_cuda_docker.bash --- cvo_gpu/run_cuda_docker.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cvo_gpu/run_cuda_docker.bash b/cvo_gpu/run_cuda_docker.bash index e1014a5..1eb72f0 100644 --- a/cvo_gpu/run_cuda_docker.bash +++ b/cvo_gpu/run_cuda_docker.bash @@ -1,6 +1,9 @@ container_name=$1 xhost +local: + +## Note: a) update -v "/home/$USER/code/docker_home/cvo/:/home/$USER/" for specifying your home directory inside docker +## b) update "/run/media/$USER/Samsung_T5/:/home/$USER/media/Samsung_T5" to your own external hard drive if any docker run -it --net=host --gpus all -e DISPLAY=${DISPLAY} \ -e QT_GRAPHICSSYSTEM=native \ -e NVIDIA_DRIVER_CAPABILITIES=all \ From a6e64659812ce346cff082b0ab73d2c69670e60e Mon Sep 17 00:00:00 2001 From: tccoin Date: Sat, 28 Jan 2023 02:36:53 -0500 Subject: [PATCH 4/5] add container for elastic_fusion --- elastic_fusion/.zshrc | 54 ++++ elastic_fusion/Dockerfile | 143 ++++++++++ elastic_fusion/build.sh | 1 + elastic_fusion/docker-compose.yml | 55 ++++ elastic_fusion/guid.patch | 423 ++++++++++++++++++++++++++++++ 5 files changed, 676 insertions(+) create mode 100644 elastic_fusion/.zshrc create mode 100644 elastic_fusion/Dockerfile create mode 100644 elastic_fusion/build.sh create mode 100755 elastic_fusion/docker-compose.yml create mode 100644 elastic_fusion/guid.patch diff --git a/elastic_fusion/.zshrc b/elastic_fusion/.zshrc new file mode 100644 index 0000000..a8a3d52 --- /dev/null +++ b/elastic_fusion/.zshrc @@ -0,0 +1,54 @@ +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block, everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH + +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# Set name of the theme to load --- if set to "random", it will +# load a random theme each time oh-my-zsh is loaded, in which case, +# to know which specific one was loaded, run: echo $RANDOM_THEME +# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes + +ZSH_THEME="powerlevel10k/powerlevel10k" + +# Which plugins would you like to load? +# Standard plugins can be found in ~/.oh-my-zsh/plugins/* +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. + +plugins=(git cp z cp extract history colorize command-not-found sudo zsh-autosuggestions zsh-syntax-highlighting) + +POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(user anaconda dir) +POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(nvm pyenv time) +POWERLEVEL9K_DISABLE_GITSTATUS=true + +source $ZSH/oh-my-zsh.sh + +# User configuration + +export SSH_KEY_PATH="~/.ssh/rsa_id" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. + + +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh +source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +source /opt/ros/noetic/setup.zsh +source ~/ws/cassie_ros/catkin_ws/devel/setup.zsh +source /opt/intel/bin/compilervars.sh intel64 \ No newline at end of file diff --git a/elastic_fusion/Dockerfile b/elastic_fusion/Dockerfile new file mode 100644 index 0000000..d91037a --- /dev/null +++ b/elastic_fusion/Dockerfile @@ -0,0 +1,143 @@ +FROM nvidia/cudagl:11.4.2-devel-ubuntu20.04 +LABEL org.opencontainers.image.authors="junzhewu@umich.edu" +LABEL description="Container for Elastic Bridge (ROS wrapper for ElasticFusion)" +LABEL version="0.1" + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y locales \ + && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ + && dpkg-reconfigure --frontend=noninteractive locales \ + && update-locale LANG=en_US.UTF-8 + +# nvidia-container-runtime +ENV NVIDIA_VISIBLE_DEVICES \ + ${NVIDIA_VISIBLE_DEVICES:-all} +ENV NVIDIA_DRIVER_CAPABILITIES \ + ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,compute,utility,display + + +# install libraries and tools +RUN apt-get update && apt-get install -y --no-install-recommends \ + sudo \ + dialog \ + apt-utils \ + git \ + mercurial \ + pkg-config \ + mesa-utils \ + libxau-dev \ + libxdmcp-dev \ + libxcb1-dev \ + libxext-dev \ + libx11-dev \ + git \ + tmux \ + wget \ + curl \ + cmake \ + vim \ + build-essential \ + unzip \ + autoconf \ + autogen \ + automake \ + libtool \ + mlocate \ + zlib1g-dev \ + libopenblas-dev \ + libflann-dev \ + libpcl-dev \ + libboost-all-dev \ + libsuitesparse-dev \ + libtbb-dev \ + libusb-1.0-0-dev \ + libgtest-dev \ + pkg-config \ + cmake-curses-gui \ + gdb \ + clang \ + emacs \ + libpcap-dev \ + gnupg2 \ + x11-xserver-utils \ + lsb-release \ + tilix \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# install ROS +RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' + +RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 + +RUN apt-get update + +RUN apt-get install -y --no-install-recommends ros-noetic-desktop-full + +# install zsh +RUN git clone https://github.com/tccoin/easy-linux.git /root/easy-linux \ + && cd /root/easy-linux \ + && bash zsh.sh \ + && touch /root/.z \ + && rm -r /root/easy-linux + +# install gitstatus +# https://github.com/romkatv/gitstatus/releases/tag/v1.3.1 +RUN mkdir -p /root/.cache/gitstatus \ + && wget https://github.com/romkatv/gitstatus/releases/download/v1.5.1/gitstatusd-linux-x86_64.tar.gz -O - \ + | tar -zx -C /root/.cache/gitstatus/ + +# install slam libraries + +RUN sudo apt install libpcl-dev + +RUN mkdir /root/elstic_ws/src -p +WORKDIR /root/elstic_ws/src + +# Download libraries +RUN git clone https://github.com/RMonica/elastic_bridge.git \ + && git clone https://github.com/RMonica/init_fake_opengl_context.git \ + && git clone https://github.com/mp3guy/ElasticFusion.git elastic_bridge/deps/ElasticFusion + +# Compile ElasticFusion Core module +## Update cmake +RUN sudo apt-get install -y --no-install-recommends software-properties-common \ + && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - \ + && sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' \ + && sudo apt-get update \ + && sudo apt-get install -y --no-install-recommends cmake + +## Compile dependencies +RUN cd /root/elstic_ws/src/elastic_bridge/deps/ElasticFusion/ \ + && git submodule update --init \ + && cd third-party/Pangolin/ \ + && mkdir build \ + && cd build \ + && cmake .. -DEIGEN_INCLUDE_DIR=/root/elstic_ws/src/elastic_bridge/deps/ElasticFusion/third-party/Eigen/ -DBUILD_PANGOLIN_PYTHON=false \ + && make -j8 + + +RUN sudo apt-get install -y --no-install-recommends cmake-qt-gui git build-essential libusb-1.0-0-dev libudev-dev openjdk-11-jdk freeglut3-dev libglew-dev libsuitesparse-dev zlib1g-dev libjpeg-dev \ + && cd /root/elstic_ws/src/elastic_bridge/deps/ElasticFusion/third-party/OpenNI2/ \ + && make -j8 + +## Install CUDA +# RUN sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cuda + +## Compile elastic fusion +RUN cd /root/elstic_ws/src/elastic_bridge/deps/ElasticFusion/ \ + && mkdir build \ + && cd build \ + && cmake .. \ + && make -j8 + +# Compile the package +RUN cd /root/elstic_ws \ + && . /opt/ros/noetic/setup.sh \ + && catkin_make + +# Apply the GUID patch +# COPY guid.patch /root/elstic_ws/src/elastic_bridge/patches/guid.patch +# RUN cd /root/elstic_ws/src/elastic_bridge/deps/ElasticFusion \ +# && patch -p1 -i ../../patches/guid.patch \ No newline at end of file diff --git a/elastic_fusion/build.sh b/elastic_fusion/build.sh new file mode 100644 index 0000000..3e3a78d --- /dev/null +++ b/elastic_fusion/build.sh @@ -0,0 +1 @@ +docker build --tag umrobotics/elastic_fusion . \ No newline at end of file diff --git a/elastic_fusion/docker-compose.yml b/elastic_fusion/docker-compose.yml new file mode 100755 index 0000000..2fc151a --- /dev/null +++ b/elastic_fusion/docker-compose.yml @@ -0,0 +1,55 @@ +version: '3.9' + +networks: + ros: + driver: bridge + +services: + ros-master: + image: umrobotics/elastic_fusion:latest + entrypoint: /bin/zsh + command: -c "source /opt/ros/melodic/setup.zsh && stdbuf -o L roscore" + networks: + - ros + restart: always + container_name: ros-master + + elastic_fusion: + image: umrobotics/elastic_fusion:latest + # depends_on: + # - ros-master + container_name: slam + networks: + - ros + environment: + - "DISPLAY=${DISPLAY}" + - "QT_GRAPHICSSYSTEM=native" + - "NVIDIA_DRIVER_CAPABILITIES=all" + - "TERM=xterm-256color" + - "XAUTHORITY" + working_dir: "/root/ws/" + privileged: true + devices: + - /dev/nvidia0 + - /dev/nvidia-modeset + - /dev/nvidiactl + - /dev/nvidia-uvm + - /dev/nvidia-uvm-tools + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - .zshrc:/root/.zshrc:rw + - .zsh_history:/root/.zsh_history:rw + # - /home/$USER/Projects/curly/:/root/ws/ + # - /run/media/$USER/CTOS-Storage/rosbag/:/root/ws/rosbag/ + ulimits: + nofile: + soft: 65536 + hard: 65536 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [ gpu ] + entrypoint: /bin/zsh diff --git a/elastic_fusion/guid.patch b/elastic_fusion/guid.patch new file mode 100644 index 0000000..7b0392d --- /dev/null +++ b/elastic_fusion/guid.patch @@ -0,0 +1,423 @@ +diff --git a/Core/ElasticFusion.h b/Core/ElasticFusion.h +index 7a2b0fc..6876281 100644 +--- a/Core/ElasticFusion.h ++++ b/Core/ElasticFusion.h +@@ -37,6 +37,10 @@ + #include + #include + ++#ifndef ELASTIC_BRIDGE_EXTENSION_GUID ++ #define ELASTIC_BRIDGE_EXTENSION_GUID 1 ++#endif ++ + class ElasticFusion + { + public: +diff --git a/Core/GlobalModel.cpp b/Core/GlobalModel.cpp +index 92e0b21..4144809 100644 +--- a/Core/GlobalModel.cpp ++++ b/Core/GlobalModel.cpp +@@ -23,6 +23,8 @@ const int GlobalModel::MAX_VERTICES = GlobalModel::TEXTURE_DIMENSION * GlobalMod + const int GlobalModel::NODE_TEXTURE_DIMENSION = 16384; + const int GlobalModel::MAX_NODES = GlobalModel::NODE_TEXTURE_DIMENSION / 16; //16 floats per node + ++#define DISPOSED_GUIDS_SIZE (1024) ++ + GlobalModel::GlobalModel() + : target(0), + renderSource(1), +@@ -38,7 +40,8 @@ GlobalModel::GlobalModel() + updateMapVertsConfs(TEXTURE_DIMENSION, TEXTURE_DIMENSION, GL_RGBA32F, GL_LUMINANCE, GL_FLOAT), + updateMapColorsTime(TEXTURE_DIMENSION, TEXTURE_DIMENSION, GL_RGBA32F, GL_LUMINANCE, GL_FLOAT), + updateMapNormsRadii(TEXTURE_DIMENSION, TEXTURE_DIMENSION, GL_RGBA32F, GL_LUMINANCE, GL_FLOAT), +- deformationNodes(NODE_TEXTURE_DIMENSION, 1, GL_LUMINANCE32F_ARB, GL_LUMINANCE, GL_FLOAT) ++ deformationNodes(NODE_TEXTURE_DIMENSION, 1, GL_LUMINANCE32F_ARB, GL_LUMINANCE, GL_FLOAT), ++ disposed_guid_store(DISPOSED_GUIDS_SIZE, DISPOSED_GUIDS_SIZE, GL_LUMINANCE32F_ARB, GL_LUMINANCE, GL_UNSIGNED_INT) + { + vbos = new std::pair[2]; + +@@ -177,6 +180,22 @@ GlobalModel::GlobalModel() + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + + initProgram->Unbind(); ++ ++ glGenBuffers(1, &atomicGuidBuffer); ++ glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicGuidBuffer); ++ glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint) * 2, NULL, GL_DYNAMIC_DRAW); ++ { ++ const GLuint U_ONE = 1; ++ const GLuint U_ZERO = 0; ++ glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(GLuint), &U_ONE); ++ glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), sizeof(GLuint), &U_ZERO); ++ } ++ glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0); ++ ++ glBindTexture(GL_TEXTURE_2D,disposed_guid_store.texture->tid); ++ std::vector image(DISPOSED_GUIDS_SIZE * DISPOSED_GUIDS_SIZE,5); // initialize to some value (5) ++ glTexImage2D(GL_TEXTURE_2D,0,GL_R32F,DISPOSED_GUIDS_SIZE,DISPOSED_GUIDS_SIZE,0,GL_RED,GL_FLOAT,image.data()); ++ glBindTexture(GL_TEXTURE_2D,0); + } + + GlobalModel::~GlobalModel() +@@ -191,6 +210,8 @@ GlobalModel::~GlobalModel() + + glDeleteBuffers(1, &uvo); + ++ glDeleteBuffers(1, &atomicGuidBuffer); ++ + glDeleteTransformFeedbacks(1, &newUnstableFid); + glDeleteBuffers(1, &newUnstableVbo); + +@@ -204,6 +225,8 @@ void GlobalModel::initialise(const FeedbackBuffer & rawFeedback, + + glBindBuffer(GL_ARRAY_BUFFER, rawFeedback.vbo); + ++ SetGuidSystem(initProgram); ++ + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, Vertex::SIZE, 0); + +@@ -242,6 +265,8 @@ void GlobalModel::initialise(const FeedbackBuffer & rawFeedback, + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + ++ UnsetGuidSystem(initProgram); ++ + initProgram->Unbind(); + + glFinish(); +@@ -306,6 +331,29 @@ const std::pair & GlobalModel::model() + return vbos[target]; + } + ++void GlobalModel::SetGuidSystem(std::shared_ptr program) ++{ ++ CheckGlDieOnError(); ++ ++ glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 1, atomicGuidBuffer); ++ ++ glBindImageTexture(7,disposed_guid_store.texture->tid,0,GL_FALSE,0,GL_READ_WRITE,GL_R32F); ++ program->setUniform(Uniform(std::string("disposed_guid_store_size"), int(DISPOSED_GUIDS_SIZE))); ++ program->setUniform(Uniform(std::string("disposed_guid_store"), int(7))); ++ ++ CheckGlDieOnError(); ++} ++ ++void GlobalModel::UnsetGuidSystem(std::shared_ptr /*program*/) ++{ ++ CheckGlDieOnError(); ++ ++ glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 1, 0); ++ glBindImageTexture(7,0,0,GL_FALSE,0,GL_READ_WRITE,GL_R32F); ++ ++ CheckGlDieOnError(); ++} ++ + void GlobalModel::fuse(const Eigen::Matrix4f & pose, + const int & time, + GPUTexture * rgb, +@@ -354,6 +402,8 @@ void GlobalModel::fuse(const Eigen::Matrix4f & pose, + dataProgram->setUniform(Uniform("pose", pose)); + dataProgram->setUniform(Uniform("maxDepth", depthCutoff)); + ++ SetGuidSystem(dataProgram); ++ + glEnableVertexAttribArray(0); + glBindBuffer(GL_ARRAY_BUFFER, uvo); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); +@@ -399,6 +449,8 @@ void GlobalModel::fuse(const Eigen::Matrix4f & pose, + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + ++ UnsetGuidSystem(dataProgram); ++ + dataProgram->Unbind(); + + glPopAttrib(); +@@ -518,6 +570,8 @@ void GlobalModel::clean(const Eigen::Matrix4f & pose, + unstableProgram->setUniform(Uniform("cols", (float)Resolution::getInstance().cols())); + unstableProgram->setUniform(Uniform("rows", (float)Resolution::getInstance().rows())); + ++ SetGuidSystem(unstableProgram); ++ + glBindBuffer(GL_ARRAY_BUFFER, vbos[target].first); + + glEnableVertexAttribArray(0); +@@ -589,6 +643,8 @@ void GlobalModel::clean(const Eigen::Matrix4f & pose, + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); + ++ UnsetGuidSystem(unstableProgram); ++ + unstableProgram->Unbind(); + + std::swap(target, renderSource); +@@ -602,6 +658,34 @@ unsigned int GlobalModel::lastCount() + return count; + } + ++unsigned int GlobalModel::maxGuid() ++{ ++ GLuint current_guid = -1; ++ glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicGuidBuffer); ++ glGetBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(GLuint), ¤t_guid); ++ glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0); ++ return current_guid; ++} ++ ++unsigned int GlobalModel::disposedGuids() ++{ ++ GLuint disposed_guids = -1; ++ glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicGuidBuffer); ++ glGetBufferSubData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), sizeof(GLuint), &disposed_guids); ++ glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0); ++ return disposed_guids; ++} ++ ++std::vector GlobalModel::downloadDisposedGuids(const bool resize) ++{ ++ glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT | GL_ATOMIC_COUNTER_BARRIER_BIT); ++ std::vector disposed_tex(DISPOSED_GUIDS_SIZE * DISPOSED_GUIDS_SIZE,5); ++ disposed_guid_store.texture->Download(disposed_tex.data(),GL_LUMINANCE,GL_FLOAT); ++ if (resize) ++ disposed_tex.resize(disposedGuids(),-1); ++ return disposed_tex; ++} ++ + Eigen::Vector4f * GlobalModel::downloadMap() + { + glFinish(); +diff --git a/Core/GlobalModel.h b/Core/GlobalModel.h +index 5c029e8..913ecc1 100644 +--- a/Core/GlobalModel.h ++++ b/Core/GlobalModel.h +@@ -87,6 +87,10 @@ class GlobalModel + + EFUSION_API unsigned int lastCount(); + ++ unsigned int maxGuid(); ++ unsigned int disposedGuids(); ++ std::vector downloadDisposedGuids(const bool resize); ++ + Eigen::Vector4f * downloadMap(); + + private: +@@ -94,6 +98,9 @@ class GlobalModel + std::pair * vbos; + int target, renderSource; + ++ void SetGuidSystem(std::shared_ptr program); ++ void UnsetGuidSystem(std::shared_ptr program); ++ + const int bufferSize; + + GLuint countQuery; +@@ -121,8 +128,12 @@ class GlobalModel + //16 floats stored column-major yo' + GPUTexture deformationNodes; + ++ GPUTexture disposed_guid_store; ++ + GLuint newUnstableVbo, newUnstableFid; + ++ GLuint atomicGuidBuffer; ++ + pangolin::GlFramebuffer frameBuffer; + GLuint uvo; + int uvSize; +diff --git a/Core/IndexMap.cpp b/Core/IndexMap.cpp +index 8889d6e..7f7960a 100644 +--- a/Core/IndexMap.cpp ++++ b/Core/IndexMap.cpp +@@ -76,6 +76,13 @@ IndexMap::IndexMap() + GL_UNSIGNED_SHORT, + false, + true), ++ guidTexture(Resolution::getInstance().width(), ++ Resolution::getInstance().height(), ++ GL_LUMINANCE32UI_EXT, ++ GL_LUMINANCE_INTEGER_EXT, ++ GL_UNSIGNED_INT, ++ false, ++ true), + oldRenderBuffer(Resolution::getInstance().width(), Resolution::getInstance().height()), + oldImageTexture(Resolution::getInstance().width(), + Resolution::getInstance().height(), +@@ -125,6 +132,7 @@ IndexMap::IndexMap() + combinedFrameBuffer.AttachColour(*vertexTexture.texture); + combinedFrameBuffer.AttachColour(*normalTexture.texture); + combinedFrameBuffer.AttachColour(*timeTexture.texture); ++ combinedFrameBuffer.AttachColour(*guidTexture.texture); + combinedFrameBuffer.AttachDepth(combinedRenderBuffer); + + oldFrameBuffer.AttachDepth(oldRenderBuffer); +@@ -132,6 +140,7 @@ IndexMap::IndexMap() + oldFrameBuffer.AttachColour(*oldVertexTexture.texture); + oldFrameBuffer.AttachColour(*oldNormalTexture.texture); + oldFrameBuffer.AttachColour(*oldTimeTexture.texture); ++ oldFrameBuffer.AttachColour(*guidTexture.texture); + + infoFrameBuffer.AttachColour(*colorInfoTexture.texture); + infoFrameBuffer.AttachColour(*vertexInfoTexture.texture); +diff --git a/Core/IndexMap.h b/Core/IndexMap.h +index 787ff68..191856d 100644 +--- a/Core/IndexMap.h ++++ b/Core/IndexMap.h +@@ -122,6 +122,11 @@ class IndexMap + return &timeTexture; + } + ++ GPUTexture * guidTex() ++ { ++ return &guidTexture; ++ } ++ + GPUTexture * oldImageTex() + { + return &oldImageTexture; +@@ -185,6 +190,7 @@ class IndexMap + GPUTexture vertexTexture; + GPUTexture normalTexture; + GPUTexture timeTexture; ++ GPUTexture guidTexture; + + pangolin::GlFramebuffer oldFrameBuffer; + pangolin::GlRenderBuffer oldRenderBuffer; +diff --git a/Core/Shaders/combo_splat.frag b/Core/Shaders/combo_splat.frag +index c39d4eb..bc1047e 100644 +--- a/Core/Shaders/combo_splat.frag ++++ b/Core/Shaders/combo_splat.frag +@@ -29,6 +29,7 @@ layout(location = 0) out vec4 image; + layout(location = 1) out vec4 vertex; + layout(location = 2) out vec4 normal; + layout(location = 3) out uint time; ++layout(location = 4) out uint guid; + + #include "color.glsl" + +@@ -54,6 +55,8 @@ void main() + vertex = vec4((gl_FragCoord.x - cam.x) * z * (1.f / cam.z), (gl_FragCoord.y - cam.y) * z * (1.f / cam.w), z, position.w); + + normal = normRad; ++ ++ guid = uint(colTime.y); + + time = uint(colTime.z); + +diff --git a/Core/Shaders/copy_unstable.geom b/Core/Shaders/copy_unstable.geom +index 7725768..541d4e1 100644 +--- a/Core/Shaders/copy_unstable.geom ++++ b/Core/Shaders/copy_unstable.geom +@@ -17,6 +17,8 @@ + */ + + #version 330 core ++#extension GL_ARB_shader_atomic_counters : enable ++#extension GL_ARB_shader_image_load_store : enable + + layout(points) in; + layout(points, max_vertices = 1) out; +@@ -30,6 +32,12 @@ out vec4 vPosition0; + out vec4 vColor0; + out vec4 vNormRad0; + ++layout(binding = 1, offset = 0) uniform atomic_uint max_guid; ++layout(binding = 1, offset = 4) uniform atomic_uint disposed_guid_count; ++ ++layout(r32ui) uniform uimage2D disposed_guid_store; ++uniform int disposed_guid_store_size; ++ + void main() + { + if(test[0] > 0) +@@ -40,4 +48,18 @@ void main() + EmitVertex(); + EndPrimitive(); + } ++ else ++ { ++ uint guid = uint(vColor[0].y); ++ if (vColor[0].w != -1 && (guid != 0u)) ++ { ++ // point is being deleted, store the guid for later ++ uint slot = atomicCounterIncrement(disposed_guid_count); ++ if (slot >= uint(disposed_guid_store_size * disposed_guid_store_size)) // out of memory ++ atomicCounterDecrement(disposed_guid_count); ++ else ++ imageStore(disposed_guid_store, ++ ivec2(int(slot) % disposed_guid_store_size, int(slot) / disposed_guid_store_size), uvec4(guid)); ++ } ++ } + } +diff --git a/Core/Shaders/data.vert b/Core/Shaders/data.vert +index 8c48ed1..29de312 100644 +--- a/Core/Shaders/data.vert ++++ b/Core/Shaders/data.vert +@@ -17,6 +17,14 @@ + */ + + #version 330 core ++#extension GL_ARB_shader_atomic_counters : enable ++#extension GL_ARB_shader_image_load_store : enable ++ ++layout(binding = 1, offset = 0) uniform atomic_uint max_guid; ++layout(binding = 1, offset = 4) uniform atomic_uint disposed_guid_count; ++ ++layout(r32ui) uniform uimage2D disposed_guid_store; ++uniform int disposed_guid_store_size; + + layout (location = 0) in vec2 texcoord; + +@@ -168,6 +176,22 @@ void main() + //New unstable vertex + updateId = 2; + vColor.w = -2; ++ ++ uint maybe_disposed_guid_slot = atomicCounterDecrement(disposed_guid_count); ++ uint guid; ++ if (maybe_disposed_guid_slot > (1u << 30u)) // underflow: container was empty ++ { ++ guid = atomicCounterIncrement(max_guid); ++ atomicCounterIncrement(disposed_guid_count); ++ } ++ else ++ { ++ uint slot = maybe_disposed_guid_slot; ++ guid = imageLoad(disposed_guid_store, ++ ivec2(int(slot) % disposed_guid_store_size, int(slot) / disposed_guid_store_size)).x; ++ } ++ ++ vColor.y = float(guid); + } + } + +diff --git a/Core/Shaders/init_unstable.vert b/Core/Shaders/init_unstable.vert +index fd2ed65..3a8878f 100644 +--- a/Core/Shaders/init_unstable.vert ++++ b/Core/Shaders/init_unstable.vert +@@ -17,6 +17,7 @@ + */ + + #version 330 core ++#extension GL_ARB_shader_atomic_counters : enable + + layout (location = 0) in vec4 vPosition; + layout (location = 1) in vec4 vColor; +@@ -26,11 +27,16 @@ out vec4 vPosition0; + out vec4 vColor0; + out vec4 vNormRad0; + ++layout(binding = 1, offset = 0) uniform atomic_uint max_guid; ++layout(binding = 1, offset = 4) uniform atomic_uint disposed_guid_count; ++ + void main() + { ++ uint guid = atomicCounterIncrement(max_guid); ++ + vPosition0 = vPosition; + vColor0 = vColor; +- vColor0.y = 0; //Unused ++ vColor0.y = float(guid); // GUID + vColor0.z = 1; //This sets the vertex's initialisation time + vNormRad0 = vNormRad; + } From 8f250fa861ce6337a5efbef7411559d828e86362 Mon Sep 17 00:00:00 2001 From: zjaxxon Date: Thu, 10 Aug 2023 00:01:42 -0400 Subject: [PATCH 5/5] Reduced PCL layer size --- cvo_gpu/Dockerfile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/cvo_gpu/Dockerfile b/cvo_gpu/Dockerfile index 4fa9205..62709ad 100644 --- a/cvo_gpu/Dockerfile +++ b/cvo_gpu/Dockerfile @@ -121,8 +121,7 @@ RUN cd /home/root/tmp/ && export CC=gcc-9 && export CXX=g++-9 \ COPY boost.h /home/root/tmp/pcl-1.9.1/io/include/pcl/io/boost.h RUN cd /home/root/tmp/pcl-1.9.1/build \ -&& export CC=gcc-9 && export CXX=g++-9 \ -&& cmake .. && make -j4 && make install +&& cmake -DCMAKE_BUILD_TYPE=Release .. && make -j4 && make -j4 install RUN rm -rf /home/root/tmp/* @@ -142,14 +141,14 @@ ENV NVIDIA_DRIVER_CAPABILITIES \ ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics # emacs tools. Feel free to comment them out of you don't use emacs and llvm tools -RUN apt update && \ - add-apt-repository ppa:kelleyk/emacs && \ - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ - wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ - add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' && \ - apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && apt update &&\ - apt install -y emacs27 python3-pip clang-10 clangd-10 llvm-10 lldb-10 llvm-10-dev libllvm10 llvm-10-runtime bear mlocate global cmake && \ - apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# RUN apt update && \ +# add-apt-repository ppa:kelleyk/emacs && \ +# wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ +# wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ +# add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' && \ +# apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && apt update &&\ +# apt install -y emacs27 python3-pip clang-10 clangd-10 llvm-10 lldb-10 llvm-10-dev libllvm10 llvm-10-runtime bear mlocate global cmake && \ +# apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* RUN updatedb # USER original_user