Skip to content

Commit 744f4e6

Browse files
committed
update docker container to add nvidia stuff
1 parent fe6a696 commit 744f4e6

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

Dockerfile_1

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ RUN curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyri
4646
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
4747
RUN echo " CURL DONE"
4848

49-
RUN sudo apt-get update
50-
RUN sudo apt-get install -y gz-harmonic
49+
RUN apt-get update
50+
RUN apt-get install -y gz-harmonic
5151
RUN echo "Ignition Installed"
52+
RUN apt-get update
53+
RUN apt-get upgrade -y
5254

5355
# install
5456
# Adapt your desired python version here
@@ -94,7 +96,7 @@ RUN pipx install numpy
9496
# Set up auto-source of workspace for ros user
9597
ARG WORKSPACE=docker_navigation
9698
WORKDIR /home/ros/${WORKSPACE}
97-
99+
RUN sudo usermod -a -G render,avahi,video ${USERNAME}
98100
RUN echo "source /opt/ros/${DISTRO}/setup.bash" >> ~/.bashrc
99101

100102
RUN echo "if [ -f ~/${WORKSPACE}/install/setup.bash ]; then source ~/${WORKSPACE}/install/setup.bash; fi" >> /home/ros/.bashrc

README.md

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1-
# docker_navigation
2-
it is a repo cointain a set of robots and their urdf model to be simulated on ignition gazebo
1+
# Dockerized Gazebo Harmonic Simulator
2+
## introduction
3+
This repository contains a docker compose structure to simulate robots in Gazebo Sim Harmonic supported by ROS2 jazzy on ubuntu 24.04.
4+
The Repository purpose is to provide an easy set up to allow robotic software developer to test their own controller in simulation.
5+
## prerequisite
6+
7+
Docker Engine: follow the docker engine installation [here](https://docs.docker.com/engine/install/ubuntu/) and then enable the docker usage as non-root user as specified [here](https://docs.docker.com/engine/install/linux-postinstall/)
8+
9+
Install Nvidia Driver: TODO
10+
11+
Nvidia-Container-Toolkit: follow the nvidia-container-toolkit following [this](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
12+
13+
## Build
14+
15+
``` bash compose_build.bash ```
16+
17+
## Start Compose
18+
19+
``` docker compose up -d ```
20+
21+
``` docker compose exec ros2_shell bash ```
22+
23+
## NVIDIA stuff test
24+
25+
To test the correct isntallation of the nvidia support you have to start the container and call
26+
27+
``` nvidia-smi```

compose.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,30 @@ services:
2323
- HISTFILE=/home/ros/.bash_history
2424
- HISTFILESIZE=10000
2525
- RCUTILS_COLORIZED_OUTPUT=1
26+
- GZ_VERSION=harmonic
27+
- NVIDIA_VISIBLE_DEVICES=all
28+
- NVIDIA_DRIVER_CAPABILITIES=all,graphics,display,video,utility,compute
29+
- GZ_VERSION=harmonic
30+
- IGN_VERSION=harmonic
31+
- IGNITION_VERSION=harmonic
32+
# Add these OpenGL related variables
33+
- __GL_SYNC_TO_VBLANK=0
34+
- __GL_SYNC_DISPLAY_DEVICE=${DISPLAY}
35+
- MESA_GL_VERSION_OVERRIDE=3.3
2636
privileged: true # Fixed spelling and removed duplicate
2737
volumes:
2838
- /tmp/.X11-unix:/tmp/.X11-unix:rw
2939
# - /tmp/.docker.xauth:/tmp/.docker.xauth:rw
3040
- ~/.bash_history:/home/ros/.bash_history
3141
- /home/punk-opc/Documents/docker_navigation:/home/ros/docker_simulation_ws
3242
- /dev/input:/dev/input
43+
- /dev/dri:/dev/dri
44+
- /dev/nvidia0:/dev/nvidia0
45+
- /dev/nvidiactl:/dev/nvidiactl
46+
- /dev/nvidia-modeset:/dev/nvidia-modeset
47+
48+
49+
3350

3451
# Command to source ROS2 environment and start shell
3552
command: >
@@ -40,6 +57,17 @@ services:
4057
"
4158
devices:
4259
- /dev/dri:/dev/dri
60+
- /dev/nvidia0:/dev/nvidia0
61+
- /dev/nvidiactl:/dev/nvidiactl
62+
- /dev/nvidia-modeset:/dev/nvidia-modeset
63+
runtime: nvidia
64+
deploy:
65+
resources:
66+
reservations:
67+
devices:
68+
- driver: nvidia
69+
count: all
70+
capabilities: [gpu]
4371
# ros2_joy:
4472
# build:
4573
# dockerfile: Dockerfile_1

0 commit comments

Comments
 (0)