Git Product home page Git Product logo

jmavsim's Introduction

jMAVSim

PROJECT DISCONTINUED

Feel free to contact me and I can transfer this project or put link to some good active fork.

Gitter

Simple multirotor simulator with MAVLink protocol support

Installation

Requirements:

Java3D and JOGL/JOAL jars, including native libs for Linux (i586/64bit), Windows (i586/64bit) and Mac OS (universal) already included in this repository, no need to install it.

Clone repository and initialize submodules:

git clone https://github.com/DrTon/jMAVSim
git submodule init
git submodule update

Compile:

cd jMAVSim
ant

Run:

java -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator

Some shells (e.g. tcsh) will try to expand *, so use \* instead:

java -cp lib/\*:out/production/jmavsim.jar me.drton.jmavsim.Simulator

On Windows use ; instead of : in -cp:

java -cp lib/*;out/production/jmavsim.jar me.drton.jmavsim.Simulator

Troubleshooting

Java 3D

jMAVSim uses java3d library for visualization. It was discontinued for long time, but now maintained again and uses JOGL backend. All necessary jars with java classes and native binaries (Linux/Mac OS/Windows) included in this repo, no need to install java3d manually. But need to make sure that java doesn't use any other deprecated version of java3d. For more info related to java3d see this article: https://gouessej.wordpress.com/2012/08/01/java-3d-est-de-retour-java-3d-is-back/

On Mac OS java may use deprecated version of java3d as extension, if you get following error:

JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
AWT not found
Exception in thread "main" java.lang.NoClassDefFoundError: apple/awt/CGraphicsDevice
	at javax.media.j3d.GraphicsConfigTemplate3D.<clinit>(GraphicsConfigTemplate3D.java:55)
...

Then add -Djava.ext.dirs= option to command line when starting:

java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator

Serial port

Serial port access is common problem. Make sure to hardcode correct port in Simulator.java:

serialMAVLinkPort.open("/dev/tty.usbmodem1", 230400, 8, 1, 0);

(Baudrate for USB ACM ports (that PX4 uses) has no effect, you can use any value)

Usually port is:

Mac OS: /dev/tty.usbmodem1
Linux: /dev/ttyACM0
Windows: COM15

On Linux you may also get Permission denied error, add your user to dialout group and relogin, or just run as root.

UDP

UDP port used to connect ground station, e.g. qgroundcontrol. jMAVSim in this case works as bridge between ground station and autopilot (behavior can be configured of course). Make sure that jMAVSim and ground station use the same ports. In qgroundcontrol (or another GCS) you also need to add target host in UDP port configuration (localhost:14555), so both ends will know to which port they should send UDP packets.

Developing

jMAVSim is not out-of-the-box simulator, but very flexible toolkit with a lot of ready to use blocks and designed to build custom simulation setups. All simulator configuration hardcoded in file src/me/drton/jmavsim/Simulator.java, this file should be edited before running simulator.

New vehicle types (e.g. non standard multirotors configurations) can be added very easily. (But for fixed wing you will need some more aerodynamics knowledge). See files under src/me/drton/jmavsim/vehicle/ as examples.

Camera can be placed on any point, including gimabal, that can be controlled by autopilot, see CameraGimbal2D class and usage example (commented) in Simulator.java.

Sensors data can be replayed from real flight log, use LogPlayerSensors calss for this.

Custom vehicle visual models in .obj format can be used, edit this line:

AbstractMulticopter vehicle = new Quadcopter(world, "models/3dr_arducopter_quad_x.obj", "x", 0.33 / 2, 4.0, 0.05, 0.005, gc);

Custom MAVLink protocols can be used, no any recompilation needed, just specify XML file instead of custom.xml here:

MAVLinkSchema schema = new MAVLinkSchema("mavlink/message_definitions/common.xml");

It's convinient to start simulator from IDE. Free and powerful "IntelliJ IDEA" IDE recommended, project files for it are already included, just open project file jMAVSim.ipr and right-click -> Run Simulator.

jmavsim's People

Contributors

drton avatar gitter-badger avatar julianoes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmavsim's Issues

no main manifest attribute, in out/production/jmavsim.jar

latest master:

01:31:43 {master} ~/git/drton/jMAVSim$ ant clean
Buildfile: /home/markw/git/drton/jMAVSim/build.xml

clean:
   [delete] Deleting directory /home/markw/git/drton/jMAVSim/out/production

BUILD SUCCESSFUL
Total time: 1 second
04:58:52 {master} ~/git/drton/jMAVSim$ ant
Buildfile: /home/markw/git/drton/jMAVSim/build.xml

make_dirs:
    [mkdir] Created dir: /home/markw/git/drton/jMAVSim/out/production/jMAVSim

compile:
    [javac] Compiling 58 source files to /home/markw/git/drton/jMAVSim/out/production/jMAVSim

jmavsim:
      [jar] Building jar: /home/markw/git/drton/jMAVSim/out/production/jmavsim.jar

all:

BUILD SUCCESSFUL
Total time: 4 seconds
04:58:58 {master} ~/git/drton/jMAVSim$ java -jar out/production/jmavsim.jar
no main manifest attribute, in out/production/jmavsim.jar

05:02:56 {master} ~/git/drton/jMAVSim$ git log
commit e224a4fa4ac77cae2f0c793bfeea48c0de938dea
Author: Anton Babushkin <[email protected]>
Date:   Mon Jun 29 22:34:55 2015 +0200

    Rotor: time constant scale fixed, documentation added


error [unknown] warning! time is negative!

I've a px4 working with JmavSim.
I've understood that I can connect using udp port ( 14556 ) only before this error

ERROR [Unknown] WARNING! TIME IS NEGATIVE! 16203872 vs 16203873

(each time, the time value changes)

When I get this error the comunication with my virtual drone stops.

What is this error ?
How can I solve ?

it happens every time after few minutes or seconds

Opengraphscene Port?

Hi Anton, is there anyreason why you chose to use Java3d? It seems like it is on it's way out, I was considering trying to convert your source code to Opengraphscene/C++. Would you be availible for questions while I was attempting this undertaking? Thanks

modeling Rotor latency

These are impulse response models constructed from log data collected using MatrixPilot firmware in an AeroQuad frame. 3S battery, 1000KV 2212 motors, 10x4.7 props, 680mm between motor centers.
The Pitch moment of inertia is a little higher than the Roll moment.

Impulse response model: A exp(-t/tau) sin(omega t)
Delay values in plot headers are the estimated command->response latency for thrust and rotation rate, respectively.

aeroquad_ratemode

This plot is for a HobbyKing microQuad with motor spacing of 220mm:
microquad_ratemode

Exception in thread "main" java.nio.BufferUnderflowException

Hi.
I'm trying to use your simulator, but I'm getting this error when I run mavros (rosrun mavros px4.launch). On mavros I get one heartbeat, and then mavros looses connection with the simulator.
Can you help me?

Exception in thread "main" java.nio.BufferUnderflowException
at me.drton.jmavlib.mavlink.MAVLinkMessage.(MAVLinkMessage.java:82)
at me.drton.jmavlib.mavlink.MAVLinkStream.read(MAVLinkStream.java:39)
at me.drton.jmavsim.UDPMavLinkPort.update(UDPMavLinkPort.java:66)
at me.drton.jmavsim.MAVLinkConnection.update(MAVLinkConnection.java:44)
at me.drton.jmavsim.World.update(World.java:33)
at me.drton.jmavsim.Simulator.run(Simulator.java:159)
at me.drton.jmavsim.Simulator.(Simulator.java:132)
at me.drton.jmavsim.Simulator.main(Simulator.java:168)

SYS_AUTOSTART

Hi,

Would you mind to instruct me how to configure SYS_AUTOSTART value for Pixhawk?
I've tried to Google around, I couldn't find any clear instructions.

Thanks in advance.

running JMAVSim in vmware fails

81 WARNING: setRealtimeSched failed (not run as root?)


| ___ \ \ \ / / / |
| |/ / \ V / / /| |
| __/ / \ / /
| |
| | / /^\ \ ___ |
_| / / |_/

px4 starting.

INFO [dataman] Unknown restart, data manager file 'rootfs/fs/microsd/dataman' size is 11405132 bytes
INFO [simulator] Waiting for initial data on UDP port 14560. Please start the flight simulator to proceed..
Buildfile: /home/itayguy/git/PX4Firmware/Tools/jMAVSim/build.xml

make_dirs:

compile:

create_run_jar:

copy_res:

BUILD SUCCESSFUL
Total time: 0 seconds
Options parsed, starting Sim.
Starting GUI...
3D [dev] 1.6.0-pre12-daily-experimental daily

com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x3e26d121, isOwner false, <7e758363, b619854>[count 0, qsz 0, owner ]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
com.jogamp.opengl.GLException: J3D-Renderer-1: createImpl ARB n/a but required, profile > GL2 requested (OpenGL >= 3.1). Requested: GLProfile[GL3bc/GL3bc.hw], current: 3.0 (Compat profile, compat[ES2], FBO, hardware) - 3.0 Mesa 17.2.8
at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:418)
at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:759)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:642)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at javax.media.j3d.JoglPipeline$QueryCanvas.doQuery(JoglPipeline.java:8615)
at javax.media.j3d.JoglPipeline$QueryCanvas.access$100(JoglPipeline.java:8566)
at javax.media.j3d.JoglPipeline.createQueryContext(JoglPipeline.java:6562)
at javax.media.j3d.Canvas3D.createQueryContext(Canvas3D.java:4609)
at javax.media.j3d.Canvas3D.createQueryContext(Canvas3D.java:3606)
at javax.media.j3d.Renderer.doWork(Renderer.java:461)
at javax.media.j3d.J3dThread.run(J3dThread.java:271)

DefaultRenderingErrorListener.errorOccurred:
CONTEXT_CREATION_ERROR: Renderer: Error creating Canvas3D graphics context for queryProperties()
graphicsDevice = X11GraphicsDevice[screen=0]
canvas = me.drton.jmavsim.Visualizer3D$CustomCanvas3D[canvas0,0,0,0x0,invalid]
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:58)
Caused by: java.lang.IllegalStateException: Canvas3D: Non-recoverable graphics configuration error
at javax.media.j3d.Canvas3D.queryProperties(Canvas3D.java:3595)
at me.drton.jmavsim.Visualizer3D.createEnvironment(Visualizer3D.java:214)
at me.drton.jmavsim.Visualizer3D.(Visualizer3D.java:175)
at me.drton.jmavsim.Simulator.(Simulator.java:157)
at me.drton.jmavsim.Simulator.main(Simulator.java:678)
... 5 more
X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 2/2, reusable (open, marked uncloseable): 0, pending (open in creation order): 2)
X11Util: Open X11 Display Connections: 2
X11Util: Open[0]: NamedX11Display[:0, 0x7f8eb00010b0, refCount 1, unCloseable false]
X11Util: Open[1]: NamedX11Display[:0, 0x7f8e94020c70, refCount 1, unCloseable false]
Options parsed, starting Sim.
Starting GUI...
3D [dev] 1.6.0-pre12-daily-experimental daily

com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x4ce470aa, isOwner false, <4da7bb0f, 4e58036c>[count 0, qsz 0, owner ]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:688)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
com.jogamp.opengl.GLException: J3D-Renderer-1: createImpl ARB n/a but required, profile > GL2 requested (OpenGL >= 3.1). Requested: GLProfile[GL3bc/GL3bc.hw], current: 3.0 (Compat profile, compat[ES2], FBO, hardware) - 3.0 Mesa 17.2.8
at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:418)
at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:759)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:642)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at javax.media.j3d.JoglPipeline$QueryCanvas.doQuery(JoglPipeline.java:8615)
at javax.media.j3d.JoglPipeline$QueryCanvas.access$100(JoglPipeline.java:8566)
at javax.media.j3d.JoglPipeline.createQueryContext(JoglPipeline.java:6562)
at javax.media.j3d.Canvas3D.createQueryContext(Canvas3D.java:4609)
at javax.media.j3d.Canvas3D.createQueryContext(Canvas3D.java:3606)
at javax.media.j3d.Renderer.doWork(Renderer.java:461)
at javax.media.j3d.J3dThread.run(J3dThread.java:271)

DefaultRenderingErrorListener.errorOccurred:
CONTEXT_CREATION_ERROR: Renderer: Error creating Canvas3D graphics context for queryProperties()
graphicsDevice = X11GraphicsDevice[screen=0]
canvas = me.drton.jmavsim.Visualizer3D$CustomCanvas3D[canvas0,0,0,0x0,invalid]
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:58)
Caused by: java.lang.IllegalStateException: Canvas3D: Non-recoverable graphics configuration error
at javax.media.j3d.Canvas3D.queryProperties(Canvas3D.java:3595)
at me.drton.jmavsim.Visualizer3D.createEnvironment(Visualizer3D.java:214)
at me.drton.jmavsim.Visualizer3D.(Visualizer3D.java:175)
at me.drton.jmavsim.Simulator.(Simulator.java:157)
at me.drton.jmavsim.Simulator.main(Simulator.java:678)
... 5 more
X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 2/2, reusable (open, marked uncloseable): 0, pending (open in creation order): 2)
X11Util: Open X11 Display Connections: 2
X11Util: Open[0]: NamedX11Display[:0, 0x7f19b0006c40, refCount 1, unCloseable false]
X11Util: Open[1]: NamedX11Display[:0, 0x7f1994020c70, refCount 1, unCloseable false]
^C
Exiting...
pxh> Shutting down
Restoring terminal
/home/itayguy/git/PX4Firmware/Tools/sitl_run.sh: line 167: kill: (5238) - No such process
ninja: build stopped: interrupted by user.
Makefile:147: recipe for target 'posix_sitl_default' failed
make: *** [posix_sitl_default] Interrupt

X11 Error while Running jmavsim with remote window fowarding.

I'm getting an odd error with jmavsim, but only when running remotely using x11 forwarding. Any suggestions much appreciated.

Command:
java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator

Error:
Success!
3D [dev] 1.6.0-pre12-daily-experimental daily

libEGL warning: GLX/DRI2 is not supported
libGL error: failed to load driver: swrast
com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for X11GraphicsDevice[type .x11, connection localhost:10.0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x407df228, isOwner false, <ca5412c, 3559b630>[count 0, qsz 0, owner ]]]
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.jogamp.opengl.GLException: main-SharedResourceRunner: Error making temp context(1) current: display 0x7faa4c006620, context 0x7faa4c038b40, drawable X11OnscreenGLXDrawable[Realized true,
Factory jogamp.opengl.x11.glx.X11GLXDrawableFactory@3a80e41f,
Handle 0x1200002,
Surface WrappedSurface[ displayHandle 0x7faa4c006620
, surfaceHandle 0x1200002
, size 64x64
, UOB[ OWNS_SURFACE | WINDOW_INVISIBLE ]
, X11GLXGraphicsConfiguration[X11GraphicsScreen[X11GraphicsDevice[type .x11, connection localhost:10.0, unitID 0, handle 0x7faa4c006620, owner true, ResourceToolkitLock[obj 0x6400cd3a, isOwner true, <70a1ce20, ee3d0a5>[count 2, qsz 0, owner ]]], idx 0], visualID 0x2e7, fbConfigID 0x4b,
requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL2/GL2.sw], on-scr[.]],
chosen GLCaps[glx vid 0x2e7, fbc 0x4b: rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.sw], on-scr[.]]]
, surfaceLock <e970846, 5da03325>[count 1, qsz 0, owner ]
, X11DummyUpstreamSurfaceHook[pixel 64x64]
, upstreamSurface false ]]
at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:371)
at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:759)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:642)
at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:580)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:297)
... 2 more
Exception in thread "main" java.lang.ExceptionInInitializerError
at javax.media.j3d.GroupRetained.(GroupRetained.java:155)
at javax.media.j3d.TransformGroupRetained.(TransformGroupRetained.java:116)
at javax.media.j3d.TransformGroup.createRetained(TransformGroup.java:115)
at javax.media.j3d.SceneGraphObject.(SceneGraphObject.java:114)
at javax.media.j3d.Node.(Node.java:172)
at javax.media.j3d.Group.(Group.java:551)
at javax.media.j3d.TransformGroup.(TransformGroup.java:87)
at me.drton.jmavsim.KinematicObject.(KinematicObject.java:32)
at me.drton.jmavsim.DynamicObject.(DynamicObject.java:18)
at me.drton.jmavsim.vehicle.AbstractVehicle.(AbstractVehicle.java:23)
at me.drton.jmavsim.vehicle.AbstractMulticopter.(AbstractMulticopter.java:19)
at me.drton.jmavsim.vehicle.Quadcopter.(Quadcopter.java:32)
at me.drton.jmavsim.Simulator.buildMulticopter(Simulator.java:184)
at me.drton.jmavsim.Simulator.(Simulator.java:116)
at me.drton.jmavsim.Simulator.main(Simulator.java:387)
Caused by: com.jogamp.opengl.GLException: Profiles [GL4bc, GL3bc, GL2, GLES1] not available on device null
at com.jogamp.opengl.GLProfile.get(GLProfile.java:1038)
at com.jogamp.opengl.GLProfile.get(GLProfile.java:1049)
at com.jogamp.opengl.GLProfile.getMaxFixedFunc(GLProfile.java:802)
at javax.media.j3d.JoglPipeline.initialize(JoglPipeline.java:132)
at javax.media.j3d.Pipeline.createPipeline(Pipeline.java:92)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:837)
at javax.media.j3d.VirtualUniverse.(VirtualUniverse.java:274)
... 15 more
X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 1/1, reusable (open, marked uncloseable): 0, pending (open in creation order): 1)
X11Util: Open X11 Display Connections: 1
X11Util: Open[0]: NamedX11Display[localhost:10.0, 0x7faa4c006620, refCount 1, unCloseable false]

compile error

I'm newbie in intelliJ

there are some error during compile..

error

doc for usage?

Hi all,

This is definitely a great piece of work. However for non-Java user the usage is unclear. Could anyone give some instructions?

can't communcate through udp port

I am trying to communicate to vagrant through udp , but I get the below message:

FAHADs-MacBook-Pro:jMAVSim fahadkhamis$ java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -udp 127.0.0.1:14560
3D [dev] 1.6.0-pre12-daily-experimental daily

Exception in thread "main" java.io.IOException: jssc.SerialPortException: Port name - /dev/tty.usbmodem1; Method name - openPort(); Exception type - Port not found.
at me.drton.jmavsim.SerialMAVLinkPort.open(SerialMAVLinkPort.java:38)
at me.drton.jmavsim.Simulator.(Simulator.java:110)
at me.drton.jmavsim.Simulator.main(Simulator.java:146)
Caused by: jssc.SerialPortException: Port name - /dev/tty.usbmodem1; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:165)
at me.drton.jmavsim.SerialMAVLinkPort.open(SerialMAVLinkPort.java:35)
... 2 more

Error while running jMAVSim

I installed Cygwin v2.3.0, Apache Ant v1.9.6 and Java JDK v1.8.0u66 (8 Update 66) on Windows 10.
Ran git clone git://github.com/DrTon/jMAVSim.
Then changed
serialMAVLinkPort.open("/dev/tty.usbmodem1", 230400, 8, 1, 0);
to
serialMAVLinkPort.open("COM3", 115200, 8, 1, 0);
(I will use it with APM) in Simulator.java

Then ran:

cd jMAVSim
git submodule init
git submodule update

Then compiled it, ran ant.

Then ran the jar file with:
java -Djava.ext.dirs= -cp lib/*;out/production/jmavsim.jar me.drton.jmavsim.Simulator
And got this error, any idea why?

Error: Could not find or load main class lib.gluegen-rt-natives-linux-amd64.jar
out/production/jmavsim.jar: line 1: $'PK\003\004': command not found
out/production/jmavsim.jar: line 2: $'\b\317u\207G': command not found
K-*▒▒ϳR0▒3▒▒r▒Cq,HL▒HU▒%-▒▒x▒▒▒RKRSt▒*A▒-▒gMETA-INF/MANIFEST.MF▒M▒▒LK-.▒
                                          ▒▒▒t▒
                                               -4▒▒▒sR▒▒: No such file or directory
out/production/jmavsim.jar: line 4: ▒K▒▒5y▒x▒PK: command not found
out/production/jmavsim.jar: line 5:▒u▒Gme/PK: No such file or directory
out/production/jmavsim.jar: line 6: $'\b\316u\207G': command not found
out/production/jmavsim.jar: line 7:▒u▒Gme/drton/jmavlib/PK: No such file or directory
out/production/jmavsim.jar: line 8:▒u▒Gme/drton/jmavlib/conversion/PK: No such file or directory
out/production/jmavsim.jar: line 9▒u▒G▒▒▒▒V4me/drton/jmavlib/conversion/RotationConversion.class▒SMS▒P=▒▒▒XiET▒Q▒u▒▒8: No such file or directory
out/production/jmavsim.jar: command substitution: line 10: syntax error near unexpected token `▒▒▒▒2▒▒▒'
out/production/jmavsim.jar: command substitution: line 10: `▒q▒▒(▒▒▒▒2▒▒▒;▒ޓ{N&▒~▒      ▒1▒O"▒듸▒▒*,▒▒1|▒mY▒[n[▒#'
?▒m/y+▒!▒▒F▒▒p[: No such file or directory▒▒
out/production/jmavsim.jar: line 10: $'\225U\301\261:\314tX\275\206L': command not found
out/production/jmavsim.jar: line 10: ▒▒▒@=▒▒6▒▒n▒▒Qu▒@▒~▒▒▒ё▒▒▒▒q*S: command not found
out/production/jmavsim.jar: line 16: !▒▒2M▒▒▒▒▒n▒%/▒N▒в▒▒ze▒▒7: No such file or directory
out/production/jmavsim.jar: line 17: $'\b\246\306': command not found
out/production/jmavsim.jar: line 17: $'?u\367\270hO\036\v\314z\347\003k\275\327]\231zID': command not found
out/production/jmavsim.jar: command substitution: line 18: syntax error near unexpected token `)'
out/production/jmavsim.jar: command substitution: line 18: `8▒Ê▒▒▒)()▒j(▒N▒U{▒sS▒▒s▒▒▒7▒XݮW▒▒v▒s̐▒▒▒'
out/production/jmavsim.jar: line 16: ▒▒D,▒M▒▒İƱؖ?▒▒{L▒ؕO!?y▒▒▒{OФ▒K▒▒▒▒▒]4▒▒QXq▒1#▒Y,: command not found
out/production/jmavsim.jar: line 17: syntax error near unexpected token `)'
out/production/jmavsim.jar: line 17: `▒e▒"C)▒▒8▒8▒▒▒F~▒
▒▒▒▒▒q▒b▒▒̢▒>▒x▒;▒G$̐=▒;Aߓn▒▒▒>▒T▒▒                      ▒EP▒`8UǷ▒▒K"޴my▒,gy
                                 ▒3▒7n▒T▒▒v
                                           Ve▒▒▒▒!֩k▒;<og▒▒▒V▒s▒▒břɖl7{▒▒▒X▒▒n▒▒▒-R]▒Z▒▒▒▒▒JU▒▒J'▒▒!&▒8M▒+▒4▒u>▒▒▒▒▒6▒[▒▒US▒)▒R̳W5▒▒}▒)▒E

jMAVSim Multiple Vehicles

HI
Can someone please guide me how can I get two vehicles on qgroundcontrol using jMAVSim?
Currently jMAVSim is simulating a single vehicle on qgroundcontrol. WHat I want is simulating two vehicles using a single jMAVSim simulator. Can anyone please guide me how can I proceed with this issue?

regards
Omar

Missing a file?

Hello I am getting a compile error this file seem to be missing in the master:

me.drton.jmavlib.geo

Connection to Matlab/Simulink

Hi,

I have a working Matlab Simulink model of a Quadcopter and would like to connect it to the HITL Simulation of PX4. My plan is to modify the jMAVSim in a way that instead of calculationg all the Forces etc. whithin the jMAVSim it actually calculates them in Simulink and passes (using UDP) the information to the jMAVSim (which will still handel all of the MAVLink communication with PX4).

Can you tell me where exactly in the code of jMAVSim are you calculating the accelerations, forces etc. of the copter and where does the desired signal of the PX4 act on the system?

Would be great if you could help me!

regards
Dominik

Not able to fly in jMAVSIM (Not able to disarm)

Hello all,
Im using the qgroundcontrol (version 2.9) and update the firmware, then disconnect, then open up jMAVSim. Up to this point, from the terminal I can see the following:

Init MAVLink
MSG: [inav] GPS timeout
MSG: [inav] GPS signal found

After that, Im trying to turn off the safety switch to enable the motor on my drone (IRIS 3DR), but no respond. I also tried to disarm it from my RC, but also no respond.

Im using Ubuntu 14.04
The lines I used to run jMAVSIM were:

  1. java -cp lib/_:out/production/jmavsim.jar me.drton.jmavsim.Simulator
    OR
  2. java -Djava.ext.dirs= -cp lib/_:out/production/jmavsim.jar me.drton.jmavsim.Simulator -serial /dev/ttyACM0 921600 -qgc

Any help will be appreciated! Thanks!

Dodecarotor Cox Mod - Issues

Hi!
I am trying to simulate a Dodecarotor Cox multicopter. I started my mod from your hexacopter vehicle, and followed the numbering so that it matches the PX4 - QGC numbering found here (https://docs.px4.io/master/en/airframes/airframe_reference.html).

Dodecarotor.java:
package me.drton.jmavsim.vehicle;

import me.drton.jmavsim.Rotor;
import me.drton.jmavsim.World;

import javax.vecmath.Matrix3d;
import javax.vecmath.Vector3d;

/**

  • Generic Dodecarotor model.
    */
    public class Dodecarotor extends AbstractMulticopter {
    private static final int rotorsNum = 12;
    private Vector3d[] rotorPositions = new Vector3d[rotorsNum];
    // private int[] rotorRotations = new int[rotorsNum];

    /**

    • Generic Dodecarotor constructor.

    • @param world world where to place the vehicle

    • @param modelName filename of model to load, in .obj format

    • @param orientation "x" or "+"

    • @param armLength length of arm from center (m)

    • @param rotorThrust full thrust of one rotor (N)

    • @param rotorTorque torque at full thrust of one rotor (Nm)

    • @param rotorTimeConst spin-up time of rotor

    • @param rotorHeight height of propeller from center point (m)

    • @param rotorsOffset rotors positions offset from gravity center

    • @param showGui false if the GUI has been disabled
      */
      public Dodecarotor(World world, String modelName, String orientation, double armLength,
      double rotorThrust, double rotorTorque, double rotorTimeConst, double rotorHeight,
      Vector3d rotorsOffset, boolean showGui) {
      super(world, modelName, showGui);

       rotorPositions[0] = new Vector3d(0.0, armLength, -rotorHeight);
       rotorPositions[1] = new Vector3d(0.0,-armLength, -rotorHeight);
       rotorPositions[2] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[3] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[4] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[5] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), -rotorHeight);
       rotorPositions[6] = new Vector3d(0.0, armLength, rotorHeight);
       rotorPositions[7] = new Vector3d(0.0,-armLength, rotorHeight);
       rotorPositions[8] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), rotorHeight);
       rotorPositions[9] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), rotorHeight);
       rotorPositions[10] = new Vector3d(armLength * Math.sin(Math.PI / 3),
       								armLength * Math.cos(Math.PI / 3), rotorHeight);
       rotorPositions[11] = new Vector3d(-armLength * Math.sin(Math.PI / 3),
       								-armLength * Math.cos(Math.PI / 3), rotorHeight);				
      

      if (orientation.equals("x") || orientation.equals("X")) {
      Matrix3d r = new Matrix3d();
      r.rotZ(-Math.PI / 2);
      for (int i = 0; i < rotorsNum; i++) {
      r.transform(rotorPositions[i]);
      }

      } else {
      throw new RuntimeException("Unknown orientation: " + orientation);
      }
      for (int i = 0; i < rotors.length; i++) {
      rotorPositions[i].add(rotorsOffset);
      Rotor rotor = rotors[i];
      rotor.setFullThrust((i > 5) ? 0.9*rotorThrust : rotorThrust); //Lower propeller reduced efficiency
      rotor.setFullTorque((i == 6 || i == 3 || i == 4 || i == 6 || i == 8 || i == 11) ? -rotorTorque : rotorTorque);
      rotor.setTimeConstant(rotorTimeConst);
      }
      }

    @OverRide
    protected int getRotorsNum() {
    return rotorsNum;
    }

    @OverRide
    protected Vector3d getRotorPosition(int i) {
    return rotorPositions[i];
    }
    }

