|
1 | 1 | @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, |
7 | 7 | spring=30.0)
|
8 | 8 |
|
9 | 9 | initialize!(mech, :quadruped)
|
10 | 10 |
|
11 | 11 | try
|
12 |
| - storage = simulate!(mech, 5.0, |
13 |
| - record=true, |
| 12 | + storage = simulate!(mech, 5.0, |
| 13 | + record=true, |
14 | 14 | verbose=false)
|
15 | 15 | @test true
|
16 | 16 | catch
|
|
20 | 20 |
|
21 | 21 | @testset "Behavior: Box toss" begin
|
22 | 22 | 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, |
26 | 26 | friction_coefficient = 0.1)
|
27 | 27 |
|
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], |
31 | 31 | ω=[5.0, 4.0, 2.0] .* timestep)
|
32 |
| - storage = simulate!(mech, 5.0, |
| 32 | + storage = simulate!(mech, 5.0, |
33 | 33 | record=true,
|
34 |
| - opts=SolverOptions(btol=1e-6, rtol=1e-6, |
| 34 | + opts=SolverOptions(btol=1e-6, rtol=1e-6, |
35 | 35 | verbose=false))
|
36 | 36 |
|
37 | 37 | @test norm(storage.v[1][end], Inf) < 1e-12
|
|
44 | 44 | # Mechanism
|
45 | 45 | timestep = 0.10
|
46 | 46 | mech = Dojo.get_fourbar(
|
47 |
| - model="fourbar", |
| 47 | + model="fourbar", |
48 | 48 | 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]) |
52 | 52 | loopjoints = mech.joints[end:end]
|
53 | 53 | Dojo.root_to_leaves_ordering(mech) == [2, 7, 3, 6, 1, 8, 4, 9]
|
54 | 54 |
|
|
65 | 65 | @test norm(min_coords[5] - (min_coords[2] - min_coords[1]), Inf) < 1.0e-5
|
66 | 66 | end
|
67 | 67 | 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