diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..340664a --- /dev/null +++ b/docker/Dockerfile @@ -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"] + diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..3c3c30b --- /dev/null +++ b/docker/README.md @@ -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 +``` + + diff --git a/docker/ros_traversability_estimation.sh b/docker/ros_traversability_estimation.sh new file mode 100755 index 0000000..ca20b1b --- /dev/null +++ b/docker/ros_traversability_estimation.sh @@ -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 +