SITL without graphical window

Hello,

I’m trying to run an ArduCopter SITL instance on a Linux-based server. I’ve been able to do this quite reliably and smoothly using X11 forwarding over SSH (the usual mode which I connect to the server), but I would like to be able to run this as a systemd service in the background.

However, I can’t figure out how to get the SITL sim to start without the graphical window. The best lead so far is Maverick’s APSITL backend, which does this apparently well – but seems rather hackish.

Is there a flag I can pass to the sim_vehicle.py to start without any graphical windows? --no-mavproxy doesn’t seem to do the trick.

Thanks!

What do you mean by graphical windows and what line are you running to boot the sim?

Without “–console” and “–map” arguments, it should start in headless mode.
You can also directly run the simulation binary.
This and this might help you.

1 Like

The command I’m running is

python3 Tools/autotest/sim_vehicle.py -v ArduCopter -f quad

optionally with the --no-mavproxy or --no-rebuilt arguments as well.

However, with this (and no X11 forwarding), the sim fails to launch:

[rebuild (success) output removed for brevity]
BUILD SUMMARY
Build directory: /home/misha/ardupilot/ardu-upstream/build/sitl
Target          Text (B)  Data (B)  BSS (B)  Total Flash Used (B)  Free Flash (B)
---------------------------------------------------------------------------------
bin/arducopter   3567701    174157   197576               3741858  Not Applicable

Build commands will be stored in build/sitl/compile_commands.json
'build' finished successfully (1.309s)
SIM_VEHICLE: Using defaults from (Tools/autotest/default_params/copter.parm)
SIM_VEHICLE: Run ArduCopter
SIM_VEHICLE: "/home/misha/ardupilot/ardu-upstream/Tools/autotest/run_in_terminal_window.sh" "ArduCopter" "/home/misha/ardupilot/ardu-upstream/build/sitl/bin/arducopter" "-S" "--model" "+" "--speedup" "1" "--slave" "0" "--defaults" "Tools/autotest/default_params/copter.parm" "-I0"
SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501"
RiTW: Starting ArduCopter : /home/misha/ardupilot/ardu-upstream/build/sitl/bin/arducopter -S --model + --speedup 1 --slave 0 --defaults Tools/autotest/default_params/copter.parm -I0
xterm: Xt error: Can't open display: localhost:10.0
Connect tcp:127.0.0.1:5760 source_system=255
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
[Errno 111] Connection refused sleeping
Failed to connect to tcp:127.0.0.1:5760 : [Errno 111] Connection refused
SIM_VEHICLE: MAVProxy exited
SIM_VEHICLE: Killing tasks
misha@minisrv ~/ardupilot/ardu-upstream (master)
>>> 

When X11 forwarding is enabled, instead of the xterm error, I get a window that displays console output presumably from the sim, the mavproxy connection does not time out, and all is well.

@Mustafa_Gokce , your solution seems to work quite well – thank you!!

1 Like