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

NaN Values in Simulation with QuaternionSpherical Joint #617

Closed
jfkunz opened this issue Mar 19, 2021 · 2 comments · Fixed by #618
Closed

NaN Values in Simulation with QuaternionSpherical Joint #617

jfkunz opened this issue Mar 19, 2021 · 2 comments · Fixed by #618

Comments

@jfkunz
Copy link

jfkunz commented Mar 19, 2021

Hi,
I tried to simulate a simple pendulum with a link attached by a QuaternionSpherical joint (ball-socket joint). The joint is displaced with a translation. When I run the simulation, the output configurations contain NaN values. Here is the code to recreate the behavior:

using RigidBodyDynamics
using Rotations
using LinearAlgebra
using StaticArrays
 
# # working with zero offset 
# translation = [0,0,0]
 
# NaN with non-zero offset
translation = [0.3,0,0]
 
origin = RigidBody{Float64}("origin")
pendulum = Mechanism(origin; gravity=[0., 0., -9.81])
 
center_of_mass = [0,0,0.2]
q0 = [cos(pi/8);sin(pi/8);0.0;0.0]
 
joint1 = Joint("joint1", QuaternionSpherical{Float64}())
inertia1 = SpatialInertia(frame_after(joint1), com=center_of_mass, moment_about_com=diagm([1.,1.,1.]), mass=1.)
link1 = RigidBody("link1", inertia1)
before_joint1_to_origin = Transform3D(frame_before(joint1), default_frame(origin), one(RotMatrix{3}), SVector{3}(translation))
attach!(pendulum, origin, link1, joint1, joint_pose=before_joint1_to_origin)
 
state = MechanismState(pendulum)
 
set_configuration!(state, joint1, q0)
ts, qs, vs = simulate(state, 10., Δt=0.001)
display(qs)

Interestingly, the simulation works just fine if I set the translation to zero.
Thank you!

@tkoolen
Copy link
Collaborator

tkoolen commented Mar 19, 2021

Thanks for the report and the reproducer. Will be fixed by #618.

@jfkunz
Copy link
Author

jfkunz commented Mar 19, 2021 via email

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

Successfully merging a pull request may close this issue.

2 participants