From f7841ad3b65df2a724ad891440ae986a18ef4d61 Mon Sep 17 00:00:00 2001 From: Kunzhao Ren Date: Sat, 21 Feb 2026 22:16:02 -0600 Subject: [PATCH 1/2] Add Dockerfile and helper scripts to simplify installation and build --- .gitignore | 1 + README.md | 20 +++++++++- docker/Dockerfile | 78 ++++++++++++++++++++++++++++++++++++++ docker/docker-compose.yaml | 47 +++++++++++++++++++++++ docker/workspace-config.sh | 15 ++++++++ scripts/colcon-config.sh | 27 +++++++++++++ 6 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 docker/Dockerfile create mode 100644 docker/docker-compose.yaml create mode 100755 docker/workspace-config.sh create mode 100755 scripts/colcon-config.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/README.md b/README.md index 515e764..563e473 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,25 @@ for details on exporting models. This repo also serves as an example of how to implement a custom controller using the [legged_control2](https://qiayuanl.github.io/legged_control2_doc/) framework. +## Install and Build (docker) +The Dockerfile and helper scripts are provided to simplify installation and build. +Make sure [Docker](https://docs.docker.com/engine/install/ubuntu/) and the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) are installed first. +```bash +# Host +git clone https://github.com/HybridRobotics/motion_tracking_controller.git +cd motion_tracking_controller/docker +docker compose up -d --build +docker exec -it wbt_ws bash +``` + +```bash +# container +cd /wbt_ws +./scripts/colcon-config.sh Release +``` +This script automatically clones and builds the required dependencies. +See [Basic Usage](#basic-usage) for usage instructions. + ## Installation ### Dependencies @@ -140,4 +159,3 @@ Below is an overview of the code structure for this repository: - Includes launch files like `mujoco.launch.py` and `real.launch.py` for simulation and real robot execution. - **`config`** - Stores configuration files for standby controller and state estimation params. - diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..d37f16d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,78 @@ +# Ubuntu 24.04 image based on ROS Jazzy (supports both x86_64 and arm64) +FROM ros:jazzy-perception-noble + +ENV ROS_DISTRO=jazzy + +# Disable interactive prompts during apt install +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + # APT / certificates / repository management / GPG keys + # (apt-transport-https is usually unnecessary on Ubuntu 22.04) + apt-get install -y --no-install-recommends \ + ca-certificates gnupg lsb-release software-properties-common && \ + \ + # Networking and troubleshooting tools + apt-get install -y --no-install-recommends \ + iputils-ping iproute2 wget curl net-tools && \ + \ + # Build / debug / code management tools + apt-get install -y --no-install-recommends \ + build-essential cmake gdb git git-lfs vim python3-vcstool && \ + \ + # Common C++ math and utility libraries + apt-get install -y --no-install-recommends \ + libboost-all-dev libeigen3-dev libyaml-cpp-dev && \ + \ + # JSON processing / code formatting / miscellaneous utilities + apt-get install -y --no-install-recommends \ + jq clang-format unzip ncdu && \ + \ + # GUI support (kept since GUI is required; gnome-terminal is large but convenient) + apt-get install -y --no-install-recommends \ + dbus-x11 gnome-terminal && \ + \ + # Hardware / USB / joystick support + apt-get install -y --no-install-recommends \ + udev usbutils joystick && \ + \ + # Python toolchain (pip) + apt-get install -y --no-install-recommends \ + python3-pip && \ + \ + git lfs install + + + # ROS dependencies +RUN apt-get install -y --no-install-recommends \ + ros-jazzy-plotjuggler-ros ros-jazzy-pinocchio + + # Install additional dependencies + # unitree_sdk2 +RUN apt-get install -y --no-install-recommends \ + libspdlog-dev libfmt-dev && \ + \ + # unitree_ros2 + apt-get install -y --no-install-recommends \ + ros-jazzy-rmw-cyclonedds-cpp ros-jazzy-rosidl-generator-dds-idl && \ + \ + # unitree_mujoco + apt-get install -y --no-install-recommends \ + libglfw3-dev + + # Add apt source +RUN echo "deb [trusted=yes] https://github.com/qiayuanl/legged_buildfarm/raw/noble-jazzy-amd64/ ./" | sudo tee /etc/apt/sources.list.d/qiayuanl_legged_buildfarm.list && \ + echo "yaml https://github.com/qiayuanl/legged_buildfarm/raw/noble-jazzy-amd64/local.yaml jazzy" | sudo tee /etc/ros/rosdep/sources.list.d/1-qiayuanl_legged_buildfarm.list && \ + echo "deb [trusted=yes] https://github.com/qiayuanl/unitree_buildfarm/raw/noble-jazzy-amd64/ ./" | sudo tee /etc/apt/sources.list.d/qiayuanl_unitree_buildfarm.list && \ + echo "yaml https://github.com/qiayuanl/unitree_buildfarm/raw/noble-jazzy-amd64/local.yaml jazzy" | sudo tee /etc/ros/rosdep/sources.list.d/1-qiayuanl_unitree_buildfarm.list && \ + echo "deb [trusted=yes] https://github.com/qiayuanl/simulation_buildfarm/raw/noble-jazzy-amd64/ ./" | sudo tee /etc/apt/sources.list.d/qiayuanl_simulation_buildfarm.list && \ + echo "yaml https://github.com/qiayuanl/simulation_buildfarm/raw/noble-jazzy-amd64/local.yaml jazzy" | sudo tee /etc/ros/rosdep/sources.list.d/1-qiayuanl_simulation_buildfarm.list && \ + sudo apt-get update && \ + sudo apt-get install -y --no-install-recommends \ + ros-jazzy-legged-control-base ros-jazzy-mujoco-ros2-control ros-jazzy-unitree-description ros-jazzy-unitree-systems + +# Copy workspace setup script into the container +COPY workspace-config.sh /workspace-config.sh + +# Use workspace-config.sh as the container entrypoint +ENTRYPOINT ["/workspace-config.sh"] diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..ee13be5 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,47 @@ +name: wbt_ws + +services: + wbt_ws: + build: + context: . # Build context (current directory) + dockerfile: Dockerfile # Defaults to Dockerfile, can be omitted + image: wbt_ws:latest # Image name + container_name: wbt_ws + + privileged: true + security_opt: + - seccomp=unconfined + + # GPU support (modern Compose) + gpus: all + # runtime: nvidia # (for jetson) + + # Environment variables + environment: + - NVIDIA_VISIBLE_DEVICES=all + - NVIDIA_DRIVER_CAPABILITIES=all + - DISPLAY=${DISPLAY:-:0} + # Use a fixed path inside container + - XAUTHORITY=/root/.Xauthority + # - XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} + - QT_X11_NO_MITSHM=1 + - WORKSPACE=/wbt_ws + + # Volume mounts + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + # Mount host Xauthority file into container + - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority:rw + - /etc/localtime:/etc/localtime:ro + - /dev/input:/dev/input:rwm + - /run/udev:/run/udev:ro + - ../:/wbt_ws/src/motion_tracking_controller + + + # Network configuration + network_mode: host + ipc: host + + # Interactive mode (equivalent to -it) + stdin_open: true + tty: true \ No newline at end of file diff --git a/docker/workspace-config.sh b/docker/workspace-config.sh new file mode 100755 index 0000000..84e56c6 --- /dev/null +++ b/docker/workspace-config.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +############################################ +# Add /usr/local/lib to the default library search path +echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/local-lib.conf +ldconfig + +############################################ +# Set up / install GDB Eigen pretty printers +cp $WORKSPACE/scripts/.gdbinit /root +cp $WORKSPACE/scripts/.gdb_eigen /root + +cd $WORKSPACE + +exec bash diff --git a/scripts/colcon-config.sh b/scripts/colcon-config.sh new file mode 100755 index 0000000..0d6a9d6 --- /dev/null +++ b/scripts/colcon-config.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Default build type is Release +BUILD_TYPE="${1:-Release}" + +echo "Building with CMAKE_BUILD_TYPE=$BUILD_TYPE" + +# Get project root directory +PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/../../../ +echo "Project directory: $PROJECT_DIR" +mkdir -p $PROJECT_DIR/lib +mkdir -p $PROJECT_DIR/src + +# Clone repos +cd $PROJECT_DIR/src +git clone https://github.com/qiayuanl/unitree_bringup.git + +# Build +cd $PROJECT_DIR +rosdep install --from-paths src --ignore-src -r -y + +source /opt/ros/jazzy/setup.bash +colcon build --symlink-install \ + --packages-up-to unitree_bringup motion_tracking_controller \ + --cmake-args \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ No newline at end of file From 6645ce8909ceafef9a1307917e28de4e4dddb349 Mon Sep 17 00:00:00 2001 From: Kunzhao Ren Date: Sun, 22 Feb 2026 17:16:44 -0600 Subject: [PATCH 2/2] Update README to correct directory path for container setup --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 563e473..e7a2be8 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ docker exec -it wbt_ws bash ```bash # container -cd /wbt_ws +cd /wbt_ws/src/motion_tracking_controller ./scripts/colcon-config.sh Release ``` This script automatically clones and builds the required dependencies.