I am calling it from Simulator.java using these specific values :

private AbstractMulticopter buildMulticopter() {
Vector3d gc = new Vector3d(0.0, 0.0, 0.0); // gravity center

	AbstractMulticopter vehicle = new Dodecarotor(world, DEFAULT_VEHICLE_MODEL, "x",
                                           0.6096, 306.26, 19.07, 0.005, 0.114, gc, SHOW_GUI);
	
    Matrix3d I = new Matrix3d();
    // Moments of inertia
    I.m00 = 39.0;  // X
    I.m11 = 39.0;  // Y
    I.m22 = 52.0;  // Z
    vehicle.setMomentOfInertia(I);
    vehicle.setMass(100);
    vehicle.setDragMove(2);
    SimpleSensors sensors = new SimpleSensors();
    sensors.setGPSInterval(50);
    sensors.setGPSDelay(200);
    sensors.setNoise_Acc(0.05f);
    sensors.setNoise_Gyo(0.01f);
    sensors.setNoise_Mag(0.005f);
    sensors.setNoise_Prs(0.1f);
    vehicle.setSensors(sensors, getSimMillis());
    //v.setDragRotate(0.1);

    return vehicle;
}

The build of the code is successful, however, my drone does not take off. I believe the error might lies in AbstractMulticopter.java . Can you help me? Or is there resources anywhere to help me build my own airframe configurations?

