NUbots / NUWebots

Environment, models, and communication for using the Webots simulation with NUbots
MIT License
7 stars 4 forks source link

Adds a dockerfile for webots with nuwebots and robocup environments #101

Open JesseWilliamson opened 1 year ago

JesseWilliamson commented 1 year ago

Requirements:

  1. Host must be using X window server
  2. host must be configured to allow local connections on the host machine. To do this, run xhost +local:root. To undo this run xhost -local:root.
  3. For GPU acceleration the host computer must be using a NVIDIA graphics card and have nvidia-container-toolkit installed. nvidia-container-toolkit is available as an Ubuntu package and is on the AUR. Webots recommends using nvidia-docker2 instead, but as far as I can tell this is deprecated.

Notes:

  1. The links on lines 27 and 60 reference files in this PR. For testing replace replace main with williamson/webots-docker.
  2. Using docker for gui applications seems to have some fairly unpredictable problems. If the benefits of this docker image are ease-of-use and standardisation, these problems probably limit its usefulness significantly.
  3. Most of this is from the cyberbotics webots-docker repo

Running on host network:

  1. Build the image. There are arguments for building with different webots or ubuntu versions, but the defaults should be fine for nubots / robocup.
  2. Run with docker run --gpus=all -it -e DISPLAY --env TEAM_NAME=nubots -v /tmp/.X11-unix:/tmp/.X11-unix:rw --network host WebotsImageName. You can add webots pathToWorldFile to run a world file directly, or leave as-is to open a bash shell.

--gpus=all enables gpu acceleration, and TEAM_NAME is for the hlvs_robocup game.json file. If you aren't running on the host network you can use --env ROBOT_HOSTS to add comma separated addresses to the hlvs whitelist.

You should be able to connect with localhost address as if webots was running normally outside a container.

ysims commented 1 year ago

@JesseWilliamson could you have a look at addressing Kip's comments. Just run ./b format for the formatting comments.