|
| 1 | +module InValidCollisionPairingError |
| 2 | + |
| 3 | +using ModiaLang |
| 4 | +import Modia3D |
| 5 | +using Modia3D.ModiaInterface |
| 6 | +using Unitful |
| 7 | + |
| 8 | +vmatRed = Modia3D.VisualMaterial(color="Red") |
| 9 | +vmatGreen = Modia3D.VisualMaterial(color="Green") |
| 10 | +vmatBlue = Modia3D.VisualMaterial(color="Blue") |
| 11 | +vmatGrey = Modia3D.VisualMaterial(color="Grey", transparency=0.5) |
| 12 | + |
| 13 | +BouncingCones = Model( |
| 14 | + boxHeigth = 0.1, |
| 15 | + gravField = UniformGravityField(g=9.81, n=[0, 0, -1]), |
| 16 | + world = Object3D(feature=Scene(gravityField=:gravField, |
| 17 | + visualizeFrames=false, |
| 18 | + defaultFrameLength=0.2, |
| 19 | + enableContactDetection=true, |
| 20 | + animationFile="BouncingCones.json")), |
| 21 | + worldFrame = Object3D(parent=:world, feature=Visual(shape=CoordinateSystem(length=0.5))), |
| 22 | + ground = Object3D(parent=:world, |
| 23 | + translation=:[0.0, 0.0, -boxHeigth/2], |
| 24 | + feature=Solid(shape=Box(lengthX=5.0, lengthY=3.0, lengthZ=:boxHeigth), |
| 25 | + visualMaterial=vmatGrey, |
| 26 | + solidMaterial="DryWood", |
| 27 | + collision=true)), |
| 28 | + frameX = Object3D(parent=:world, |
| 29 | + translation=:[-1.0, -0.5, 1.0], |
| 30 | + rotation=:[-90*u"°", 0.0, -90*u"°"], |
| 31 | + feature=Visual(shape=CoordinateSystem(length=0.5))), |
| 32 | + coneX = Object3D(feature=Solid(shape=Cone(axis=1, diameter=0.4, length=1.0, topDiameter=0.3), |
| 33 | + visualMaterial=vmatRed, |
| 34 | + solidMaterial="BilliardTable", |
| 35 | + collision=true)), |
| 36 | + jointX = FreeMotion(obj1=:frameX, obj2=:coneX, |
| 37 | + r=Var(init=[0.0, 0.0, 0.0]), |
| 38 | + rot=Var(init=[0.0, -60*u"°", 0.0]), |
| 39 | + v=Var(init=[0.0, 1.0, 0.0])), |
| 40 | + frameY = Object3D(parent=:world, |
| 41 | + translation=:[0.0, -0.5, 1.0], |
| 42 | + rotation=:[90*u"°", 90*u"°", 0.0], |
| 43 | + feature=Visual(shape=CoordinateSystem(length=0.5))), |
| 44 | + coneY = Object3D(feature=Solid(shape=Cone(axis=2, diameter=0.4, length=1.0, topDiameter=0.3), |
| 45 | + visualMaterial=vmatGreen, |
| 46 | + solidMaterial="DryWood", |
| 47 | + collision=true)), |
| 48 | + jointY = FreeMotion(obj1=:frameY, obj2=:coneY, |
| 49 | + r=Var(init=[0.0, 0.0, 0.0]), |
| 50 | + rot=Var(init=[0.0, 0.0, -60*u"°"]), |
| 51 | + v=Var(init=[0.0, 0.0, 1.0])), |
| 52 | + frameZ = Object3D(parent=:world, |
| 53 | + translation=:[1.0, -0.5, 1.0], |
| 54 | + feature=Visual(shape=CoordinateSystem(length=0.5))), |
| 55 | + coneZ = Object3D(feature=Solid(shape=Cone(axis=3, diameter=0.4, length=1.0, topDiameter=0.3), |
| 56 | + visualMaterial=vmatBlue, |
| 57 | + solidMaterial="DryWood", |
| 58 | + collision=true)), |
| 59 | + jointZ = FreeMotion(obj1=:frameZ, obj2=:coneZ, |
| 60 | + r=Var(init=[0.0, 0.0, 0.0]), |
| 61 | + rot=Var(init=[-60*u"°", 0.0, 0.0]), |
| 62 | + v=Var(init=[1.0, 0.0, 0.0])) |
| 63 | +) |
| 64 | + |
| 65 | +bouncingCones = @instantiateModel(buildModia3D(BouncingCones), unitless=true, log=false, logStateSelection=false, logCode=false) |
| 66 | + |
| 67 | + |
| 68 | +stopTime = 1.3 |
| 69 | +tolerance = 1e-8 |
| 70 | + |
| 71 | +simulate!(bouncingCones, stopTime=stopTime, tolerance=tolerance, log=true, logStates=true, logEvents=true) |
| 72 | + |
| 73 | +@usingModiaPlot |
| 74 | +plot(bouncingCones, [("jointX.r", "jointY.r", "jointZ.r") ("jointX.rot", "jointY.rot", "jointZ.rot") |
| 75 | + ("jointX.v", "jointY.v", "jointZ.v") ("jointX.w", "jointY.w", "jointZ.w")], figure=1) |
| 76 | + |
| 77 | +end |
0 commit comments