Hexacopter simulation problem in jMAVSim w/ Pixhawk

Hello group members,
I am trying to carry the flight simulation in jMAVSim using Pixhawk controller,
but i have some problem
I want to hexacopter simulation in jMAVSim and edited the 'Simulator.java'
There is a hexacopter code in vehicle folder, and i applied in Simulator.java source code.
But when i shoot the flight simulation in jmavsim, it cannot maneuver well
(altitude change works, but heading change does not work)
did i miss some steps ?
I didnot changed anything in QGC (including frame setting as 'HIL quadroter x')
Actually it worked well w/ the quadcopter code
The only thing i have changed is the Simulator.java code
If someone has some clue for this, I really appreciate it
Thank you :)

ps. Firmware PX4 1.4.4 is used

Error With Simulator.class

I am able to download and compile the jMAVSim directory using ANT. When I run "java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -udp 127.0.0.1:14560" I get the error could not find or load main class me.drton.jmavsim.Simulator. Am I not doing something correctly with the build.xml file? Is there something else that I am missing here?

Thanks,

Simulator can't displaye the attitude

I use the pixhawk, and connect via USB (/dev/ACM0), and then the jMAVLink can't dispaly the status, just on the ground,

and i try to connect the QGC via udp, the QGC display No Rules.

Thanks.

