Skip to content

Add Docker Support for Traversability Estimation #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
60 changes: 60 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Use ROS Noetic official base image
FROM ros:noetic

# Set frontend to noninteractive in apt-get to suppress interactive dialogs
ENV DEBIAN_FRONTEND noninteractive

# Update and install necessary ROS packages and system dependencies
RUN apt-get update && apt-get install -y \
ros-noetic-gazebo-ros-pkgs \
ros-noetic-gazebo-ros-control \
ros-noetic-rviz \
ros-noetic-rqt-graph \
ros-noetic-grid-map \
ros-noetic-pcl-ros \
ros-noetic-eigen-conversions \
ros-noetic-tf-conversions \
libqt5widgets5 \
libqt5gui5 \
libqt5core5a \
qt5-default \
libeigen3-dev \
git \
cmake \
python3-catkin-tools \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Use bash for subsequent commands to ensure compatibility with bash-specific scripts
SHELL ["/bin/bash", "-c"]

# Set up the catkin workspace
RUN mkdir -p /catkin_ws/src && \
source /opt/ros/noetic/setup.bash && \
catkin init --workspace /catkin_ws && \
cd /catkin_ws/src

# Clone the necessary repositories including traversability_estimation
RUN cd /catkin_ws/src && \
git clone -b noetic https://github.com/leggedrobotics/kindr.git && \
git clone https://github.com/leggedrobotics/elevation_mapping.git && \
git clone https://github.com/anybotics/kindr_ros.git && \
git clone https://github.com/leggedrobotics/any_node.git && \
git clone https://github.com/ANYbotics/message_logger.git && \
git clone https://github.com/leggedrobotics/traversability_estimation.git

# Build the workspace
RUN source /opt/ros/noetic/setup.bash && \
cd /catkin_ws && \
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release && \
catkin build

# Automatically source the workspace setup file and ROS setup for every new bash session
RUN echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc && \
echo "source /catkin_ws/devel/setup.bash" >> ~/.bashrc

# Reset the frontend variable to avoid affecting applications that expect interactive frontend
ENV DEBIAN_FRONTEND dialog

CMD ["bash"]

35 changes: 35 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Docker Environment for Traversability Estimation

This directory contains the Docker setup for the Traversability Estimation project, which simplifies the setup process for development and testing by encapsulating all dependencies and configurations.

## Overview
The provided Docker configuration ensures a consistent development environment, avoiding the "works on my machine" problem, and allows for easy setup of complex dependencies involved in the project.

## Getting Started

### Prerequisites
- **Docker Engine**: Install Docker on your machine. See [Docker documentation](https://docs.docker.com/get-docker/) for installation instructions.
- **NVIDIA GPU Drivers**: If you are planning to use GPU capabilities, ensure that you have the appropriate NVIDIA drivers installed. Additionally, install the [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker) for Docker to utilize GPU acceleration.

### Building the Docker Image
Navigate to the directory containing the Dockerfile and run the following command to build the Docker image. This process can take several minutes as it installs all required dependencies and sets up the environment.

```bash
docker build -t ros-traversability .
```

### Running the Docker Container

Before you can run the Docker container with GUI support, you need to ensure the environment is configured correctly for displaying GUIs from Docker to your host machine. Start by making sure the `ros_traversability_estimation.sh` script is executable:

```bash
chmod +x ros_traversability_estimation.sh
```

Then, execute the container using the script, which handles the necessary configurations for GPU usage and X server permissions:

```bash
./ros_traversability_estimation.sh
```


17 changes: 17 additions & 0 deletions docker/ros_traversability_estimation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Allowing local connections to the X server
xhost +SI:localuser:root

# Command to run the Docker container with GPU and display settings
docker run --gpus all -it \
--env="DISPLAY=$DISPLAY" \
--env="XDG_RUNTIME_DIR=/tmp" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--volume="ros-tools:/root" \
ros-traversability \
/bin/bash

# Optionally, reset the X server settings
xhost -SI:localuser:root