Skip to content

Commit d9a6ea2

Browse files
Merge pull request #27 from ModiaSim/hippmann_planarMotionTest
Add planar motion test
2 parents 95c0f37 + 706f4f9 commit d9a6ea2

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

test/Basic/BoxPlanarMotion.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module BoxPlanarMotionSimulation
2+
3+
using ModiaLang
4+
import Modia3D
5+
using Modia3D.ModiaInterface
6+
7+
BoxPlanarMotion = Model(
8+
world = Object3D(feature=Scene(gravityField=UniformGravityField(g=1.0, n=[0, -1, 0]))),
9+
worldFrame = Object3D(parent=:world,
10+
feature=Visual(shape=CoordinateSystem(length=0.2))),
11+
transx = Object3D(),
12+
transy = Object3D(),
13+
box = Object3D(feature=Solid(shape=Box(lengthX=0.4, lengthY=0.6, lengthZ=0.1),
14+
solidMaterial="Steel",
15+
visualMaterial=VisualMaterial(color="DarkGreen", transparency=0.2))),
16+
prismatic_x = Prismatic(obj1=:world , obj2=:transx, axis=1, s =Var(init=-1.0), v=Var(init=1.0)),
17+
prismatic_y = Prismatic(obj1=:transx, obj2=:transy, axis=2, s =Var(init=-1.0), v=Var(init=2.0)),
18+
revolute_z = Revolute( obj1=:transy, obj2=:box , axis=3, phi=Var(init= 0.0), w=Var(init=3.0))
19+
)
20+
21+
boxPlanarMotion = buildModia3D(BoxPlanarMotion)
22+
23+
model = @instantiateModel(boxPlanarMotion, aliasReduction=false, unitless=true, log=false, logStateSelection=false, logCode=false)
24+
25+
stopTime = 4.0
26+
requiredFinalStates = [1.0, 3.0, -2.0, -1.0, 3.0, 12.0]
27+
simulate!(model, stopTime=stopTime, log=true, logStates=true, requiredFinalStates=requiredFinalStates)
28+
29+
@usingModiaPlot
30+
plot(model, ["prismatic_x.s", "prismatic_y.s", "revolute_z.phi"], figure=1)
31+
32+
end

test/Collision/CollidingSphereWithBunnies.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ ConvexPartitions = Model(
2121
massProperties=massAndGeoSphere, collision=true)),
2222
free = FreeMotion(obj1=:world, obj2=:sphere, r=Var(init=[0.0, 2.0, 0.0])),
2323

24-
2524
bunnySolid = Object3D(parent=:world, feature=Solid(shape =
26-
FileMesh(filename=filenameBunny, scale=[0.1, 0.1, 0.1]), solidMaterial="Steel", collision = true )),
25+
FileMesh(filename=filenameBunny, scale=[0.1, 0.1, 0.1]), solidMaterial="Steel", collision=true )),
2726

2827
bunnyPartitionSolid = Object3D(parent=:world, translation=[0.5, -2.0, 2.0], feature=Solid(shape =
29-
FileMesh(filename = filenameBunny, scale=[0.1, 0.1, 0.1], convexPartition=true), solidMaterial="Steel", collision=true)),
28+
FileMesh(filename=filenameBunny, scale=[0.1, 0.1, 0.1], convexPartition=true), solidMaterial="Steel", collision=true)),
3029
)
3130

3231
convexPartitions = @instantiateModel(buildModia3D(ConvexPartitions), unitless=true, log=false, logStateSelection=false, logCode=false)
3332

3433
stopTime = 1.3
35-
requiredFinalStates = [1.6853549405539088, -1.9603839264641005, 1.5512239899411384, 4.577225786420592, -3.6364005190730575, -1.841958211129179, 16.04685907044025, 0.10996251002097332, 8.10149898250639, 28.66624352831703, 8.399969490696167, 37.24515015558254]
34+
if Sys.iswindows()
35+
requiredFinalStates = [1.6852436731117506, -1.9602009870847892, 1.5537079430670875, 4.576280426855566, -3.6359538989543787, -1.8281828479408744, 16.048751238499957, 0.11284016337050634, 8.101268624505751, 28.746819815200922, 8.39876218585158, 37.19093884427305]
36+
else
37+
requiredFinalStates = [1.6853549405539088, -1.9603839264641005, 1.5512239899411384, 4.577225786420592, -3.6364005190730575, -1.841958211129179, 16.04685907044025, 0.10996251002097332, 8.10149898250639, 28.66624352831703, 8.399969490696167, 37.24515015558254]
38+
end
3639
@time simulate!(convexPartitions, stopTime=stopTime, log=false, logStates=false, logEvents=true, requiredFinalStates=requiredFinalStates)
3740

3841
end

test/includeTests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Test.@testset "Basic" begin
1010
include(joinpath("Basic", "PendulumWithSpring.jl"))
1111
include(joinpath("Basic", "DoublePendulumWithDampers.jl"))
1212
include(joinpath("Basic", "Mobile.jl"))
13+
include(joinpath("Basic", "BoxPlanarMotion.jl"))
1314
include(joinpath("Basic", "ShaftFreeMotion.jl"))
1415
Test.@test_throws LoadError include(joinpath("Basic", "Object3DWithoutParentError.jl"))
1516
end
@@ -21,7 +22,11 @@ Test.@testset "Robot" begin
2122
include(joinpath("Robot", "ServoWithPathAndRevolute.jl"))
2223
include(joinpath("Robot", "YouBotWithSphere.jl"))
2324
Test.@test_skip include(joinpath("Robot", "YouBotPingPong.jl")) # too long computation time
24-
include(joinpath("Robot", "YouBotGripping.jl"))
25+
if Sys.iswindows()
26+
include(joinpath("Robot", "YouBotGripping.jl"))
27+
else
28+
Test.@test_skip include(joinpath("Robot", "YouBotGripping.jl")) # mpr error on linux https://github.com/ModiaSim/PrivateModia3D.jl/issues/142
29+
end
2530
Test.@test_skip include(joinpath("Robot", "YouBotsGripping.jl")) # too long computation time
2631
end
2732

0 commit comments

Comments
 (0)