GPS signal found/lost and OFFBOARD reject

GPS signal found/lost

Is there anyreason why I got a warning

MSG: [inav] GPS timeout

or

MSG: [inav] init ref: 55.7533950, 37.6254270,   0.0000
MSG: home: 55.7533950, 37.6254270, -0.01

then

(MAV 001:50) [inav] GPS signal found 
(MAV 001:50) [inav] GPS signal lost 

these two warnings when I started jMAVsim and keep warning all the time even though I armed the plane with RC.

My setting up are

  • Ubuntu 14.04
  • Pixhawk with Pixhawk Fireware
  • QGC < - udp -> jMAVSim < - usb(/dev/ttyACM0) -> Pixhawk

OFFBOARD reject

I tried both RC_MAP_OFFB_SW = 8 and rosrun mavros mavsys mode -c OFFBOARD method, but still got

(MAV 001:50) REJECT OFFBOARD 

I checked the ros topic /mavros/setpoint/local_position worked fine but only send (0, 0, 3) for climbing.

My setting up are

  • Ubuntu 14.04
  • Pixhawk with Pixhawk Fireware
  • QGC < - udp -> MAVROS<- udp -> jMAVSim < - usb(/dev/ttyACM0) -> Pixhawk
  • ./setpoint_demo.py as mentioned at https://pixhawk.org/dev/ros/hil.

