SatelliteToolbox.jl icon indicating copy to clipboard operation
SatelliteToolbox.jl copied to clipboard

Compatibility of transformations code with Automatic Differentiation tools (Zygote)

Open srikumarks opened this issue 1 year ago • 2 comments

Zygote is the most used Automatic Differentiation tool and it doesn't support static arrays due to their use for mutations [^1]. DCM and Quaternion structures used in frame conversion code, which I'm trying to use with Zygote, use SMatrix and SVector for efficiency reasons as stated in the code comments. However that makes them incompatible with Zygote.

Having the transformation code be AD compatible is perhaps useful (broadly true for most libraries) and so posting this issue in that spirit. One way to address this in the library is to perhaps also support a third rotation representation that uses ordinary vectors/matrices (could be DCM based representation, but just uses a vector of 9 numbers or an ordinary Matrix instead of an SMatrix{3,3}).

This impacts the angle_to_rot functions defined in the ReferenceFrameRotations package - ReferenceFrameRotations/uTarN/src/conversions/angle_to_rot.jl. It looks at the moment that having angle_to_rot support the ordinary matrix as a return type should suffice to get all the r_eci_to_eci and r_eci_to_ecef and such functions to also support them when overloaded with the first argument being the type Matrix. Will also have to check whether the "multiply with vector to transform it" steps will also work properly.

(I might implement this, but posting an issue in advance for any comments or tips that could help with it ... with the best case being "it already exists"!)

[^1]: Apparently. I'm not conversant with all the details of why.

srikumarks avatar Jan 21 '23 02:01 srikumarks