PX4 / jMAVSim

Simple multirotor simulator with MAVLink protocol support
BSD 3-Clause "New" or "Revised" License
82 stars 207 forks source link

jMAVSim: Added the option to run without the GUI #105

Closed katzfey closed 4 years ago

katzfey commented 4 years ago

Added a new command line argument to allow the user to run without the GUI. The new argument is -no-gui. This allows use of the simulator in environments that do not have a GUI, like a headless Docker.

Fixes #59.

julianoes commented 4 years ago

Thanks for the PR @katzfey! I'll try this out and review it.

julianoes commented 4 years ago

@katzfey please rebase on top of master, then CI should pass.

julianoes commented 4 years ago

Unfortunately the problem is that the j3d libs still require a X11 DISPLAY variable as was also mentioned in https://github.com/PX4/jMAVSim/issues/59#issuecomment-421120951.

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.ExceptionInInitializerError
    at javax.media.j3d.GroupRetained.<init>(GroupRetained.java:155)
    at javax.media.j3d.TransformGroupRetained.<init>(TransformGroupRetained.java:116)
    at javax.media.j3d.TransformGroup.createRetained(TransformGroup.java:115)
    at javax.media.j3d.SceneGraphObject.<init>(SceneGraphObject.java:114)
    at javax.media.j3d.Node.<init>(Node.java:172)
    at javax.media.j3d.Group.<init>(Group.java:551)
    at javax.media.j3d.TransformGroup.<init>(TransformGroup.java:87)
    at me.drton.jmavsim.KinematicObject.<init>(KinematicObject.java:42)
    at me.drton.jmavsim.DynamicObject.<init>(DynamicObject.java:24)
    at me.drton.jmavsim.vehicle.AbstractVehicle.<init>(AbstractVehicle.java:26)
    at me.drton.jmavsim.vehicle.AbstractMulticopter.<init>(AbstractMulticopter.java:19)
    at me.drton.jmavsim.vehicle.Quadcopter.<init>(Quadcopter.java:33)
    at me.drton.jmavsim.Simulator.buildMulticopter(Simulator.java:431)
    at me.drton.jmavsim.Simulator.<init>(Simulator.java:312)
    at me.drton.jmavsim.Simulator.main(Simulator.java:930)
    ... 5 more
Caused by: java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:269)
    ... 20 more

I think the change is still worthwile but it doesn't allow it to be run in CI/docker just yet.

katzfey commented 4 years ago

Darn! Sorry about that. You would think that if I wanted it to run in a headless Docker that I would have tested it in a headless Docker. I'll keep working on it.

JonasVautherin commented 4 years ago

What's the status on that? @katzfey does it run in docker now? I'll be happy to test it when it works for you!

katzfey commented 4 years ago

Well, I am testing in a Docker now and can reproduce the issue. I have made changes and it gets farther but still not quite there.

katzfey commented 4 years ago

I have it all working now on headless docker. Need to clean up some commit comments and then I can submit a new PR.

katzfey commented 4 years ago

@JonasVautherin Please feel free to test the work now. It seems to be working for me on a headless system with the -no-gui option. Branch is run_without_gui in my repo https://github.com/katzfey/jMAVSim

JonasVautherin commented 4 years ago

Branch is run_without_gui in my repo

Which is this PR, right? :sweat_smile:

julianoes commented 4 years ago

Awesome, thanks @katzfey!