diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..175f24f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +ARG ROS_DISTRO=noetic + +FROM osrf/ros:${ROS_DISTRO}-desktop-full as deps + +ENV DEBIAN_FRONTEND=noninteractive +ENV ROS_PYTHON_VERSION=3 + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update && apt-get install -y \ + python3-rosdep \ + python3-catkin-tools \ + build-essential \ + libyaml-cpp-dev \ + ros-${ROS_DISTRO}-ompl \ + ros-${ROS_DISTRO}-grid-map-core \ + ros-${ROS_DISTRO}-grid-map-ros \ + ros-${ROS_DISTRO}-grid-map-msgs \ + ros-${ROS_DISTRO}-geometry-msgs \ + ros-${ROS_DISTRO}-visualization-msgs \ + ros-${ROS_DISTRO}-std-msgs \ + ros-${ROS_DISTRO}-dynamic-reconfigure \ + ros-${ROS_DISTRO}-tf \ + ros-${ROS_DISTRO}-tf2 \ + ros-${ROS_DISTRO}-tf2-ros \ + ros-${ROS_DISTRO}-urdf \ + ros-${ROS_DISTRO}-eigen-conversions \ + ros-${ROS_DISTRO}-rviz \ + ros-${ROS_DISTRO}-fake-localization \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /root/catkin_ws + +RUN mkdir -p src +COPY . /root/catkin_ws/src/se2_navigation + +FROM deps as builder + +ARG CMAKE_BUILD_TYPE=Release + +WORKDIR /root/catkin_ws + +RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \ + catkin config --extend /opt/ros/${ROS_DISTRO} --cmake-args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} && \ + catkin build + +RUN echo "source /root/catkin_ws/devel/setup.bash" >> /root/.bashrc + +CMD ["bash"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4ae1deb --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +.PHONY: docker-build docker-shell compose-build compose-up compose-down + +IMAGE ?= se2_navigation:noetic +SERVICE ?= car_demo + +docker-build: + docker build --build-arg ROS_DISTRO=noetic -t $(IMAGE) . + +docker-shell: + xhost +local:root || true + docker run --rm -it \ + -e DISPLAY=$$DISPLAY \ + -e QT_X11_NO_MITSHM=1 \ + -e ROS_MASTER_URI=http://127.0.0.1:11311 \ + -e ROS_IP=127.0.0.1 \ + --network host \ + -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ + --device /dev/dri \ + --shm-size 1g \ + $(IMAGE) \ + bash + +compose-build: + docker compose build $(SERVICE) + +compose-up: + xhost +local:root || true + docker compose up $(SERVICE) + +compose-down: + docker compose down diff --git a/README.md b/README.md index 2a299af..516c84b 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,16 @@ Refer to [car_demo](car_demo/README.md) for the details. Refer to [approach_pose_planner](se2_approach_pose_planning/approach_pose_planner_ros/README.md) if you are interested in approach pose planning. +## Docker Setup + +The repository includes a ROS Noetic `Dockerfile`, a `docker-compose.yml`, and Makefile shortcuts for desktop testing. + +- **Prerequisites**: Docker with the Compose plugin, GPU drivers/X11 if you plan to visualize RViz or Gazebo. Allow the container to access your X server with `xhost +` before launching. +- **Build image**: `make docker-build` (sets up the catkin workspace inside the container). +- **Open interactive shell**: `make docker-shell` enters the image with ROS sourced; you can run commands such as `roslaunch car_demo demo_autonomous.launch`. +- **Run the demo via Compose**: `make compose-up` builds (if needed) and launches the `car_demo` service defined in `docker-compose.yml`. +- **Stop containers**: `make compose-down` tears down the Compose stack and keeps the catkin workspace volume. + ## Usage Run the main demo with: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ccfbcf0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: "3.9" + +services: + car_demo: + build: + context: . + dockerfile: Dockerfile + args: + ROS_DISTRO: noetic + command: ["/bin/bash", "-lc", "source /root/catkin_ws/devel/setup.bash && roslaunch car_demo demo_autonomous.launch"] + environment: + - DISPLAY=${DISPLAY} + - QT_X11_NO_MITSHM=1 + - ROS_MASTER_URI=http://127.0.0.1:11311 + - ROS_IP=127.0.0.1 + - NVIDIA_VISIBLE_DEVICES=all + - NVIDIA_DRIVER_CAPABILITIES=all + network_mode: host + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - car_demo_workspace:/root/catkin_ws + devices: + - /dev/dri:/dev/dri + shm_size: 1g + restart: "no" + +volumes: + car_demo_workspace: