5.7 Starting Webots Remotely (ssh)
Webots can be started on a remote computer, by using ssh (or a similar) command. However, Webots will work only if it can get a X11 connection to a X-server running locally (on the same computer). It is currently not possible to redirect Webots graphical output to another computer.
5.7.1 Using the ssh command
Here is the usual way to start from computer A, a Webots instance that will run on computer B:
$ ssh myname@computerB.org |
The last line starts Webots: the --mode=fast option enables the Fast simulation mode, which is available only with Webots PRO. The --mode=fast option makes the simulation run as fast as possible, without graphical rendering, which is fine because the graphical output won't be visible anyway from computer A. Options --stdout and --stderr are used to redirect Webots' output to the standard streams instead of Webots console, otherwise the output would not be visible on computer A.
At this point, Webots will start only if a X-server with proper authorizations is running on computer B. To ensure that this is the case, the simplest solution is to have an open login session on computer B, i.e., to have logged in using the login screen of computer B, and not having logged out. Unless configured differently, the ssh login and the screen login session must belong to the same user, otherwise the X-server will reject the connection. Note that the xhost + command can be used to grant access to the X-server to another user. For security reasons, the screen of the open session on computer B can be locked (e.g. with a screen-saver): this won't affect the running X-server.
5.7.2 Terminating the ssh session
A little problem with the above approach is that closing the ssh session will kill the remote jobs, including Webots. Fortunately it is easy to overcome this problem by starting the Webots as a background job and redirecting its output to a file:
$ ssh myname@computerB.org |
In this case the decision to terminate the job is usually made in the Supervisor code according to simulation specific criteria. The wb_supervisor_simulation_quit() function can be used to automatically terminate Webots when the job is over.