Making jMAVsmi SITL simulator (instead of HITL)

How much work is actually needed to change it into fully-working SITL for Pixhawk (or ArduPilotMega?)

I am really looking forward finding an alternative for heavy Gazeboo simulator.

What do you think needs to be done and what are barriers?

Run JmavSim in HITL Mode

I am trying to run Jmavsim in HITL mode. I follwed the link
https://pixhawk.org/dev/hil/jmavsim
and used /dev/ttyACM0(Pixhawk connected through usb(serial)) and /dev/ttyUSB0(Pixhawk connected through radio telemetry(udp)) and as mention in link ttyusbmodem1 but every time it throws serial port exception either port not found or port busy.

Thanks.

WARNING: Got heartbeat from system #2 but configured to only accept messages from system #1. Please change the system ID parameter to match in order to use HITL/SITL.

Hi,
I have an issue when I start jMAVSim to communicate with px4 by running:

java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -serial /dev/ttyACM0 921600 -qgc

it shows the blow log:

WARNING: Got heartbeat from system #2 but configured to only accept messages from system #1. Please change the system ID parameter to match in order to use HITL/SITL.

is that related to MAV_SYS_ID?

jMAVSim does nothing

This is my first time using any of these. Please tell me if I did anything wrong.

I started jMAVSim using

