-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a dockerfile for webots with nuwebots and robocup environments #101
Open
JesseWilliamson
wants to merge
9
commits into
main
Choose a base branch
from
williamson/webots-docker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b48e0ce
Adds a dockerfile for webots with nuwebots and robocup environments
JesseWilliamson 2bb5411
Add basic utilities to dependencies install script
JesseWilliamson d9affbd
Replace CMD with entrypoint script
JesseWilliamson 5bae41f
Allow comma separated addresses in run command and add teams/ prefix
JesseWilliamson e3d47dc
Formatting, remove user, don't remove config script after running
JesseWilliamson 208b98d
Update Dockerfile
JesseWilliamson 53b700b
fix ant gamecontroller build, fix package installs
JesseWilliamson 3d75850
change hlvs_webots location and remove working directory change
JesseWilliamson 5a27f90
Copy scripts instead of downloading from repo, clean up user setup
JesseWilliamson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
ARG BASE_IMAGE=nvidia/cuda:11.8.0-base-ubuntu22.04 | ||
FROM ${BASE_IMAGE} AS downloader | ||
|
||
# Determine Webots version to be used and set default argument | ||
ARG WEBOTS_VERSION=R2023b | ||
ARG WEBOTS_PACKAGE_PREFIX= | ||
|
||
# Disable dpkg/gdebi interactive dialogs | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update | ||
RUN apt-get install --yes \ | ||
wget\ | ||
bzip2 | ||
|
||
RUN rm -rf /var/lib/apt/lists/ | ||
RUN wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2 | ||
RUN tar xjf webots-*.tar.bz2 | ||
RUN rm webots-*.tar.bz2 | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
# Disable dpkg/gdebi interactive dialogs | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install Webots runtime dependencies | ||
RUN apt-get update | ||
RUN apt-get install --yes \ | ||
wget \ | ||
xvfb \ | ||
locales | ||
RUN wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh | ||
RUN chmod +x linux_runtime_dependencies.sh | ||
RUN ./linux_runtime_dependencies.sh | ||
RUN rm ./linux_runtime_dependencies.sh | ||
|
||
# Webots complains if run by root | ||
RUN useradd webots | ||
ENV HOME=/home/webots | ||
WORKDIR ${HOME} | ||
|
||
# Install Webots | ||
COPY --from=downloader /webots /usr/local/webots/ | ||
ENV QTWEBENGINE_DISABLE_SANDBOX=1 | ||
ENV WEBOTS_HOME /usr/local/webots | ||
ysims marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ENV PATH /usr/local/webots:${PATH} | ||
|
||
# Enable OpenGL capabilities | ||
ENV NVIDIA_DRIVER_CAPABILITIES=graphics,compute,utility | ||
|
||
# Dependencies for building NUbots and Robocup code | ||
RUN apt-get update | ||
RUN apt-get install --yes \ | ||
ant \ | ||
cmake-curses-gui \ | ||
libprotobuf-dev \ | ||
protobuf-compiler \ | ||
libeigen3-dev \ | ||
libyaml-cpp-dev \ | ||
ninja-build \ | ||
clang-tidy \ | ||
python3-dev \ | ||
libjpeg9-dev \ | ||
git \ | ||
python3-pip \ | ||
vim \ | ||
nano | ||
|
||
RUN rm -rf /var/lib/apt/lists/ | ||
|
||
# Build the latest version of the RoboCup Humanoid TC fork of GameController | ||
RUN git clone https://github.com/RoboCup-Humanoid-TC/GameController ./GameController | ||
RUN ant -buildfile ./GameController/build.xml | ||
|
||
# Build the robocup controllers | ||
RUN git clone https://github.com/RoboCup-Humanoid-TC/hlvs_webots.git ./hlvs_webots | ||
RUN pip3 install -r ./hlvs_webots/controllers/referee/requirements.txt | ||
RUN make -j$(nproc) -C ./hlvs_webots | ||
|
||
# Set environment variables for GameController | ||
ENV GAME_CONTROLLER_HOME=./GameController JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 | ||
|
||
# Install the NUbots-developed environment | ||
RUN git clone https://github.com/NUbots/NUWebots ./NUWebots | ||
RUN pip3 install -r ./NUWebots/requirements.txt | ||
RUN ./NUWebots/b configure -- -DENABLE_CLANG_TIDY=OFF | ||
RUN ./NUWebots/b build | ||
|
||
COPY entrypoint.sh ./entrypoint.sh | ||
COPY webots-config.py ./webots-config.py | ||
RUN chmod +x entrypoint.sh | ||
|
||
RUN chown -R webots:webots /home/webots | ||
USER webots | ||
ENV USER=webots | ||
|
||
# Configure robocup game.json file based on environment variables | ||
ENTRYPOINT ["./entrypoint.sh"] | ||
CMD ["bash", "-i"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
python3 webots-config.py /home/webots/hlvs_webots/controllers/referee/game.json | ||
# Run the command given by CMD or docker run parameter, replacing current process | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import json | ||
import os | ||
import sys | ||
|
||
TEAM_NAME = os.environ.get("TEAM_NAME") | ||
ROBOT_HOSTS = os.environ.get("ROBOT_HOSTS") | ||
|
||
filename = sys.argv[1] | ||
|
||
with open(filename, "r") as f: | ||
game_config = json.load(f) | ||
|
||
if TEAM_NAME: | ||
game_config["red"]["config"] = "teams/" + TEAM_NAME + ".json" | ||
if ROBOT_HOSTS: | ||
game_config["red"]["hosts"] += ROBOT_HOSTS.split(",") | ||
|
||
with open(filename, "w") as f: | ||
json.dump(game_config, f, indent=2) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.