Enabling SIM_STATE message in ArduCopter SITL logs?

Hi all,

I’m running some tests using the SITL framework in ArduCopter, and injecting in faults to the GPS, barometer etc. For analysis, I need to get the simulation ground truth data about the position, altitude, vx, vy, vz etc. as the GLOBAL_POSITION message data and any sensor messages will necessarily be affected by the faults I inject and not representative of the actual behaviour of the copter.

The log files contain the SIMSTATE message, which contains the latitude, longitude and some other useful information about the copter in the simulation, but doesn’t have all of the data I need like the altitude or velocities. The MAVLink protocol specifies a SIM_STATE message in the common message set which includes all the variables I am interested in, but this message doesn’t seem to be saved into the log files if indeed it is sent at all.

Is there any way to enable the SIM_STATE message so that it is included in the .tlog files? Or any other workaround that could get me access to the variables contained in the SIM_STATE message?



We aren’t supporting the SIM_STATE message for now. I am working on a fix so that SIMSTATE will be even to SIM_STATE

While you’re at it, do you think it possible to add a timestamp to the SIMSTATE message?



Thanks for the response, if the SIMSTATE message achieves parity with the SIM_STATE message then that’ll work for me. What sort of timeline is there for this change, i.e. weeks, months? I could use this in a paper I’m writing, though I have a backup strategy in mind if it will take more than a few weeks.


I seem to have a similar use case as you. I need the true simulated absolute position and rotation. I’d like precision for position down to 1cm or so.

Today I discovered that while the SIM_STATE mavlink metadata was added in 2013, no implementation was done.

I managed to get the following patch to compile. It emits mavlink with msgid=108 to my client, as intended. I have only taken a quick glance at the altitude field, and so far it looks good. I will proceed with checking the other fields that I need. YMMV.



PS: Here is the mavlink commit that added the SIM_STATE message:

    commit 6eb8cfcec1f343d6cfca1d0b43261aebf7a3549a
    Author: Andrew Tridgell <tridge@samba.org>
    Date:   Thu Jun 6 16:41:03 2013 +1000

        message_defintions: added RADIO_STATUS, SIM_STATE and HIL_SENSOR

        the RADIO_STAUS is a copy from ardupilotmega

        HIL_SENSOR is intended to replace HIL_STATE, giving missing

        SIM_STATE is used to provide feedback to ground stations on true SIM

        Pair-programmed-with: Lorenz Meier

Hi Jeff,

Thanks for this, I’ve checked your code out and understand a bit better how to get access to the simulation state. Unfortunately for me the messages aren’t being saved into the .tlog files produced after running a SITL simulation which is what I use, so I’ll need to keep investigating why that is.

Is there a reason that SIMSTATE doesn’t contain the altitude?
Do I need to integrate AccZ from takeoff? or is there a better way?

Is there a reason that SIMSTATE doesn¢t contain the altitude?

Somebody managed to overlook it when the message was created…

Do I need to integrate AccZ from takeoff? or is there a better way?

Probably a mavlink2 extension to the message…


Try ahrs2 message, which contains relative altitude

1 Like