Skip to content

Commit 536fd75

Browse files
Add ContactResult test model
- Add test model BouncingSphereContactResults.jl.
1 parent d750083 commit 536fd75

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module BouncingSphereContactResultsSimulation
2+
3+
using Modia3D
4+
5+
BouncingSphere = Model3D(
6+
boxHeigth = 0.1,
7+
groundMaterial = VisualMaterial(color="DarkGreen", transparency=0.5),
8+
gravField = UniformGravityField(g=9.81, n=[0, -1, 0]),
9+
world = Object3D(feature=Scene(gravityField=:gravField,
10+
visualizeFrames=false,
11+
defaultFrameLength=0.2,
12+
enableContactDetection=true,
13+
visualizeContactPoints=true)),
14+
worldFrame = Object3D(parent=:world, feature=Visual(shape=CoordinateSystem(length=0.5))),
15+
ground = Object3D(parent=:world,
16+
translation=:[0.0, -boxHeigth/2, 0.0],
17+
feature=Solid(shape=Box(lengthX=2.0, lengthY=:boxHeigth, lengthZ=0.5),
18+
visualMaterial=:groundMaterial,
19+
solidMaterial="Steel",
20+
collision=true)),
21+
sphere = Object3D(parent=:world, fixedToParent=false,
22+
translation=[-0.5, 0.3, 0.0],
23+
velocity=[1.0, 0.0, 0.0],
24+
feature=Solid(shape=Sphere(diameter=0.2),
25+
visualMaterial=VisualMaterial(color="Blue"),
26+
solidMaterial="Steel",
27+
massProperties=MassPropertiesFromShapeAndMass(mass=10000.0),
28+
collision=true)),
29+
result = ContactResult(object1=:sphere, object2=:ground, objectCoordinateRef=:ground)
30+
)
31+
32+
bouncingSphere = @instantiateModel(BouncingSphere, unitless=true, log=false, logStateSelection=false, logCode=false, FloatType=Float64)
33+
34+
stopTime = 1.5
35+
dtmax = 0.05
36+
tolerance = 1e-8
37+
requiredFinalStates = [0.6190964322303429, 0.09989803187140613, 0.0, 0.7018335184646917, -0.00011551585213889106, 0.0, 0.0, 0.0, -9.171436344350457, 0.0, 0.0, -7.0240720401621495]
38+
simulate!(bouncingSphere, stopTime=stopTime, tolerance=tolerance, dtmax=dtmax, log=true, logStates=false, logEvents=true,
39+
requiredFinalStates_atol=1e-6, requiredFinalStates=requiredFinalStates)
40+
41+
@usingModiaPlot
42+
plot(bouncingSphere, ["result.penetration", "result.penetrationVelocity", "result.tangentialVelocity", "result.angularVelocity", "result.normalForce", "result.tangentialForce", "result.torque"], figure=1)
43+
plot(bouncingSphere, ["result.positionVector", "result.normalVector", "result.forceVector", "result.torqueVector"], figure=2)
44+
45+
end

test/Robot/YouBotSphereTransport.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,7 @@ youbot = @instantiateModel(youbotModel, unitless=true, logCode=false, log=false)
532532

533533
stopTime = 13.5
534534
tolerance = 1e-7
535-
# use boxes instead of FileMesh for better performance
536-
if Sys.iswindows()
537-
requiredFinalStates = [3.1415947353156977, 2.4404618792441014e-6, 0.06413101847025342, -0.38051837261409877, 1.5066656031419667, 0.38051766101104056, 0.08493817930077076, -0.5038810237109801, -4.6660513554873775e-7, 3.752739122664999e-7, 0.02640050697959681, -0.05767990246020697, -0.38561153991690283, -0.13530700791021252, 0.003352929911771347, -0.1332188913735816, 0.04978725220079851, -6.996407090545839e-6, -0.7775608475001248, 0.005107163857175746, 0.38015816381775924, 0.04903299043458591, 4.3039218890990144e-6, 0.10223649086921456, -0.23251977356265563, 0.5671780375371024, 6.409469280850812, 5.535728438671193e-7, 0.5044004851046952, -2.473504004121177e-6]
538-
elseif Sys.isapple()
539-
requiredFinalStates = missing
540-
else
541-
requiredFinalStates = [3.141594735312716, 2.440457544603476e-6, 0.06413101847181349, -0.380518372597451, 1.5066656031498458, 0.3805176609510743, 0.08493817930222113, -0.5038810238174551, -4.666083661539158e-7, 3.7522126012581574e-7, 0.026400488779754015, -0.057679898615238055, -0.3856115354698501, -0.1353070539098794, 0.0033529207102979517, -0.13321886490666132, 0.049787252111476124, -6.996240368087093e-6, -0.7775614019840636, 0.005107163901554179, 0.38015912423821296, 0.04903348978501739, 4.303738169808239e-6, 0.1022367696490673, -0.2408237298542479, 0.6183371828465237, 6.424368692503729, 5.538288842857016e-7, 0.5044004851850659, -2.4739225351517005e-6]
542-
end
543-
535+
requiredFinalStates = [3.1415947353156977, 2.4404618792441014e-6, 0.06413101847025342, -0.38051837261409877, 1.5066656031419667, 0.38051766101104056, 0.08493817930077076, -0.5038810237109801, -4.6660513554873775e-7, 3.752739122664999e-7, 0.02640050697959681, -0.05767990246020697, -0.38561153991690283, -0.13530700791021252, 0.003352929911771347, -0.1332188913735816, 0.04978725220079851, -6.996407090545839e-6, -0.7775608475001248, 0.005107163857175746, 0.38015816381775924, 0.04903299043458591, 4.3039218890990144e-6, 0.10223649086921456, -0.23251977356265563, 0.5671780375371024, 6.409469280850812, 5.535728438671193e-7, 0.5044004851046952, -2.473504004121177e-6]
544536

545537
simulate!(youbot, stopTime=stopTime, tolerance=tolerance, requiredFinalStates_rtol=0.01, requiredFinalStates_atol=0.01, log=true, logStates=false, logParameters=false, requiredFinalStates=requiredFinalStates, logEvents=false)
546538

test/includeTests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ end
7171
Test.@testset "Collision" begin
7272
include(joinpath("Collision", "BouncingSphere.jl"))
7373
include(joinpath("Collision", "BouncingSphereFree.jl"))
74+
include(joinpath("Collision", "BouncingSphereContactResults.jl"))
7475
include(joinpath("Collision", "BouncingEllipsoid.jl"))
7576
include(joinpath("Collision", "BouncingEllipsoidOnSphere.jl"))
7677
include(joinpath("Collision", "TwoCollidingBalls.jl"))

0 commit comments

Comments
 (0)