Skip to content

Commit

Permalink
lbr-stack#149 Added Dockerfile and scripts for building and running t…
Browse files Browse the repository at this point in the history
…he container. Updated README.
  • Loading branch information
Nicolai-98 committed Jan 19, 2024
1 parent 0c47212 commit 52c8ee2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ vcs import src < src/repos.yaml
rosdep install --from-paths src --ignore-src -r -y
colcon build --symlink-install
```
Copy the Dockerfile and the container scripts to the lbr-stack directory. Build and start the container.
```shell
cp -r src/lbr_fri_ros2_stack/lbr_humble_docker/* .
chmod +x container_build.sh
sudo ./container_build.sh
```
Next, launch the simulation via
```shell
source install/setup.bash
Expand Down
26 changes: 26 additions & 0 deletions lbr_humble_docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ros:humble-ros-base-jammy

SHELL ["/bin/bash", "-c"]

RUN apt update -y
RUN apt install vim python-is-python3 python3-pip python3-colcon-common-extensions -y
RUN pip3 install scipy numpy
# create workspace and build package
# source workspace
RUN source /opt/ros/humble/setup.bash && echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc

# create workspace
RUN mkdir -p home/ros2_ws/src
WORKDIR /home/ros2_ws/

COPY ./src /home/ros2_ws/src
RUN rosdep install -i --from-path src --rosdistro humble -y

# "--symlink-install" allows the code in the locally mounted volume ./src to be adjusted without rebuilding
RUN source /opt/ros/humble/setup.bash && colcon build --symlink-install

# source overlay workspace
RUN source /home/ros2_ws/install/setup.bash && echo "source /home/ros2_ws/install/setup.bash" >> ~/.bashrc
CMD ["/bin/bash"]


19 changes: 19 additions & 0 deletions lbr_humble_docker/container_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# dont forget to chmod +x container_build.sh
xhost +

docker rm lbr_stack_container

docker build -t lbr_stack_container .

docker run -it \
--network host \
--ipc host \
--volume ./src:/home/ros2_ws/src \
--volume /tmp/.X11-unix:/tmp/.X11-unix \
--volume /dev/shm:/dev/shm \
--volume /dev:/dev --privileged \
--env DISPLAY \
--env QT_X11_NO_MITSHM=1 \
--name lbr_stack_container \
lbr_stack_container

2 changes: 2 additions & 0 deletions lbr_humble_docker/container_new_console.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dont forget to chmod +x container_new_console.sh
docker exec -it lbr_stack_container bash
5 changes: 5 additions & 0 deletions lbr_humble_docker/container_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# dont forget to chmod +x container_new_console.sh
xhost +

docker start lbr_stack_container -i

0 comments on commit 52c8ee2

Please sign in to comment.