ami-iit / adam

adam implements a collection of algorithms for calculating rigid-body dynamics in Jax, CasADi, PyTorch, and Numpy.
https://adam-docs.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
123 stars 19 forks source link

Remove casadi.MX #89

Closed Giulero closed 2 months ago

Giulero commented 2 months ago

I did some tests using casadi.MX, and I figured out that that MX is not really elastic. For example, a "numeric MX" (an MX filled with numbers) cannot be converted to a DM, while a "numeric SX" can. Also, MX and SX cannot be converted to each other.

On the other hand, passing through a casadi.Function allows the user to choose the type of the input and have the output of the same type, i.e.

a_sx = cs.SX.sym('a')
b_sx = cs.SX.sym('b')

fun = cs.Function('fun', [a,b], [a+b])

c_sx = fun(a_sx, b_sx)

a_mx = cs.MX.sym('a')
b_mx = cs.MX.sym('b')

c_mx = fun(a_mx, b_mx)

# this should be possible also with casadi.DM and numpy 

For this reason (and also because I've not implemented sufficient tests) I want to revert #84, for now, and just do the computation with casadi.SX and exploit the casadi.Function.

Giulero commented 2 months ago

Thanks @GiulioRomualdi!

Cc @traversaro, @S-Dafarra I had to revert #84, the MX support needs more development.

S-Dafarra commented 2 months ago

Also, MX and SX cannot be converted to each other.

I think that the conversion from MX to SX should be possible with expand 🤔