From b232fd2af4bcc326f84c1045a484f478852dda96 Mon Sep 17 00:00:00 2001 From: avcu Date: Fri, 26 Jul 2024 09:29:41 +0300 Subject: [PATCH 1/2] add docker and makefile --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ Makefile | 7 +++++++ 2 files changed, 46 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc82e69 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# Use the official ROS 2 humble base image +ARG ROS_DISTRO=humble +FROM ros:${ROS_DISTRO} as deps + +# Set the working directory +WORKDIR /root/ros2_ws + +SHELL ["/bin/bash", "-c"] + +RUN source /opt/ros/${ROS_DISTRO}/setup.bash +RUN apt-get update \ + && apt-get -y --quiet --no-install-recommends install \ + gcc \ + git \ + python3 \ + python3-pip + +COPY . /root/ros2_ws/src +RUN rosdep install --from-paths src --ignore-src -r -y + +WORKDIR /root/ros2_ws/src + +RUN pip3 install -r requirements.txt +# Run a default command, e.g., starting a bash shell +CMD ["bash"] + +WORKDIR /root/ros2_ws +FROM deps as builder +ARG CMAKE_BUILD_TYPE=Release + +RUN source /opt/ros/${ROS_DISTRO}/setup.bash +RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \ + colcon build + +# Source the ROS2 setup file +RUN echo "source /root/ros2_ws/install/setup.bash" >> ~/.bashrc + +# Run a default command, e.g., starting a bash shell +CMD ["bash"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ef827b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY : docker_build +docker_build: + docker build -t yasmin . + +.PHONY : docker_run +docker_run: + docker run -it --net=host --ipc=host --privileged --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --volume="${XAUTHORITY}:/root/.Xauthority" --entrypoint /bin/bash yasmin \ No newline at end of file From 6f76666db8efeddad088de6ecd0f6ac5f3c77b87 Mon Sep 17 00:00:00 2001 From: avcu Date: Fri, 26 Jul 2024 15:50:39 +0300 Subject: [PATCH 2/2] add introduction of docker and makefile usage to readme --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index 5a9ccc3..ba9b5e6 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,43 @@ $ cd ~/ros2_ws $ colcon build ``` +## Docker Setup + +If your operating system doesn't support ROS 2 humble, docker is a great alternative. + +First of all, you have to build the project and create an image like so: + +```shell +## Assuimg you are in the correct project directory +$ docker build -t yasmin . +``` +To use a shortcut, you may use the following command: + +```shell +## Assuimg you are in the correct project directory +$ make docker_build +``` + +After the image is created, copy and paste the following command to the terminal to run the image: + +```shell +## Assuimg you are in the correct project directory +$ docker run -it --net=host --ipc=host --privileged --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --volume="${XAUTHORITY}:/root/.Xauthority" --entrypoint /bin/bash yasmin +``` +To use a shortcut, you may use following command: + +```shell +$ make docker_run +``` +### Running the package at docker image + +If you are in the docker image , this project is already sourced and the demo script can be run as the following command; + +```shell +$ cd /root/ros2_ws/ +$ ros2 run yasmin_demos yasmin_demo.py +``` + ## Demos There are some examples, for both Python and C++, that can be found in [yasmin_demos](./yasmin_demos/).