Skip to content

Commit 1862516

Browse files
committed
wheel test updates
1 parent f12ceeb commit 1862516

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

test/test_wheels.jl

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ end
3131

3232
@named worldwheel = WheelInWorld()
3333

34+
ssys = multibody(worldwheel)
35+
3436
defs = Dict([
3537
])
3638

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))
3840
@test prob[collect(worldwheel.wheel.wheeljoint.der_angles)] == prob[collect(worldwheel.wheel.wheeljoint.der_angles)]
3941

4042
sol = solve(prob, Tsit5(), abstol=1e-8, reltol=1e-8)
@@ -79,51 +81,49 @@ using LinearAlgebra
7981
end
8082

8183
@named worldwheel = WheelInWorldWithSurface(surface = (x,z)->0)
82-
worldwheel = complete(worldwheel)
84+
ssys = multibody(worldwheel)
8385

84-
# pars = collect(worldwheel.world.n) .=> [0,0,-1];
86+
# pars = collect(ssys.world.n) .=> [0,0,-1];
8587
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];
9193
# collect(D.(cwheel.wheel.angles)) .=> [0, 5, 1]
9294
])
9395

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))
9697
sol = solve(prob, FBDF(autodiff=false), abstol=1e-8, reltol=1e-8)
9798
@test SciMLBase.successful_retcode(sol)
9899
# 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
100101

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)
102103

103104
@named worldwheel = WheelInWorldWithSurface(surface = (x,z)->x)
104-
worldwheel = complete(worldwheel)
105+
ssys = multibody(worldwheel)
105106

106107
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];
112113
])
113114

114-
ssys = multibody(worldwheel)
115115
prob = ODEProblem(ssys, defs, (0, 4))
116116
sol = solve(prob, FBDF(autodiff=false), abstol=1e-8, reltol=1e-8)
117117
# plot(sol)
118118
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
120120

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
122122
@test norm(dd .- dd[1]) < 1e-10 # constant acceleration
123123
@test abs(dd[1]) < 9.81
124124
@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)
127127

128128

129129

@@ -165,7 +165,7 @@ import ModelingToolkitStandardLibrary.Blocks
165165
end
166166
@named model = WheelWithAxis()
167167
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))
169169
@test_skip begin # Singular linear system
170170
sol = solve(prob, Rodas4(autodiff=false), abstol=1e-8, reltol=1e-8)
171171
@test_broken !all(iszero, sol.u)
@@ -175,6 +175,8 @@ end
175175
# ==============================================================================
176176
## RollingWheelSet
177177
# ==============================================================================
178+
import ModelingToolkitStandardLibrary.Mechanical.Rotational
179+
import ModelingToolkitStandardLibrary.Blocks
178180
@component function DrivingWheelSet(; name)
179181
systems = @named begin
180182
sine1 = Blocks.Sine(frequency=1, amplitude=2)

0 commit comments

Comments
 (0)