Skip to content

Using With AutoQuad

Max Paperno edited this page Apr 27, 2016 · 17 revisions

Using jMAVSim With AutoQuad

For more information and assistance check the AutoQuad Forums discussion thread.


First you will need some "things."

  1. AutoQuad M4 board (any version).
  2. jMAVSim (obviously), a version from this repository. Either build it yourself (see main README) or download a pre-built archive (check Releases section in this GitHub repo).
  3. AutoQuad firmware built with Maxim Paperno's HILSim for AutoQuad library (the firmware binary will typically have "-hils" appended in the name, eg. aqfc-mp-vX.Y.ZZZZ-hwv8.6-quatos-hils.bin).
  4. A decently fast computer with a 64-bit operating system (Windows/Linux/OS X) -- at least a 2+GHz quad-core with fast graphics is recommended (this is really just a guess, minimum system specs not determined yet).
  5. 64-bit Java 8. You can check to see which one you have already by going to a command line and running java -showversion You need to see output similar to below (note the version "1.8.x" and "64-Bit Server VM" parts). If you don't see this, you need to go to the Java downloads page and grab the latest 64-bit version of the JRE for your OS (or the JDK if you want to be able to make changes to jMAVSim).
    java version "1.8.0_74"
    Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
  6. Optional - another way to connect to the AQ M4 for a telemetry link (serial USB adapter, bluetooth, etc) -- you will not be able to use USB port while Sim is running.
  7. AQ setup params file and (optionally) Quatos motor mix file. (Right-click the links and Save As...)
  8. A good USB cable. (Saved the easiest for last! ;-) )

It is highly recommended that you disconnect (or do not provide battery power to) the motors/ESCs before running the simulator. There are some safeguards in the firmware to prevent motors from running, but it is better to be safe. All you actually need powered is the AQ itself and some radio input (on-board or external Rx).

If you do have motors connected and powered, be sure to disarm the AQ before exiting the simulator mode.

Now get your M4 and USB cable ready -- save the current onboard params if you care about them. You will not be able to use Mavlink over the USB link (while sim is running) so you'll probably also want a serial/BT connection ready to go, it's much simpler to set up that way. You can also run QGC on a separate computer from the sim (for performance reasons or just to have a 2nd screen).

The params file you downloaded has all the required settings to match the sim (and some PID/Quatos tuning). It does not include stuff like radio setup, comm settings, and so on... those are up to you. Just set it up like you would any normal quad. The params are set for Quatos. To use PIDs, just load a predefined Quad X mix, save and reboot. The Quatos mixing table from the link above makes it simple to switch back.

Make sure your voltage source is correct... it doesn't matter how many "cells" you fly with, as long as it's some voltage that somewhat resembles a LiPo pack. It doesn't have to be precise (eg. mine's powered with 12V from a wall-wart which is detected as 3 cells.)

Basically pretend like you're going to fly this thing for real and set it up the way you want (but start with the tunings provided).

If you downloaded a pre-built zip archive of jMAVSim, unzip it into any folder of your choice. Get a command prompt ready in the folder with the .jar file (Windows tip: shift-right-click on a folder in Explorer tree view to get a convenient "Open command window here" option).

Let's make sure jMAVSim runs at all... At that command prompt, enter:

java -jar jmavsim_run.jar -h

You should see some help text. If you get a Java error... read it and make a record of it. Do the java version check again to make sure you're running 64b Java in that cmd-prompt. If you get the help text, read that too... ;-) Especially the last part about different key commands to use while in the sim window. You can switch views and such. Especially useful is hitting SPACE bar after you crash!

Assuming that worked, now boot up your AQ and connect the USB cable. Make sure the USB port is active on the computer before starting jMAVSim (device recognized, port present) -- otherwise you will get an "ugly" error when starting the sim. Also make sure no other program is using the AQ COM port (eg. QGC, which may re-connect to the USB port automatically in some cases). Now finally we can run the sim:

