When we put together the virtual machine for TM351, the data management and analysis course, we built a headless virtual machine that did not contain a graphical desktop, but instead ran a set of services that could be accessed within the machine at a machine level, and via a browser based UI at the user level.
Some applications, however, don’t expose an HTML based graphical user interface over http, instead they require access to a native windowing system.
One way round this is to run a system that can generate an HTML based UI within the VM and then expose that via a browser. For an example, see Accessing GUI Apps Via a Browser from a Container Using Guacamole.
Another approach is to expose an X11 window connection from the VM and connect to that on the host, displaying the windows natively on host as a result. See for example the Viewing Application UIs and Launching Applications from Shortcuts section of BYOA (Bring Your Own Application) – Running Containerised Applications on the Desktop.
The problem with the X11 approach is that is requires gubbins (technical term!) on the host to make it work. (I’d love to see a version of Kitematic extended not only to support docker-compose but also pre-packaged with something that could handle X11 connections…)
So another alternative is to create a virtual machine that does expose a desktop, and run the applications on that.
Here’s how I think the different approaches look:
As an example of the desktop VM idea, I’ve put together a build script for a virtual machine containing a Linux graphic desktop that runs the V-REP robot simulator. You can find it here: ou-robotics-vrep.
The script uses one Vagrant script to build the VM and another to launch it.
Along with the simulator, I packaged a Jupyter notebook server that can be used to create Python notebooks that can connect to the simulator and control the simulated robots running within it. These notebooks could be be viewed view a browser running on the virtual machine desktop, but instead I expose the notebook server so notebooks can be viewed in a browser on host.
The architecture thus looks something like this:
I’d never used Vagrant to build a Linux desktop box before, so here are a few things I learned about and observed along the way:
ubuntu-desktopnaively installs a whole range of applications as well. I wanted a minimal desktop that contained just the simulator application (though I also added in a terminal). For the minimal desktop,
apt-get install -y ubuntu-desktop --no-install-recommends;
- by default, Ubuntu requires a user to login (user: vagrant; password: vagrant). I wanted to have as simple an experience as possible so wanted to log the user in automatically. This could be achieved by adding the following to
[SeatDefaults] autologin-user=vagrant autologin-user-timeout=0 user-session=ubuntu greeter-session=unity-greeter
- a screensaver kept kicking in and kicking back to the login screen. I got round this by creating a desktop settings script (
#dock location gsettings set com.canonical.Unity.Launcher launcher-position Bottom #screensaver disable gsettings set org.gnome.desktop.screensaver lock-enabled false
and then pointing to that from a
desktop_settings.desktop file in the
/home/vagrant/.config/autostart/ directory (I set execute permissions set on the script and the
[Desktop Entry] Name=Apply Gnome Settings Exec=/opt/set-gnome-settings.sh Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Type=Application
- because the point of the VM is largely to run the simulator, I thought I should autostart the simulator. This can be done with another
.desktopfile in the autostart directory:
[Desktop Entry] Name=V-REP Simulator Exec=/opt/V-REP_PRO_EDU_V3_4_0_Linux/vrep.sh Type=Application X-GNOME-Autostart-enabled=true
- the Jupyter notebook server is started as a service and reuses the installation I used for the TM351 VM;
- I thought I should also add a desktop shortcut to run the simulator, though I couldnlt find an icon to link to? Create an executable
run_vrep.desktopfile and place it on the desktop:
[Desktop Entry] Name=V-REP Simulator Comment=Run V-REP Simulator Exec=/opt/V-REP_PRO_EDU_V3_4_0_Linux/vrep.sh Icon= Terminal=false Type=Application
Her’s how it looks:
If you want to give it a try, comments on the build/install process would be much appreciated: ou-robotics-vrep.
I will also be posting a set of activities based on the RobotLab activities used in TM129 in the possibility that we start using V-REP on TM129. The activity notebooks will be posted in the repo and via the associated uncourse blog if you want to play along.
One issue I have noticed is that if I resize the VM window, V-REP crashes… I also can’t figure out how to open a V-REP scene file from script (issue) or how to connect using a VM hostname alias rather than IP address (issue).