From 009f60d2921074a733b65fc290886a6c4f7be299 Mon Sep 17 00:00:00 2001 From: Adeeb Abbas Date: Tue, 4 Jul 2023 10:16:03 -0400 Subject: [PATCH] fixes to eric's cr --- Dockerfile | 88 ++++++++++++++++++++-------------------------- README.md | 6 +++- docker-compose.yml | 4 +-- 3 files changed, 45 insertions(+), 53 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b128292..f1719517 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,65 +1,58 @@ # Dockerfile for drake-ros ARG ARCH -FROM ${ARCH}ros:humble-ros-base-jammy +FROM ${ARCH}/ros:humble # Set shell for running commands SHELL ["/bin/bash", "-c"] -# Install ROS2 packages -RUN apt-get update && apt-get install -y --no-install-recommends \ - ros-humble-desktop=0.10.0-1* \ - && rm -rf /var/lib/apt/lists/* - -# Update and upgrade the system +# Update the system and install necessary dependencies RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install -y tzdata - -# Install necessary dependencies for the script -RUN apt-get install -y wget unzip curl software-properties-common lsb-release python3-pip - -# Install Bazelisk using npm as it's straightforward this way -RUN apt-get install -y npm -RUN npm install -g @bazel/bazelisk - -# Run Bazelisk to install Bazel -RUN bazelisk + apt-get install -y wget unzip curl software-properties-common lsb-release python3-pip && \ + apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools -y && \ + apt-get install -y tzdata && \ + rm -rf /var/lib/apt/lists/* -# Install some useful tools for development -RUN apt-get update --fix-missing && \ - apt-get install -y git \ - nano \ - vim \ - libeigen3-dev \ - tmux \ - zip +# Bazel Installer only needed for arm64 systems +RUN install_bazel() { \ + wget "https://github.com/bazelbuild/bazel/releases/download/6.2.0/bazel-6.2.0-linux-$1" && \ + chmod 755 bazel-6.2.0-linux-$1 && \ + mv bazel-6.2.0-linux-$1 /usr/bin/bazel; \ +} -RUN apt-get -y dist-upgrade +# Install Bazel for arm64 systems since install_prereqs.sh doesn't for non x86_64 systems +RUN if [ "$ARCH" = "arm64" ] ; then \ + install_bazel "arm64" \ + ; fi + +# Argument to support building Drake from source (only strictly necessary for ARM64 users) +ARG BUILD_DRAKE_FROM_SOURCE=false -ARG BUILD_DRAKE_FROM_SOURCE=false -RUN if [ "$BUILD_DRAKE_FROM_SOURCE" = "true" ] ; then \ +# Install Drake from source or download pre-built binary accordingly +RUN if [ "$BUILD_DRAKE_FROM_SOURCE" = "true" ]; then \ # Install build dependencies for Drake \ + apt-get update && \ apt-get install -y build-essential cmake && \ - # Clone Drake source code \ git clone https://github.com/RobotLocomotion/drake.git && \ yes | bash drake/setup/ubuntu/install_prereqs.sh && \ mkdir drake-build && \ cd drake-build && \ # Build Drake from source \ - cmake -DCMAKE_INSTALL_PREFIX=$HOME/drake ../drake && make -j$(nproc) \ - ; \ - else \ - # Download and install Drake dependencies \ - wget -q -O /tmp/drake-setup.zip https://github.com/RobotLocomotion/drake/archive/refs/heads/master.zip && \ - unzip -q /tmp/drake-setup.zip -d /tmp && \ - yes | bash /tmp/drake-master/setup/ubuntu/install_prereqs.sh && \ - rm -rf /tmp/drake-setup.zip /tmp/drake-master && \ - # Download and install pre-built Drake binary for Ubuntu \ - wget https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-jammy.tar.gz && \ - tar -xzf drake-latest-jammy.tar.gz --strip-components=1 -C /opt && \ - rm drake-latest-jammy.tar.gz ; \ - fi + cmake -DCMAKE_INSTALL_PREFIX=/opt/drake ../drake && make -j$(nproc) && \ + make install \ + ; else \ + # Update and add necessary keys and sources for Drake installation + apt-get update && apt-get install --no-install-recommends \ + ca-certificates gnupg lsb-release wget && \ + wget -qO- https://drake-apt.csail.mit.edu/drake.asc | gpg --dearmor - \ + | tee /etc/apt/trusted.gpg.d/drake.gpg >/dev/null && \ + echo "deb [arch=amd64] https://drake-apt.csail.mit.edu/$(lsb_release -cs) $(lsb_release -cs) main" \ + | tee /etc/apt/sources.list.d/drake.list >/dev/null && \ + apt-get update && apt-get install -y --no-install-recommends drake-dev && \ + # Add Drake to the path + echo 'export PATH="/opt/drake/bin${PATH:+:${PATH}}"' >> /etc/bash.bashrc && \ + echo 'export PYTHONPATH="/opt/drake/lib/python'$(python3 -c 'import sys; print("{0}.{1}".format(*sys.version_info))')'/site-packages${PYTHONPATH:+:${PYTHONPATH}}"' >> /etc/bash.bashrc \ + ; fi # Clone Drake ROS repository RUN git clone https://github.com/RobotLocomotion/drake-ros.git @@ -73,12 +66,7 @@ RUN source /opt/ros/humble/setup.bash && \ cd drake_ros_ws/ && \ apt-get update --fix-missing && \ rosdep install -i --from-path src --rosdistro humble -y && \ - if [ "$BUILD_DRAKE_FROM_SOURCE" = "true" ] ; then \ - colcon build --symlink-install --cmake-args -DCMAKE_PREFIX_PATH=$HOME/drake \ - ; \ - else \ - colcon build --symlink-install ; \ - fi && \ + colcon build --symlink-install && \ colcon test --packages-up-to drake_ros_examples --event-handlers console_cohesion+ && \ colcon test-result --verbose diff --git a/README.md b/README.md index cd9587d5..95b956fa 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,13 @@ capability: - Ubuntu 22.04 + ROS 2 Humble (Recommended) - Ubuntu 20.04 + ROS 2 Rolling - - Architecture: x86_64 (amd64) + - Mac (only via [Docker](./docker-README.md)) + - Architecture: x86_64 (amd64), arm64 (only via [Docker](./docker-README.md)) - Bazel >= 5.0 +## Docker Support +For users preferring Docker, we offer support for Ubuntu and Macs via Docker. You can build and interact with visualization (`rviz2`) directly on the Docker platform, which is particularly useful for Mac users, including those with Apple Silicon architecture. Please refer to our detailed Docker instructions in the [Docker README](./docker-README.md). + ## Usable! But No Stability Commitment This code is prioritized for use within the TRI Dexterous Manipulation Group. diff --git a/docker-compose.yml b/docker-compose.yml index 3a3e3247..fae6548d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,6 @@ # docker-compose.yml -# +# +# NOTE - Only necessary for machines without an Nvidia GPU # This Docker Compose configuration sets up a Drake ROS integration environment # along with a noVNC server for remote access to the graphical interface of any # visualization tools used in the project. @@ -26,7 +27,6 @@ services: - x11 stdin_open: true tty: true - restart: on-failure novnc: container_name: novnc_container image: theasp/novnc:latest