java -jar jmavsim_run.jar -ap aq -serial COM20 2400

Replace COM20 with your USB com port. The 2400 part (baud rate) is important. You can use other command-line options which you saw in the help text (eg. -max to start the simulator in a maximized window). Keep the -ap aq part unless you know that is already the default MAV type (from looking at the help text). See note for OS X at the bottom of this page under Troubleshooting.

If all goes well you should see the simulator 3D view come up, and then you should see a startup message sequence like (or similar to) this:

Init MAVLink
MSG: HILSIM: Simulation mode enabled
MSG: HILSIM: UKF reset completed.

All text messages from AQ show up in the simulator window with "MSG:" prepended. "HILSIM:" indicates a message from the HILS code running on AQ.

That's it... now arm the 'copter and go fly!


Motor outputs on the physical AQ ports (PWM and CAN) are disabled during the simulation. It should be safe to use ports with motors/ESCs connected, but do excercise caution. Disconnecting the ESCs entirely would be preferable. All you actually need powered is the AQ itself and some radio input (onboard or external Rx).

Press F1 key to get a list of all available key commands. SPACE bar resets everything, and also resets the AQ UKF (filter) back to defaults (otherwise it may get confused about the current orientation & position). You may need to give the UKF a few moments to settle down after a reset (watch the HUD in QGC to see what's going on in real-time).

Some touches with the ground are "survivable" but if you really drill it in, just hit SPACE to reset.

The MR modeled by the simulation is, by default, is a small 250g, 200mm dia. X-quad with 5" rotors (roughly, anyway). It can be tuned (via AQ settings) to very agile or docile, as you prefer. This does mean that if the wind in the simulation gets too strong, it will carry the little thing away (just like in real life!). It also means that the 1kg Quatos license which came with your AQ M4 will work in the sim. The PID controller works fine as well.

There is also a gimbal/camera modeled in the sim (the funny "clown ball" dangling underneath the model). If you set up your AQ with gimbal outputs, the simulated gimbal will be controlled as well. It doesn't matter which port(s) you specify for the gimbal output(s), just use any free port number. Gimbal output ports are active during simulation. Do not use a port with a real motor/gimbal connected. To view from the gimbal camera, press the G key in the sim. You will most likely need to tune the AQ gimbal settings to smooth out the gimbal movements.


If you get an error when starting jMAVSim, please make a note of it so someone can help you diagnose the issue. After all the initial program resources (graphics/etc) are loaded, any errors or warnings will appear in the message window of the main GUI as well as in the console (command prompt) window. Common error messages should be fairly self-explanatory, like if it can't open the COM port you specified.

Other than actually starting the sim, the most likely problem is going to be performance issues. The computer running jMAVSim is being asked to do a lot at once, and it needs to do it as near real-time as possible. Which desktop operating systems aren't always good at. Then there's also the 3D graphics involved, which isn't something Java is especially known for.

Anyway, if you run into performance issues, here are some things to try:

  • Try running the sim a bit slower or faster. Use the -r <Hz> startup option, where <Hz> is a speed. The AQ version runs at 400 Hz by default. Try lowering or raising that in steps of 100, within a range of 100 to 800 Hz.
  • Turn off anti-aliasing. Use the -no-aa option with jMAVSim, but keep in mind that your graphics driver may override the application settings (the graphics driver options would need to be set to "allow application to decide" or something similar.
  • Hide the HUD after startup -- use the H key.
  • Make sure nothing else is running on your computer. Especially anti-virus programs or other "invasive species" of that sort. Many people don't realize how much junk is running in the background on their computer, a lot of which they never even use. AV can cause your computer to seem to freeze up for some moments, which definitely won't be good for the simulator (remember that thing about real-time?).

Check the main README for more troubleshooting ideas.

On OS X you will most likely need to add the -Djava.ext.dirs= option mentioned in the readme. Like this:

java -Djava.ext.dirs= -jar jmavsim_run.jar ...

Clone this wiki locally
You can’t perform that action at this time.