Skip to content

Commit

Permalink
improve GUI applications documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Edoardo Ghignone committed May 3, 2024
1 parent 0f287bc commit f02d80e
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/.install_utils/xauth_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ XAUTH=$HOME/.Xauthority
export XAUTH_LOC=$XAUTH
xhost +local:$USER

touch $XAUTH
touch $XAUTH
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 5 additions & 1 deletion .docker_utils/Dockerfile.jet
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
8 changes: 6 additions & 2 deletions .docker_utils/Dockerfile.nuc
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
6 changes: 5 additions & 1 deletion .docker_utils/Dockerfile.sim_arm
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
9 changes: 7 additions & 2 deletions .docker_utils/Dockerfile.sim_x86
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
4 changes: 4 additions & 0 deletions .docker_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,9 @@ cd <race_stack folder>
./.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)
69 changes: 69 additions & 0 deletions .docker_utils/README_GUI.md
Original file line number Diff line number Diff line change
@@ -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 <username>@<car_ip>
```

2. Move to the ForzaETH race stack directory, and run the `xauth_setup.sh` script:
```bash
cd <racestack_directory>
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 <username>@<car_ip>
```

2. Move to the ForzaETH race stack directory, and run the `xauth_setup.sh` script:
```bash
cd <racestack_directory>
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!

0 comments on commit f02d80e

Please sign in to comment.