sudo java -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator

Then, I connected the quad. I run

roslaunch mavros px4.launch

Then I armed it by

rosrun mavros mavsafety arm

I pressed the safety switch and armed it. Then I run the ./setpoint_position_demo.py from https://pixhawk.org/dev/offboard_control/testing

Then, I change it to Offboard mode using

rosrun mavros mavsys mode -c OFFBOARD

There was no change in the simulator window. The output of the jMAVSim Terminal is

3D [dev] 1.6.0-pre12-daily-experimental daily

libEGL warning: DRI2: failed to authenticate
Init MAVLink
MSG: Switched to ON hil state
MSG: [inav] GPS signal found
MSG: [inav] init ref: 55.7533950, 37.6254270,   0.0000
MSG: home: 55.7533950, 37.6254270, -0.03
MSG: Waypoint too far: 5858770 m,[MIS_DIST_1WP=900]
MSG: Not switching off HIL (safety)
MSG: command temporarily rejected: 176
MSG: Flight mode: OFFBOARD
MSG: [mpc] reset pos sp: 0, 0
MSG: [mpc] reset alt sp: 11
MSG: [cmd] ARMED by arm/disarm component command
MSG: [sdlog2] log dir: /fs/microsd/log/2015-11-02
MSG: [sdlog2] starting: 12_39_19.px4log
MSG: TAKEOFF DETECTED
MSG: LANDING DETECTED
MSG: Not switching off HIL (safety)
MSG: [cmd] DISARMED by set mode command
MSG: command temporarily rejected: 176
MSG: [sdlog2] logging stopped
MSG: [cmd] ARMED by arm/disarm component command
MSG: [sdlog2] log dir: /fs/microsd/log/2015-11-02
MSG: [sdlog2] starting: 12_40_10.px4log
MSG: TAKEOFF DETECTED
MSG: LANDING DETECTED
MSG: failsafe mode on
MSG: [mpc] reset pos sp: 0, 0
MSG: [mpc] reset alt sp: 4
MSG: TAKEOFF DETECTED
MSG: failsafe mode off
MSG: Flight mode: OFFBOARD
MSG: LANDING DETECTED

