Coder Social home page Coder Social logo

jmavsim's Introduction

jMAVSim

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 julianoes avatar gitter-badger avatar ashish-kb avatar

Watchers

James Cloos avatar  avatar

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.