Hey all

I’m trying to wrap my head around a supposedly simple problem, but it’s not working yet.

It is known (see https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf) that the relationship between the measured (e.g. by an accelerometer) acceleration of earth’s gravity a=\left[a_x,a_y,a_z\right]^T relates to Euler ZYX angles (Euler angles - Wikipedia) via

\theta is the so called Pitch angle and \phi the Roll angle. They can be calculated from (1) via

What I’d like to calculate is a local sensitivity function for J_\phi(\phi,\theta), i.e. I’d like to plot a surface plot with ||{J}|| on the z-axis and \phi and \theta on the x and y axis respectively.

To my understanding, I’d need to calculate the partial derivatives of (2). The problem here is, that (2) is no function of \phi or \theta but of a_y and a_z. So there are more calculation steps required. However, (hopefully) all information are shown in (1).

Can Julia do these term conversion to eliminate all a_{x,y,z} terms? I do not know if that’s mathematically possible. But then I would not know how to calculate the sensitivity function.

I tried to use (3) as a starting point and calculated the partial derivatives, but there are still dependencies of a_z and a_x.

Can Julia do (in some magic way) a sensitivity analysis of (1) directly?

From a Monte Carlo analysis (sampling a randomly across the unit sphere’s surface and applying (2) and (3) to calculate the angles) and practical experiments, some shape like here (with different scaling on z) would be expected:

Disclaimer: I don’t know if that task is solvable analytically, but some paper are doing a sensitivity analysis without showing the steps (and then applying simplification like setting a_x=0 to plot it), e.g. https://doi.org/10.1109/TIM.2008.2006137

Thank you very much!

Jan