Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbolic Derivatives with SymPy do not work #630

Open
traikodinev opened this issue Mar 21, 2022 · 3 comments
Open

Symbolic Derivatives with SymPy do not work #630

traikodinev opened this issue Mar 21, 2022 · 3 comments

Comments

@traikodinev
Copy link

As of the latest version, the example is broken.

https://github.com/JuliaRobotics/RigidBodyDynamics.jl/blob/master/examples/6.%20Symbolics%20using%20SymPy/6.%20Symbolics%20using%20SymPy.jl

Using version 2.2.0 works.

The issue is that Quaternion does not support type Sym. I can update later with more info.

@ferrolho
Copy link
Member

ferrolho commented Nov 8, 2024

@blegat, I was exploring the source of Dionysos.jl and came across BipedRobot/src/piracy.jl. Is that somehow correlated to this issue? Was the type piracy a workaround? Thanks in advance and sorry for the unsolicited tag... :P

@ferrolho
Copy link
Member

ferrolho commented Nov 10, 2024

The issue can be fixed with

# Type piracy needed in order to make Symbolics.jl types interact well with Quaternions.jl.
# This should be avoided — see https://docs.julialang.org/en/v1/manual/style-guide/#avoid-type-piracy.
function Base.:/(q::Quaternions.Quaternion, x::Symbolics.Num)
    return Quaternions.Quaternion(q.s / x.val, q.v1 / x.val, q.v2 / x.val, q.v3 / x.val)
end

which should be included with #648 when that gets merged.

I took the snippet from BipedRobot/src/piracy.jl.

@blegat
Copy link

blegat commented Nov 11, 2024

Yes, we tried RigidBodyDynamics with SymPy but then ended up using Symbolics.jl
We had a similar issue (see also JuliaGeometry/Quaternions.jl#128 which shows that it can get tricky) and we ended up deciding to do some type piracy 😇
I assume our method could solve it, maybe by replacing Symbolic.Num to something like SymPy.Num.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants