Skip to content

Commit d53b858

Browse files
Merge pull request #96 from ModiaSim/gh_rattlebackTest
Add rattleback test
2 parents a190d90 + 1b77f57 commit d53b858

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
docs/build/
33
docs/site/
44
.vscode/
5+
*.json

test/Collision/Rattleback.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module RattlebackSimulation
2+
3+
using Modia3D
4+
5+
mass = 0.014660765716752368
6+
centerOfMass = [0.0, 0.0, 0.0]
7+
inertiaTensor = [5.864306286700948e-7 0.0 0.0; 0.0 7.623598172711232e-6 0.0; 0.0 0.0 7.623598172711232e-6]
8+
gam = -5 # inertia tensor orientation angle [deg] about vertical axis; sign defines preferred rotation direction
9+
rotMatrix = [cosd(gam) -sind(gam) 0.0; sind(gam) cosd(gam) 0.0; 0.0 0.0 1.0]
10+
inertiaTensor = rotMatrix * inertiaTensor * rotMatrix'
11+
massProps = MassProperties(; mass=mass, centerOfMass=centerOfMass,
12+
Ixx=inertiaTensor[1,1], Iyy=inertiaTensor[2,2], Izz=inertiaTensor[3,3],
13+
Ixy=inertiaTensor[1,2], Iyz=inertiaTensor[2,3], Ixz=inertiaTensor[3,1])
14+
15+
Rattleback = Model(
16+
world = Object3D(feature=Scene(gravityField=UniformGravityField(g=9.81, n=[0, 0, -1]),
17+
nominalLength=0.1,
18+
enableContactDetection=true)),
19+
worldFrame = Object3D(parent=:world, feature=Visual(shape=CoordinateSystem(length=0.05))),
20+
ground = Object3D(parent=:world,
21+
translation=:[0.0, 0.0, -0.005],
22+
feature=Solid(shape=Box(lengthX=0.2, lengthY=0.2, lengthZ=0.01),
23+
visualMaterial=VisualMaterial(color="Grey90", transparency=0.5),
24+
solidMaterial="DryWood",
25+
collision=true)),
26+
ellipsoid = Object3D(feature=Solid(massProperties=massProps,
27+
shape=Ellipsoid(lengthX=0.1, lengthY=0.02, lengthZ=0.02),
28+
visualMaterial=VisualMaterial(color="Blue"),
29+
solidMaterial="DryWood",
30+
collision=true)),
31+
joint = FreeMotion(obj1=:world, obj2=:ellipsoid, r=Var(init=[0.0, 0.0, 0.01]), w=Var(init=[0.0, 0.1, 5.0]))
32+
)
33+
34+
rattleback = @instantiateModel(buildModia3D(Rattleback), unitless=true)
35+
36+
stopTime = 6.0
37+
tolerance = 1e-8
38+
requiredFinalStates = [0.0006643219607533129, -0.0003421523453737833, 0.00999995717824536, 0.0004810494172644089, 0.00013865075493256469, -3.842333721570369e-8, 0.08135690941922864, -0.26163303787420544, -1.2651039117459748, -0.05518153954821725, -0.6191105987556029, -2.2091732972104654]
39+
simulate!(rattleback, stopTime=stopTime, tolerance=tolerance, log=false, requiredFinalStates=requiredFinalStates)
40+
41+
@usingModiaPlot
42+
plot(rattleback, ["joint.r" "joint.rot"; "joint.v" "joint.w"], figure=1)
43+
44+
end

test/Robot/YouBotsGripping.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ Modia3D.PathPlanning.ptpJointSpace(referencePath = referencePath1, positions =[
106106
0.0 0.2 pi/2-0.2 0.0 0.0 diameter-0.002 0.0 0.0 0.0 0.0 0.0 diameter;
107107
0.0 0.2 pi/2-0.2 0.0 0.0 diameter+0.01 0.0 0.0 0.0 0.0 0.0 diameter;
108108
0.0 0.0 pi/2 0.0 0.0 diameter+0.01 0.0 0.0 0.0 0.0 0.0 diameter;
109-
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 0.0 0.0 0.0 diameter
110-
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 pi/2 0.0 0.0 diameter+0.01
111-
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.3 pi/2-0.3 0.0 0.0 diameter+0.01
112-
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.3 pi/2-0.3 0.0 0.0 diameter-0.002
113-
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 pi/2-0.3 0.0 0.0 diameter-0.002
114-
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 0.0 0.0 diameter-0.002
115-
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 1.0 0.0 diameter-0.002
116-
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 1.0 0.0 diameter+0.01
117-
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 0.0 0.0 diameter+0.01
109+
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 0.0 0.0 0.0 diameter;
110+
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 pi/2 0.0 0.0 diameter+0.01;
111+
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.3 pi/2-0.3 0.0 0.0 diameter+0.01;
112+
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.3 pi/2-0.3 0.0 0.0 diameter-0.002;
113+
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 pi/2-0.3 0.0 0.0 diameter-0.002;
114+
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 0.0 0.0 diameter-0.002;
115+
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 1.0 0.0 diameter-0.002;
116+
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 1.0 0.0 diameter+0.01;
117+
0.0 0.0 0.0 0.0 0.0 0.001 pi pi/4 pi/4 0.0 0.0 diameter+0.01;
118118
0.0 0.0 0.0 0.0 0.0 0.001 0.0 0.0 0.0 0.0 0.0 0.01
119119
])
120120

test/includeTests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Test.@testset "Collision" begin
6060
if testsExtend >= normalTests
6161
include(joinpath("Collision", "BouncingSphere2.jl")) # use solver QBDF, Tsit5 with stopTime=2.5s; requiredFinalStates=[0.0, 0.0]
6262
include(joinpath("Collision", "ZeroCrossingIssue.jl"))
63+
include(joinpath("Collision", "Rattleback.jl"))
6364
include(joinpath("Collision", "BouncingCones.jl"))
6465
include(joinpath("Collision", "BouncingFrustums.jl"))
6566
include(joinpath("Collision", "BouncingCapsules.jl"))

0 commit comments

Comments
 (0)