Need help with jMAVsim - always climbing and can't start mission [SOLVED]

Hi, I have been trying to set up a hardware in the loop (HIL) simulation for multi-copters using jMavsim. Here is a summary of my problem:

  • Simulated vehicle starts climbing immediately after arming

  • 0 throttle (stick at the bottom) correspond to 1000 PWM for each motor, but vehicle is still climbing

  • Pixhawk connected to Ubuntu terminal via a usb cable, only things attached to pixhawk are safety swtich, buzzer and RC receiver, I use a RC transmitter to give manual control input

  • When switch to mission mode, console rejects commad “MSG: Rejecting mode switch cmd”

  • Same error message when switching to Altitude Control, Hold, Return to Land, Follow

  • I use this command to start the simulation (not sure if baud rate matters, I have tried 57600, 115200 with same results)
    java -Djava.ext.dirs= -cp lib/*:out/production/jmavsim.jar me.drton.jmavsim.Simulator -serial /dev/ttyACM0 57600 -qgc

So far I can get the visualization to work on Ubuntu 14.04 LTS, establish a serial connection to a pixhawk loaded with the latest PX4 flight stack from qgroundcontrol, and establish a UDP connection to the qgroundcontrol. But the problem I have now is that as soon as I arm the autopilot, the vehicle sitting in jMavsim will start climbing, and this behavior is also reflected by the altitude reading in qgroundcontrol. As I increase throttle the vehicle will climb even faster, but when I move the throttle to minimum the vehicle won’t come back down, it only start falling when I disarm the autopilot.

Another issue I have is I can’t set the vehicle to mission mode. I can create missions in qgroundcontrol and sync them to the vehicle, but I get a “MSG: Rejecting mode switch cmd” in the jMAVsim console every time.

A screenshot of the jMAVsim window is attached.

I have a similar problem. About mission mode, you must ensure that you have a valid home position. Then you ll be able to set your vehicle in the mission mode. But in the misssion mode, when arming the device, it always climbing, too!
Have you solved this issue ?

I pretty much followed this guide

I still couldn’t figure out how to stop it from climbing. I tried switching to Altitude hold mode, but it climbs even faster…

How do you ensure a valid home position? Did you solve the climbing problem yourself?


I tried to run the HIL today, and solved the climbing issue by changing the vehicle mass in the simulation.

Go to Firmware/tools/jMAVSim/src/me/drton/jmavsim, open with an editor, around line 308, where a new AbstractMulticopter object is constructed, in vehicle.setMass(0.8), change this 0.8 to something around 1.2.

So after all it was because the simulated vehicle was way too light…idle thrust even at the absolute minimum allowed, is still too strong.

Interesting. Can you send a pull request?

Yeah sure, I will try a few different numbers and find the optimal mass for the default vehicle.

@LorenzMeier @metusa
It turns out 1.0 is the sweet spot… Anyway I have made a pull request.

Hi @Zi_W
Thank you very much for your reply. Now, I can run HIL successfully.