ami-iit / liecasadi

Rigid transform using Lie groups and Dual Quaternions, written in CasADi!
BSD 3-Clause "New" or "Revised" License
57 stars 4 forks source link

Add slerp and override getattr method #7

Closed Giulero closed 1 year ago

Giulero commented 1 year ago

This PR introduces the slerp method. See the example slerp_so3 to check how it works.

Also, I introduced a small modification that would allow passing directly Quaternion objects to casadi methods without accessing the quaternion coefficients with .coeffs():

    def __getattr__(self, attr):
        return getattr(self.xyzw, attr)

This modification should give to the Quaternion class methods from the underlying type that is used to build a Quaternion instance.

For example, before:

opti.subject_to(quat[k + 1] == (rotation_SO3[k+1]).as_quat().coeffs())
# or
opti.subject_to(quat[k + 1] == (quaternion_obj[k+1]).coeffs())

Now:

opti.subject_to(quat[k + 1] == (rotation_SO3[k+1]).as_quat())
# or
opti.subject_to(quat[k + 1] == (quaternion_obj[k]))

This modification shouldn't break the previous code since the .coeffs() method is still accessible.

A lot of doc is still missing! I'll add it in a different PR.

Giulero commented 1 year ago

Thanks @FabioBergonti !

diegoferigo commented 1 year ago

@Giulero sorry for the late feedback, it looks good to me. Is there any reason why you removed the quaternion product method? I don't think I'm using it, but it might be useful to others.

Giulero commented 1 year ago

Is there any reason why you removed the quaternion product method? I don't think I'm using it, but it might be useful to others.

Actually, it was an old duplicate in SO3 class. The quaternion product is in the Quaternion class :)

diegoferigo commented 1 year ago

Is there any reason why you removed the quaternion product method? I don't think I'm using it, but it might be useful to others.

Actually, it was an old duplicate in SO3 class. The quaternion product is in the Quaternion class :)

Ow ok it makes sense! Thanks for the detail :wink: