Skip to content

Commit d6c35bd

Browse files
committed
adding dhanibekov behavior test
1 parent c485650 commit d6c35bd

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

test/behaviors.jl

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
@testset "Behavior: Quadruped simulation" begin
2-
mech = get_mechanism(:quadruped,
3-
timestep=0.05,
4-
gravity=-9.81,
5-
friction_coefficient=0.8,
6-
damper=1000.0,
2+
mech = get_mechanism(:quadruped,
3+
timestep=0.05,
4+
gravity=-9.81,
5+
friction_coefficient=0.8,
6+
damper=1000.0,
77
spring=30.0)
88

99
initialize!(mech, :quadruped)
1010

1111
try
12-
storage = simulate!(mech, 5.0,
13-
record=true,
12+
storage = simulate!(mech, 5.0,
13+
record=true,
1414
verbose=false)
1515
@test true
1616
catch
@@ -20,18 +20,18 @@ end
2020

2121
@testset "Behavior: Box toss" begin
2222
for timestep in [0.10, 0.05, 0.01, 0.005]
23-
mech = get_mechanism(:box,
24-
timestep=timestep,
25-
gravity=-9.81,
23+
mech = get_mechanism(:box,
24+
timestep=timestep,
25+
gravity=-9.81,
2626
friction_coefficient = 0.1)
2727

28-
initialize!(mech, :box,
29-
x=[0.0, 0.0, 0.5],
30-
v=[1.0, 1.5, 1.0],
28+
initialize!(mech, :box,
29+
x=[0.0, 0.0, 0.5],
30+
v=[1.0, 1.5, 1.0],
3131
ω=[5.0, 4.0, 2.0] .* timestep)
32-
storage = simulate!(mech, 5.0,
32+
storage = simulate!(mech, 5.0,
3333
record=true,
34-
opts=SolverOptions(btol=1e-6, rtol=1e-6,
34+
opts=SolverOptions(btol=1e-6, rtol=1e-6,
3535
verbose=false))
3636

3737
@test norm(storage.v[1][end], Inf) < 1e-12
@@ -44,11 +44,11 @@ end
4444
# Mechanism
4545
timestep = 0.10
4646
mech = Dojo.get_fourbar(
47-
model="fourbar",
47+
model="fourbar",
4848
timestep=timestep)
49-
Dojo.initialize!(mech, :fourbar,
50-
angle=0.1,
51-
angular_velocity=[3.0, -3.0])
49+
Dojo.initialize!(mech, :fourbar,
50+
angle=0.1,
51+
angular_velocity=[3.0, -3.0])
5252
loopjoints = mech.joints[end:end]
5353
Dojo.root_to_leaves_ordering(mech) == [2, 7, 3, 6, 1, 8, 4, 9]
5454

@@ -65,3 +65,23 @@ end
6565
@test norm(min_coords[5] - (min_coords[2] - min_coords[1]), Inf) < 1.0e-5
6666
end
6767
end
68+
69+
@testset "Behavior: Tennis Racket" begin
70+
# Simulation
71+
timestep=0.01
72+
gravity=0.0
73+
mech = get_mechanism(:dzhanibekov,
74+
timestep=timestep,
75+
gravity=gravity);
76+
77+
# Simulate
78+
initialize_dzhanibekov!(mech,
79+
angular_velocity=[15.0; 0.01; 0.0])
80+
storage = simulate!(mech, 4.00,
81+
record=true,
82+
verbose=false)
83+
84+
# The x position of the side body oscillate between a positive and negative
85+
# value when we observe the Dhanibekov effect. Otherwise, it always remains in the positive position.
86+
@test minimum([x[1] for x in storage.x[2]]) < -0.05
87+
end

0 commit comments

Comments
 (0)