|
225 | 225 | energy20 = gravitational_potential_energy(state) + kinetic_energy(state) |
226 | 226 | @test energy20 ≈ energy15 atol=1e-5 # stabilization doesn't significantly affect energy after converging |
227 | 227 | end |
| 228 | + |
| 229 | + @testset "Ball joint pendulum" begin |
| 230 | + # Issue #617 |
| 231 | + translation = [0.3, 0, 0] |
| 232 | + |
| 233 | + world = RigidBody{Float64}("world") |
| 234 | + pendulum = Mechanism(world; gravity=[0., 0., -9.81]) |
| 235 | + |
| 236 | + center_of_mass = [0, 0, 0.2] |
| 237 | + q0 = [cos(pi/8), sin(pi/8), 0.0, 0.0] |
| 238 | + |
| 239 | + joint1 = Joint("joint1", QuaternionSpherical{Float64}()) |
| 240 | + inertia1 = SpatialInertia(frame_after(joint1), com=center_of_mass, moment_about_com=diagm([1.,1.,1.]), mass=1.) |
| 241 | + link1 = RigidBody("link1", inertia1) |
| 242 | + before_joint1_to_world = Transform3D(frame_before(joint1), default_frame(world), one(RotMatrix{3}), SVector{3}(translation)) |
| 243 | + attach!(pendulum, world, link1, joint1, joint_pose=before_joint1_to_world) |
| 244 | + |
| 245 | + state = MechanismState(pendulum) |
| 246 | + |
| 247 | + set_configuration!(state, joint1, q0) |
| 248 | + ts, qs, vs = simulate(state, 1., Δt=0.001) |
| 249 | + @test all(all(!isnan, q) for q in qs) |
| 250 | + @test all(all(!isnan, v) for v in vs) |
| 251 | + end |
228 | 252 | end |
0 commit comments