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.
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:

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.