Determining cause of failsafe

I’m trying to solve a few issues that I’ve been having with my pixracer and in order to do so I need to determine the cause of failsafe. I have a plot showing the status of the controller

How can I know what the numerical values of navstate and mainstate correspond to?

I also have the .mavlink file from QGC. is there I way I can extract the failsafe cause from this?

Just in case here are the two log files. https://drive.google.com/drive/folders/0B2mys0x5fHHtaUlaVkppam0tOWc?usp=sharing
In this flight the the drone flew around fine for a few seconds in stabilized mode before declaring “Failsafe” and zooming up to get stuck in the limb of a tree.

Thanks. That’s exactly what I was looking for. For completeness sake, the declarations for MainState are here: https://github.com/PX4/Firmware/blob/4453e4201b7a245cff52beeb38a293161aea4c48/msg/commander_state.msg

So, I can see that failsafe was briefly true and that as a result NAV_STATE went to 6 (RC recover mode). Is there any way from the logs that I can get more information about what caused failsafe to enable?

I think you’ll have to look at the commander source code to do that.