Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/src/motion_tracking_controller
./scripts/colcon-config.sh Release
```
This script automatically clones and builds the required dependencies.
See [Basic Usage](#basic-usage) for usage instructions.

## Installation

### Dependencies
Expand Down Expand Up @@ -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.

78 changes: 78 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
47 changes: 47 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions docker/workspace-config.sh
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions scripts/colcon-config.sh
Original file line number Diff line number Diff line change
@@ -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