|
31 | 31 |
|
32 | 32 | @named worldwheel = WheelInWorld() |
33 | 33 |
|
| 34 | +ssys = multibody(worldwheel) |
| 35 | + |
34 | 36 | defs = Dict([ |
35 | 37 | ]) |
36 | 38 |
|
37 | | -prob = ODEProblem(ssys, defs, (0, 4); guesses, missing_guess_value = MissingGuessValue.Random(Random.GLOBAL_RNG)) |
| 39 | +prob = ODEProblem(ssys, defs, (0, 4); missing_guess_value = MissingGuessValue.Random(Random.GLOBAL_RNG)) |
38 | 40 | @test prob[collect(worldwheel.wheel.wheeljoint.der_angles)] == prob[collect(worldwheel.wheel.wheeljoint.der_angles)] |
39 | 41 |
|
40 | 42 | sol = solve(prob, Tsit5(), abstol=1e-8, reltol=1e-8) |
@@ -79,51 +81,49 @@ using LinearAlgebra |
79 | 81 | end |
80 | 82 |
|
81 | 83 | @named worldwheel = WheelInWorldWithSurface(surface = (x,z)->0) |
82 | | -worldwheel = complete(worldwheel) |
| 84 | +ssys = multibody(worldwheel) |
83 | 85 |
|
84 | | -# pars = collect(worldwheel.world.n) .=> [0,0,-1]; |
| 86 | +# pars = collect(ssys.world.n) .=> [0,0,-1]; |
85 | 87 | defs = Dict([ |
86 | | - # collect(worldwheel.world.n) .=> [0,0,-1]; |
87 | | - worldwheel.wheel.body.r_0[1] => 0.2; |
88 | | - worldwheel.wheel.body.r_0[2] => 0.3; |
89 | | - worldwheel.wheel.body.r_0[3] => 0.2; |
90 | | - collect(worldwheel.wheel.wheeljoint.der_angles) .=> [0, -5, -1]; |
| 88 | + # collect(ssys.world.n) .=> [0,0,-1]; |
| 89 | + ssys.wheel.body.r_0[1] => 0.2; |
| 90 | + ssys.wheel.body.r_0[2] => 0.3; |
| 91 | + ssys.wheel.body.r_0[3] => 0.2; |
| 92 | + collect(ssys.wheel.wheeljoint.der_angles) .=> [0, -5, -1]; |
91 | 93 | # collect(D.(cwheel.wheel.angles)) .=> [0, 5, 1] |
92 | 94 | ]) |
93 | 95 |
|
94 | | -ssys = multibody(worldwheel) |
95 | | -prob = ODEProblem(ssys, defs, (0, 4)) |
| 96 | +prob = ODEProblem(ssys, defs, (0, 4); missing_guess_value = MissingGuessValue.Random(Random.GLOBAL_RNG)) |
96 | 97 | sol = solve(prob, FBDF(autodiff=false), abstol=1e-8, reltol=1e-8) |
97 | 98 | @test SciMLBase.successful_retcode(sol) |
98 | 99 | # first(Multibody.render(worldwheel, sol, 0, show_axis=true)) |
99 | | -@test sol(4, idxs=[worldwheel.wheel.x; worldwheel.wheel.z]) ≈ [0.162547, -2.23778] atol=1e-3 |
| 100 | +@test sol(4, idxs=[ssys.wheel.x; ssys.wheel.z]) ≈ [0.162547, -2.23778] atol=1e-3 |
100 | 101 |
|
101 | | -@test all(norm.(sol[collect(worldwheel.wheel.wheeljoint.e_lat_0)]) .≈ 1) |
| 102 | +@test all(norm.(sol[collect(ssys.wheel.wheeljoint.e_lat_0)]) .≈ 1) |
102 | 103 |
|
103 | 104 | @named worldwheel = WheelInWorldWithSurface(surface = (x,z)->x) |
104 | | -worldwheel = complete(worldwheel) |
| 105 | +ssys = multibody(worldwheel) |
105 | 106 |
|
106 | 107 | defs = Dict([ |
107 | | - # collect(worldwheel.world.n) .=> [0,0,-1]; |
108 | | - worldwheel.wheel.body.r_0[1] => 0.0; |
109 | | - worldwheel.wheel.body.r_0[2] => 0.3/sqrt(2); |
110 | | - worldwheel.wheel.body.r_0[3] => 0.0; |
111 | | - collect(worldwheel.wheel.wheeljoint.der_angles) .=> [0, 0, 0]; |
| 108 | + # collect(ssys.world.n) .=> [0,0,-1]; |
| 109 | + ssys.wheel.body.r_0[1] => 0.0; |
| 110 | + ssys.wheel.body.r_0[2] => 0.3/sqrt(2); |
| 111 | + ssys.wheel.body.r_0[3] => 0.0; |
| 112 | + collect(ssys.wheel.wheeljoint.der_angles) .=> [0, 0, 0]; |
112 | 113 | ]) |
113 | 114 |
|
114 | | -ssys = multibody(worldwheel) |
115 | 115 | prob = ODEProblem(ssys, defs, (0, 4)) |
116 | 116 | sol = solve(prob, FBDF(autodiff=false), abstol=1e-8, reltol=1e-8) |
117 | 117 | # plot(sol) |
118 | 118 | tv = 0:0.5:4 |
119 | | -@test sol(tv, idxs=worldwheel.wheel.body.r_0[1]) ≈ sol(tv, idxs=worldwheel.wheel.body.r_0[2]) .- 0.3*sqrt(2) rtol=1e-6 # The sqrt(2) is to account for the shifted contact point at a 45 degree plane |
| 119 | +@test sol(tv, idxs=ssys.wheel.body.r_0[1]) ≈ sol(tv, idxs=ssys.wheel.body.r_0[2]) .- 0.3*sqrt(2) rtol=1e-6 # The sqrt(2) is to account for the shifted contact point at a 45 degree plane |
120 | 120 |
|
121 | | -dd = diff(sol(tv, idxs=worldwheel.wheel.wheeljoint.der_angles[2]).u) # angular acceleration |
| 121 | +dd = diff(sol(tv, idxs=ssys.wheel.wheeljoint.der_angles[2]).u) # angular acceleration |
122 | 122 | @test norm(dd .- dd[1]) < 1e-10 # constant acceleration |
123 | 123 | @test abs(dd[1]) < 9.81 |
124 | 124 | @test abs(dd[1]) > 5 |
125 | | -@test all(norm.(sol[collect(worldwheel.wheel.wheeljoint.e_lat_0)]) .≈ 1) |
126 | | -@test all(norm.(sol[collect(worldwheel.wheel.wheeljoint.e_long_0)]) .≈ 1) |
| 125 | +@test all(norm.(sol[collect(ssys.wheel.wheeljoint.e_lat_0)]) .≈ 1) |
| 126 | +@test all(norm.(sol[collect(ssys.wheel.wheeljoint.e_long_0)]) .≈ 1) |
127 | 127 |
|
128 | 128 |
|
129 | 129 |
|
@@ -165,7 +165,7 @@ import ModelingToolkitStandardLibrary.Blocks |
165 | 165 | end |
166 | 166 | @named model = WheelWithAxis() |
167 | 167 | ssys = multibody(model) |
168 | | -prob = ODEProblem(ssys, [], (0, 4), guesses=Dict([ssys.spin_axis.phi => 0.0])) |
| 168 | +prob = ODEProblem(ssys, [], (0, 4), guesses=Dict([ssys.spin_axis.phi => 0.0]); missing_guess_value = MissingGuessValue.Random(Random.GLOBAL_RNG)) |
169 | 169 | @test_skip begin # Singular linear system |
170 | 170 | sol = solve(prob, Rodas4(autodiff=false), abstol=1e-8, reltol=1e-8) |
171 | 171 | @test_broken !all(iszero, sol.u) |
|
175 | 175 | # ============================================================================== |
176 | 176 | ## RollingWheelSet |
177 | 177 | # ============================================================================== |
| 178 | +import ModelingToolkitStandardLibrary.Mechanical.Rotational |
| 179 | +import ModelingToolkitStandardLibrary.Blocks |
178 | 180 | @component function DrivingWheelSet(; name) |
179 | 181 | systems = @named begin |
180 | 182 | sine1 = Blocks.Sine(frequency=1, amplitude=2) |
|
0 commit comments