diff --git a/.devcontainer/.install_utils/xauth_setup.sh b/.devcontainer/.install_utils/xauth_setup.sh index 5c84493..462ede7 100755 --- a/.devcontainer/.install_utils/xauth_setup.sh +++ b/.devcontainer/.install_utils/xauth_setup.sh @@ -5,4 +5,4 @@ XAUTH=$HOME/.Xauthority export XAUTH_LOC=$XAUTH xhost +local:$USER -touch $XAUTH +touch $XAUTH \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 280c08b..7c5db77 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,7 +21,7 @@ } }, "containerEnv": { - "DISPLAY": "${localEnv:DISPLAY}", + // "DISPLAY": "${localEnv:DISPLAY}", // this has to be set anyway once the devcontainer is opened "USER" : "${localEnv:USER}", "XAUTHORITY" : "/tmp/.Xauthority", "ROS_HOSTNAME" : "${localEnv:ROS_HOSTNAME}" diff --git a/.docker_utils/Dockerfile.jet b/.docker_utils/Dockerfile.jet index 881ef4c..832da3a 100644 --- a/.docker_utils/Dockerfile.jet +++ b/.docker_utils/Dockerfile.jet @@ -23,7 +23,11 @@ RUN catkin init && . /opt/ros/noetic/setup.bash && . /.install_utils/catkin_skip RUN . /.install_utils/cartographer_dep.sh USER root -RUN chown -R ${USER}:${USER} /home/${USER} +RUN chown -R ${USER}:${USER} /home/${USER}\ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER USER $USER ENTRYPOINT [ "bash", "/.install_utils/ros_entrypoint.sh" ] diff --git a/.docker_utils/Dockerfile.nuc b/.docker_utils/Dockerfile.nuc index 80401bc..3329e8f 100644 --- a/.docker_utils/Dockerfile.nuc +++ b/.docker_utils/Dockerfile.nuc @@ -23,8 +23,12 @@ RUN catkin init && . /opt/ros/noetic/setup.bash && . /.install_utils/catkin_skip RUN . /.install_utils/cartographer_dep.sh USER root -RUN chown -R ${USER}:${USER} /home/${USER} -RUN echo "${USER}:password" | chpasswd +RUN apt-get install -y x11-apps +RUN chown -R ${USER}:${USER} /home/${USER}\ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER USER $USER ENTRYPOINT [ "bash", "/.install_utils/ros_entrypoint.sh" ] diff --git a/.docker_utils/Dockerfile.sim_arm b/.docker_utils/Dockerfile.sim_arm index 954d67f..0d028b5 100644 --- a/.docker_utils/Dockerfile.sim_arm +++ b/.docker_utils/Dockerfile.sim_arm @@ -20,7 +20,11 @@ RUN mkdir -p /home/${USER}/catkin_ws/src RUN catkin init && . /opt/ros/noetic/setup.bash && . /.install_utils/catkin_skiplist_car.sh USER root -RUN chown -R ${USER}:${USER} /home/${USER} +RUN chown -R ${USER}:${USER} /home/${USER}\ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER USER $USER ENTRYPOINT [ "bash", "/.install_utils/ros_entrypoint.sh" ] diff --git a/.docker_utils/Dockerfile.sim_x86 b/.docker_utils/Dockerfile.sim_x86 index 42b25ac..1bbf3e2 100644 --- a/.docker_utils/Dockerfile.sim_x86 +++ b/.docker_utils/Dockerfile.sim_x86 @@ -19,9 +19,14 @@ RUN mkdir -p /home/${USER}/catkin_ws/src # initialize workspace and make sure no car packages are built RUN catkin init && . /opt/ros/noetic/setup.bash && . /.install_utils/catkin_skiplist_car.sh + USER root -RUN chown -R ${USER}:${USER} /home/${USER} -RUN echo "${USER}:password" | chpasswd +RUN apt-get install -y x11-apps +RUN chown -R ${USER}:${USER} /home/${USER}\ + && apt-get update \ + && apt-get install -y sudo \ + && echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \ + && chmod 0440 /etc/sudoers.d/$USER USER $USER ENTRYPOINT [ "bash", "/.install_utils/ros_entrypoint.sh" ] diff --git a/.docker_utils/README.md b/.docker_utils/README.md index a6c6513..f740d41 100644 --- a/.docker_utils/README.md +++ b/.docker_utils/README.md @@ -118,5 +118,9 @@ cd ./.docker_utils/sec_dock.sh ``` +## How to use GUI applications with the container +To have more information on how to use GUI applications with the container, please refer to the [GUI applications documentation](./README_GUI.md). + + --- [Go back to the main README](../README.md) diff --git a/.docker_utils/README_GUI.md b/.docker_utils/README_GUI.md new file mode 100644 index 0000000..d8bcdc1 --- /dev/null +++ b/.docker_utils/README_GUI.md @@ -0,0 +1,69 @@ +GUI applications in remote containers are a bit of a pain in the neck. Which makes GUI applications in remote VSCode devcontainers are even more of a pain. + +## GUI applications in remote Docker containers +If you want to launch a GUI application from a remote docker container, as for example during [mapping](https://git.ee.ethz.ch/pbl/research/f1tenth/race_stack/-/tree/master/base_system/pbl_f110_system?ref_type=heads#mapping), a couple of specific steps need to be taken. + +1. Connect to a car via SSH, enabling X forwarding with the `-X` flag: +```bash +ssh -X @ +``` + +2. Move to the ForzaETH race stack directory, and run the `xauth_setup.sh` script: +```bash +cd +source .devcontainer/.install_utils/xauth_setup.sh +``` +You should get at least the first line of the following output: +``` +non-network local connections being added to access control list +xhost: must be on local machine to add or remove hosts. +``` + +3. run the container with the appropriate script. If had you never run the container, running `main_dock.sh` should be fine, otherwise consider attaching to the already built container with `main_attach_dock.sh`. +```bash +.docker_utils/main_dock.sh +``` + +4. Enjoy a terminal with GUI forwarding! + + +## GUI applications in remote VSCode devcontainers +Due to the complicatedness of how a VSCode container is spun up, connecting to GUI applications requires a bit more involvement and a secondary SSH connection, to which we can relay the X forwarding. +Due to this reason, both a terminal **and** VSCode need to be opened in the car. + +1. Connect to a car via SSH, enabling X forwarding with the `-X` flag: +```bash +ssh -X @ +``` + +2. Move to the ForzaETH race stack directory, and run the `xauth_setup.sh` script: +```bash +cd +source .devcontainer/.install_utils/xauth_setup.sh +``` +You should get at least the first line of the following output: +``` +non-network local connections being added to access control list +xhost: must be on local machine to add or remove hosts. +``` + +3. Mmeorize the `DISPLAY` number in this SSH-connected terminal, afeter printing it to screen: +```bash +echo $DISPLAY +``` + +an example output could be +``` +localhost:10.0 +``` + + +4. open up the devcontainer on the car, first by opening up VSCode, then connecting to the car with the remote connection button to the bottom left (Connect to Host...), then open the race stack folder, and reopen in the devcontainer. + +5. In the devcontainer terminal where you want to use the GUI application, export now the `DISPLAY` variable number. For example: +```bash +export DISPLAY=:10.0 +``` + +6. Enjoy a terminal with GUI forwarding! +