I suspect something fishy at

 libEGL warning: DRI2: failed to authenticate

Please help!!

IRIS Model in jMAVSim?

How does jMAVSim perform IRIS simulation with qgroundcontrol? Does jMAVSim has a build-in IRIS dynamic model or get the model from somewhere else?

It seems to me that the default modeling parameters in Simulator.java is quite different to IRIS specs.

Headless version

Hey there!

Just curious if you had ever considered creating a headless version of the simulator. It looks like Java3d is tightly coupled though.

PX4 HIL mode

Hi,
I'm trying to get jMAVSim to work with PX4FMU, PX4 flight stack. I was able to get jMAVSim running and connected to PX4 via USB. I can also connect with qgroundcontrol to jMAVSim via UDP successfully.

The problem is, jMAVSim only receives mode changes, but nothing happens in simulator window (motors also don't spin).

Here is what's printed in console of jMAVSim:

$ java -Djava.library.path=./ -cp out/production/jmavsim.jar me.drton.jmavsim.Simulator
Init MAVLink
MSG: Switched to ON hil state
MSG: detected RC signal first time
MSG: ARMED by RC
MSG: [cmd] arming state: ARMED
MSG: [sdlog2] log dir: /fs/microsd/log/sess018
MSG: [sdlog2] starting: log001.px4log
MSG: IN AIR MODE
MSG: LANDED MODE
MSG: [inav] GPS signal found
MSG: [inav] init ref: 55.7533950, 37.6254270, 0.0000
MSG: home: 55.7533950, 37.6254270, 0.00
MSG: IN AIR MODE
MSG: LANDED MODE
MSG: IN AIR MODE
MSG: LANDED MODE
MSG: IN AIR MODE
MSG: LANDED MODE
MSG: IN AIR MODE
MSG: LANDED MODE
MSG: DISARMED by RC
MSG: [cmd] arming state: STANDBY
MSG: [sdlog2] logging stopped

Maybe I am missing some obvious configuration steps and this is not a bug, but an error on my side?
I would also welcome any tips on how to debug this issue.

Error in Windows

Every time i run jMAVSim this error appears:

Exception in thread "main" java.net.BindException: Cannot assign requested address: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:465)
at sun.nio.ch.DatagramChannelImpl.connect(DatagramChannelImpl.java:738)
at me.drton.jmavsim.UDPMavLinkPort.open(UDPMavLinkPort.java:36)
at me.drton.jmavsim.Simulator.(Simulator.java:112)
at me.drton.jmavsim.Simulator.main(Simulator.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Process finished with exit code 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.