Skip to content

Commit 01c825d

Browse files
committed
- Fix bugs with respect to Object(..., fixedToParent=false, angularVelocityResolvedInParent=true)
- Fix bugs in some of the newly introduced functions in Frames.jl - Adapt test models for angularVelocityResolvedInParent=true: Basic/BouncingSphere3D.jl, FreeShaft.jl, FreeShaftAdaptiveRotSequence.jl, Collision/TwoCollidingBalls.jl - Add tests for Frames.jl
1 parent ba53c32 commit 01c825d

File tree

11 files changed

+120
-49
lines changed

11 files changed

+120
-49
lines changed

src/Composition/joints/joints.jl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ mutable struct MultibodyData{F <: Modia3D.VarFloatType, TimeType}
8989

9090
# Define hidden model states and copy initial values into eqInfo
9191
path = obj.path * "."
92-
w_init = freeMotion.wResolvedInParent ? resolve2(freeMotion.rot, freeMotion.w, rotation123=freeMotion.isrot123) : freeMotion.w
92+
w_init = freeMotion.wResolvedInParent ? Modia3D.resolve1(freeMotion.rot, freeMotion.w, rotation123=freeMotion.isrot123) : freeMotion.w
9393
freeMotion.ix_hidden_r = Modia.newHiddenState!(partiallyInstantiatedModel, path*"translation" , path*"der(translation)" , freeMotion.r)
9494
freeMotion.ix_hidden_v = Modia.newHiddenState!(partiallyInstantiatedModel, path*"velocity" , path*"der(velocity)" , freeMotion.v)
9595
freeMotion.ix_hidden_rot = Modia.newHiddenState!(partiallyInstantiatedModel, path*"rotation" , path*"der(rotation)" , freeMotion.rot)
@@ -698,25 +698,24 @@ function setStatesHiddenJoints!(m::Modia.SimulationModel{F,TimeType}, mbs::Multi
698698
j3 = freeMotion.ix_hidden_v ; freeMotion.v = SVector{3,F}(x_hidden[j3], x_hidden[j3+1], x_hidden[j3+2])
699699
j4 = freeMotion.ix_hidden_w ; freeMotion.w = SVector{3,F}(x_hidden[j4], x_hidden[j4+1], x_hidden[j4+2])
700700
if freeMotion.wResolvedInParent
701-
freeMotion.w = resolve2(freeMotion.rot, freeMotion.w, rotation123 = freeMotion.isrot123)
701+
freeMotion.w = Modia3D.resolve2(freeMotion.rot, freeMotion.w, rotation123 = freeMotion.isrot123)
702702
end
703703

704-
# Copy some freeMotion state derivatives into der_x_hidden
705-
# der(r) = v
706-
der_x_hidden[j1] = freeMotion.v[1]
707-
der_x_hidden[j1+1] = freeMotion.v[2]
708-
der_x_hidden[j1+2] = freeMotion.v[3]
704+
# der(r) = v
705+
der_x_hidden[j1] = freeMotion.v[1]
706+
der_x_hidden[j1+1] = freeMotion.v[2]
707+
der_x_hidden[j1+2] = freeMotion.v[3]
709708

710-
if Modia.positive(m, freeMotion.iz_rot2, singularitySafetyMargin(freeMotion.rot[2]), freeMotion.str_rot2, nothing)
711-
# freeMotion.rot[2] mapped to range -pi .. pi is either >= 1.5 or <= -1.5 (so comes close to singular position pi/2 = 1.57...)
712-
change_rotSequence!(m, freeMotion, _x, x_hidden)
713-
end
709+
if Modia.positive(m, freeMotion.iz_rot2, singularitySafetyMargin(freeMotion.rot[2]), freeMotion.str_rot2, nothing)
710+
# freeMotion.rot[2] mapped to range -pi .. pi is either >= 1.5 or <= -1.5 (so comes close to singular position pi/2 = 1.57...)
711+
change_rotSequence!(m, freeMotion, _x, x_hidden)
712+
end
714713

715-
# der(rot) = J123or132(rot,isrot123) * w
716-
der_rot = J123or132(freeMotion.rot, freeMotion.isrot123)*freeMotion.w
717-
der_x_hidden[j2] = der_rot[1]
718-
der_x_hidden[j2+1] = der_rot[2]
719-
der_x_hidden[j2+2] = der_rot[3]
714+
# der(rot) = J123or132(rot,isrot123) * w
715+
der_rot = J123or132(freeMotion.rot, freeMotion.isrot123)*freeMotion.w
716+
der_x_hidden[j2] = der_rot[1]
717+
der_x_hidden[j2+1] = der_rot[2]
718+
der_x_hidden[j2+2] = der_rot[3]
720719
end
721720
return nothing
722721
end
@@ -799,7 +798,7 @@ function setHiddenStatesDerivatives!(m::Modia.SimulationModel{F,TimeType}, mbs::
799798
m.der_x_hidden[j1+2] = freeMotion.a[3]
800799

801800
j2 = freeMotion.ix_hidden_w
802-
z = freeMotion.wResolvedInParent ? resolve1(obj.R_rel, freeMotion.z) : freeMotion.z
801+
z = freeMotion.wResolvedInParent ? Modia3D.resolve1(obj.R_rel, freeMotion.z) : freeMotion.z
803802
m.der_x_hidden[j2 ] = z[1]
804803
m.der_x_hidden[j2+1] = z[2]
805804
m.der_x_hidden[j2+2] = z[3]

src/Composition/joints/object3DMotion.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Return a `joint` that describes the free movement of `obj2::`[`Object3D`](@ref)
4646
with respect to `obj1::`[`Object3D`](@ref). The initial position is `r`
4747
(resolved in `obj1`) and the initial orientation is `rot` in [Cardan (Tait–Bryan) angles](https://en.wikipedia.org/wiki/Euler_angles#Chained_rotations_equivalence)
4848
(rotation sequence x-y-z from `obj1` to `obj2`). `v` (resolved in `obj1`) and `w`
49-
(resolved in `obj2`) are the initial cartesian translational and rotational
49+
(resolved in `obj1`) are the initial cartesian translational and rotational
5050
velocity vectors.
5151
"""
5252
mutable struct FreeMotion{F <: Modia3D.VarFloatType} <: Modia3D.AbstractJoint
@@ -75,22 +75,23 @@ mutable struct FreeMotion{F <: Modia3D.VarFloatType} <: Modia3D.AbstractJoint
7575
iqdd_hidden::Int # qdd_hidden[iqdd_hidden:iqdd_hidden+5] are the elements of qdd that are stored in [a,z] if hiddenStates
7676
ix_rot::Int # startIndex of rot with respect to x-vector
7777
str_rot2::String # String to be used for zero crossing logging of iz_rot2
78-
wResolvedInParent::Bool # = true, if w is resolved in obj1 (= parent); = false, if w is resolved in obj2.
78+
wResolvedInParent::Bool # = true: For external interface (w in state, der(w) in der(x)) w is resolved in obj1 (= parent);
79+
# = false: For external interface w is resolved in obj2 (!).
7980

8081
obj1::Modia3D.AbstractObject3D
8182
obj2::Modia3D.AbstractObject3D
8283

8384
ndof::Int
8485

85-
r::SVector{3,F}
86-
rot::SVector{3,F} # cardan angles
86+
r::SVector{3,F} # Relative position vector from obj1 to obj2, resolved in obj1
87+
rot::SVector{3,F} # Rotation angles from obj1 to obj2 with rotation sequence isrot123
8788
isrot123::Bool # = true: rotation sequence x-y-z, otherwise x-z-y
8889

89-
v::SVector{3,F} # = der(r)
90-
w::SVector{3,F} # angular velocity vector
90+
v::SVector{3,F} # = der(r), that is relative velocity of obj2 with respect to obj1, resolved in obj1
91+
w::SVector{3,F} # Relative angular velocity vector of obj2 with respect to obj1, resolved in obj2 (!)
9192

92-
a::SVector{3,F} # = der(v)
93-
z::SVector{3,F} # = der(w)
93+
a::SVector{3,F} # = der(v), that is relative acceleration of obj2 with respect to obj1, resolved in obj1
94+
z::SVector{3,F} # = der(w), that is relative angular velocity of obj2 with respect to obj1, resolved in obj2 (!)
9495

9596
function FreeMotion{F}(; obj1::Modia3D.AbstractObject3D,
9697
obj2::Modia3D.AbstractObject3D,
@@ -126,13 +127,17 @@ mutable struct FreeMotion{F <: Modia3D.VarFloatType} <: Modia3D.AbstractJoint
126127
# " obj2 has a root, but obj1 has not root. This is currently not supported (exchange obj1 and obj2)!")
127128
#end
128129

130+
isrot123 = true
129131
r = Modia3D.convertAndStripUnit(SVector{3,F}, u"m", r)
130132
rot = Modia3D.convertAndStripUnit(SVector{3,F}, u"rad", rot)
131133
v = Modia3D.convertAndStripUnit(SVector{3,F}, u"m/s" , v)
132134
w = Modia3D.convertAndStripUnit(SVector{3,F}, u"rad/s", w)
135+
if wResolvedInParent
136+
# Transform w from obj1 to obj2
137+
w = Modia3D.resolve2(rot, w, rotation123=isrot123)
138+
end
133139
a = Modia3D.ZeroVector3D(F)
134140
z = Modia3D.ZeroVector3D(F)
135-
isrot123 = true
136141
str_rot2 = "singularitySafetyMargin(" * path * ".rotation[2])"
137142

138143
obj2.joint = new(path, hiddenStates, -1, -1, -1, -1, -1, -1, -1, -1, str_rot2, wResolvedInParent, obj1, obj2, 6, r, rot, isrot123, v, w, a, z)

src/Frames/_module.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export qrot1, qrot2, qrot3, qrot123, qrot_e, qrot_nxy, from_R
3131

3232
export resolve1, resolve2, absoluteRotation, relativeRotation, inverseRotation
3333
export planarRotationAngle, eAxis
34+
export angularVelocityResolvedInParentStates!
3435

3536
export Path, t_pathEnd, interpolate, interpolate_r
3637
export skew

src/Frames/rotationMatrix.jl

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ but compute this efficiently by taking the zeros in rot1(..) into account.
5353
"""
5454
@inline function rot1(angle::Number, v::AbstractVector)
5555
(s,c) = sincos(angle)
56-
SVector{3,typeof(s)}(v[1], v[2]*c + v[3]*s, -v[2]*s + v[3]*c)
56+
SVector{3}(v[1], v[2]*c + v[3]*s, -v[2]*s + v[3]*c)
5757
end
5858

5959

@@ -81,7 +81,7 @@ but compute this efficiently by taking the zeros in rot2(..) into account.
8181
"""
8282
@inline function rot2(angle::Number, v::AbstractVector)
8383
(s,c) = sincos(angle)
84-
SVector{3,typeof(s)}(v[1]*c - v[3]*s, v[2], v[1]*s + v[3]*c)
84+
SVector{3}(v[1]*c - v[3]*s, v[2], v[1]*s + v[3]*c)
8585
end
8686

8787

@@ -101,15 +101,15 @@ end
101101

102102

103103
"""
104-
Modia3D.rot3(angle::F,v::AbstractVector) where F
104+
Modia3D.rot3(angle,v::AbstractVector)
105105
106106
Return in principal Modia3D.rot3(angle)*v,
107107
but compute this efficiently by taking the zeros in rot3(..) into account.
108108
`angle` can be provided in radian or in degree, e.g. `using Unitful; Modia3D.rot3(90u"°", v)`.
109109
"""
110110
@inline function rot3(angle::Number, v::AbstractVector)
111111
(s,c) = sincos(angle)
112-
SVector{3,typeof(s)}(c*v[1] + s*v[2], -v[1]*s + v[2]*c, v[3])
112+
SVector{3}(c*v[1] + s*v[2], -v[1]*s + v[2]*c, v[3])
113113
end
114114

115115

@@ -209,13 +209,15 @@ vector `v1::SVector{3,F}` (vector resolved in frame 1) given
209209
210210
- Rotation matrix `R::SMatrix{3,3,F,9}` (rotate frame 1 into frame 2) or
211211
- Quaternion vector `q::SVector{4,F}` (rotate frame 1 into frame 2) or
212-
- Angles vector `rotation::SVector{3,F}` (= rotation123 ? [angleX, angleY, angleZ] : [angleX, angleZ, angleY]).
212+
- Angles vector `rotation::AbstractVector`
213+
(rotation123=true: rotate around X with rotation[1], around Y with rotation[2], around Z with rotation[3];
214+
rotation123=false: rotate around X with rotation[1], around Z with rotation[2], around Y with rotation[3]).
213215
"""
214216
resolve1(R::SMatrix{3,3,F,9}, v2::SVector{3,F}) where F <: Modia3D.VarFloatType = R'*v2
215217
resolve1(R::SMatrix{3,3,F,9}, v2::AbstractVector) where F <: Modia3D.VarFloatType = R'*SVector{3,F}(v2)
216-
resolve1(rotation::SVector{3,F}, v2::AbstractVector; rotation123=true) where F <: Modia3D.VarFloatType =
217-
rotation123 ? rot1(rotation[1], rot2(rotation[2], rot3(rotation[3],v2))) :
218-
rot1(rotation[1], rot3(rotation[3], rot2(rotation[2],v2)))
218+
resolve1(rotation::AbstractVector, v2::AbstractVector; rotation123=true) where F <: Modia3D.VarFloatType =
219+
rotation123 ? rot1(-rotation[1], rot2(-rotation[2], rot3(-rotation[3],v2))) :
220+
rot1(-rotation[1], rot3(-rotation[2], rot2(-rotation[3],v2)))
219221

220222

221223
"""
@@ -228,13 +230,27 @@ vector `v2::SVector{3,F}` (vector resolved in frame 2) given
228230
229231
- Rotation matrix `R::SMatrix{3,3,F,9}` (rotate frame 1 into frame 2) or
230232
- Quaternion vector `q::SVector{4,F}` (rotate frame 1 into frame 2) or
231-
- Angles vector `rotation::SVector{3,F}` (= rotation123 ? [angleX, angleY, angleZ] : [angleX, angleZ, angleY]).
233+
- Angles vector `rotation::AbstractVector`
234+
(rotation123=true: rotate around X with rotation[1], around Y with rotation[2], around Z with rotation[3];
235+
rotation123=false: rotate around X with rotation[1], around Z with rotation[2], around Y with rotation[3]).
232236
"""
233237
resolve2(R::SMatrix{3,3,F,9}, v1::SVector{3,F}) where F <: Modia3D.VarFloatType = R*v1
234238
resolve2(R::SMatrix{3,3,F,9}, v1::AbstractVector) where F <: Modia3D.VarFloatType = R*SVector{3,F}(v1)
235-
resolve2(rotation::SVector{3,F}, v1::AbstractVector; rotation123=true) where F <: Modia3D.VarFloatType =
239+
resolve2(rotation::AbstractVector, v1::AbstractVector; rotation123=true) where F <: Modia3D.VarFloatType =
236240
rotation123 ? rot3(rotation[3], rot2(rotation[2], rot1(rotation[1], v1))) :
237-
rot2(rotation[2], rot3(rotation[3], rot1(rotation[1], v1)))
241+
rot2(rotation[3], rot3(rotation[2], rot1(rotation[1], v1)))
242+
243+
244+
"""
245+
Modia3D.angularVelocityResolvedInParentStates!(states, startIndexRotation, rotation123)
246+
"""
247+
function angularVelocityResolvedInParentStates!(states::AbstractVector, startIndexRotation::Int, rotation123::Bool)::Nothing
248+
rotation = states[startIndexRotation:startIndexRotation+2]
249+
w2 = states[startIndexRotation+3:startIndexRotation+5]
250+
states[startIndexRotation+3:startIndexRotation+5] = Modia3D.resolve1(rotation, w2, rotation123=rotation123)
251+
return nothing
252+
end
253+
238254

239255

240256
"""

test/Basic/BouncingSphere3D.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BouncingSphere = Model3D(
99
visualMaterial=VisualMaterial(color="DarkGreen"),
1010
solidMaterial="Steel",
1111
collision=true)),
12-
sphere = Object3D(parent=:world, fixedToParent=false, translation=[0.0, 1.0, 0.0],
12+
sphere = Object3D(parent=:world, fixedToParent=false, translation=[0.0, 1.0, 0.0], angularVelocityResolvedInParent=true,
1313
feature=Solid(shape=Sphere(diameter=0.2),
1414
visualMaterial=VisualMaterial(color="Blue"),
1515
solidMaterial="Steel",
@@ -18,7 +18,9 @@ BouncingSphere = Model3D(
1818
)
1919

2020
bouncingSphere = @instantiateModel(BouncingSphere, unitless=true, logCode=true)
21-
simulate!(bouncingSphere, stopTime=2.2, dtmax=0.1, log=true, logStates=true)
21+
22+
requiredFinalStates = [-1.1158498420134682e-7, 0.09999999283736953, 1.9605796328352922e-10, -1.3226335283305713e-12, 3.726293803759173e-13, 6.442335795625085e-16, -4.97188563948566e-9, 6.3453729183502065e-15, -2.8482188606342696e-6, 6.351235882032115e-15, -4.677163261435682e-20, 1.3039308706792498e-11]
23+
simulate!(bouncingSphere, stopTime=2.2, dtmax=0.1, log=true, logStates=true, requiredFinalStates=requiredFinalStates)
2224
printResultInfo(bouncingSphere)
2325

2426
@usingModiaPlot

test/Basic/FreeShaft.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Shaft = Model(
99
world = Object3D(feature=Scene(gravityField=UniformGravityField(g=0.3, n=[0, 0, -1]))),
1010
worldFrame = Object3D(parent=:world,
1111
feature=Visual(shape=CoordinateSystem(length=:Diameter))),
12-
shaft = Object3D(parent=:world, fixedToParent=false,
12+
shaft = Object3D(parent=:world, fixedToParent=false, angularVelocityResolvedInParent=true,
1313
feature=Solid(shape=Cylinder(axis=3, diameter=:Diameter, length=:Length),
1414
massProperties=MassProperties(; mass=84.7154, Ixx=7.2711, Iyy=7.2711, Izz=0.4230),
1515
visualMaterial=:(visualMaterial))),
@@ -18,7 +18,7 @@ Shaft = Model(
1818
model = Model3D(
1919
shaft = Shaft | Map(Length=1.0, Diameter=0.2, shaft = Map(velocity=[0.0, 0.1, 0.6],
2020
rotation=[30, 20, 10]u"°",
21-
angularVelocity=[1.0, 2.0, 3.0], angularVelocityResolvedInParent=false)
21+
angularVelocity=Modia3D.resolve1([30, 20, 10]u"°",[1.0, 2.0, 3.0]), angularVelocityResolvedInParent=true)
2222
)
2323
)
2424
#@showModel model
@@ -29,6 +29,7 @@ shaft = @instantiateModel(model, unitless=true, log=false, logStateSelection=fal
2929

3030
stopTime = 5.0
3131
requiredFinalStates=[-1.7224720653038268e-14, 0.4999999999999575, -0.750000016852883, -1.5681975307975595e-14, 0.0999999999999862, -0.8999999999999555, 12.518049838490617, -0.9018643787079454, 13.979844144766544, 2.0096818051930816, -0.9803470582617598, 2.9999999999999933]
32+
Modia3D.angularVelocityResolvedInParentStates!(requiredFinalStates, 7, true)
3233
simulate!(shaft, stopTime=stopTime, log=true, logStates=false, requiredFinalStates=requiredFinalStates)
3334

3435
@usingModiaPlot

test/Basic/FreeShaftAdaptiveRotSequence.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@ Shaft = Model3D(
1313
shaft = Object3D(parent = :world, fixedToParent = false,
1414
rotation=[30.0, 90.0, 10.0]u"°",
1515
velocity=[0.0, 0.1, 0.0]u"m/s",
16-
angularVelocity=[-2.0, 0.0, 0.0]u"rad/s", angularVelocityResolvedInParent=false,
16+
angularVelocity=Modia3D.resolve1([30.0, 90.0, 10.0]u"°", [-2.0, 0.0, 0.0]u"rad/s"), angularVelocityResolvedInParent=true,
1717
feature=Solid(shape=Cylinder(axis=3, diameter=:Diameter, length=:Length),
1818
massProperties=MassProperties(; mass=84.7154, Ixx=7.2711, Iyy=7.2711, Izz=0.4230),
1919
visualMaterial=:(visualMaterial))),
2020
shaftFrame = Object3D(parent=:shaft, feature=Visual(shape=CoordinateSystem(length=0.4))),
2121
)
2222

23+
2324
shaft = @instantiateModel(Shaft, unitless=true, log=false, logStateSelection=false, logCode=false)
2425

2526
stopTime = 7.0
2627
dtmax = 0.1
2728
#requiredFinalStates = [0.0, 0.7, -7.350074420637136, 0.6981317007977381, 1.4336293856408397, 1.5707963267949017, 0.0, 0.1, -2.1, -2.0, 0.0, 0.0]
2829
requiredFinalStates = [0.0, 0.7, -7.350074420637136, 0.0, 0.1, -2.1, 0.6981317007977381, 1.4336293856408397, 1.5707963267949017, -2.0, 0.0, 0.0]
29-
simulate!(shaft, stopTime=stopTime, dtmax=dtmax, log=true, logEvents=false, logStates=false, requiredFinalStates=requiredFinalStates)
30+
Modia3D.angularVelocityResolvedInParentStates!(requiredFinalStates, 7, false)
31+
simulate!(shaft, stopTime=stopTime, dtmax=dtmax, log=true, logEvents=true, logStates=false, requiredFinalStates=requiredFinalStates)
3032
#printResultInfo(shaft)
3133

3234
@usingModiaPlot
33-
plot(shaft, ["shaft.rotation", "shaft.rotation123", "shaft.angularVelocity", "shaft.translation", "shaft.velocity"], figure=1)
35+
plot(shaft, ["shaft.rotation", "shaft.rotation123", "shaft.angularVelocity", "shaft.translation", "shaft.velocity"], figure=2)
3436

3537
end

test/Basic/Pendulum.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Pendulum = Model3D(
1010
)
1111

1212
pendulum = @instantiateModel(Pendulum, unitless=true, log=false, logDetails=false, logCode=true, logStateSelection=false, logCalculations=false)
13-
simulate!(pendulum, stopTime=3.0, log=true)
13+
requiredFinalStates = [5.970529829666215, -1.1395482781332746]
14+
simulate!(pendulum, stopTime=3.0, log=true, requiredFinalStates = requiredFinalStates)
1415

1516
@usingModiaPlot
1617
plot(pendulum, "rev.phi")

test/Collision/TwoCollidingBalls.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ collidingBalls = Model3D(
3131
ball1 = Object3D(parent=:world, fixedToParent=false,
3232
translation = [-1.3, 0.0, diameter/2],
3333
velocity = [3.0, 0.0, 0.0],
34-
rotation = [pi/2, 0.0, 0.0],
34+
rotation = [pi/2, 0.0, 0.0], angularVelocityResolvedInParent=true,
3535
feature=Solid(shape=Sphere(diameter=diameter),
3636
solidMaterial="BilliardBall",
3737
visualMaterial=vmatSolids,
3838
collision=true)),
3939

4040
ball2 = Object3D(parent=:world, fixedToParent=false,
4141
translation = [0.0, 0.0, diameter/2],
42-
rotation = [pi/2, 0.0, 0.0],
42+
rotation = [pi/2, 0.0, 0.0], angularVelocityResolvedInParent=true,
4343
feature=Solid(shape=Sphere(diameter=diameter),
4444
solidMaterial="BilliardBall",
4545
visualMaterial=vmatSolids,
@@ -50,10 +50,14 @@ twoCollidingBalls = @instantiateModel(collidingBalls, unitless=true, log=false,
5050

5151
stopTime = 1.5
5252
tolerance = 1e-6
53+
dtmax = 0.1
5354
requiredFinalStates = [0.4489974852019629, 4.971482124288075e-6, 0.029996861274764766, 0.5336096206429409, 4.775435383850775e-6, -8.566849073992856e-7, 1.5708013764495665, 1.2298784775382833e-5, -55.4441088791202, -6.408457808447407e-5, -9.894396552324208e-5, -17.78647176388158, 1.4032405177409832, -4.464837913922324e-6, 0.029997744288682248, 1.4383823207541608, -4.574293232521244e-6, -2.3103945635420407e-6, 1.570796533109225, 1.2115305686199998e-8, -44.07171252097457, 0.00015344214722251976, 2.5704782290946986e-6, -47.9463685248874]
54-
simulate!(twoCollidingBalls, stopTime=stopTime, tolerance=tolerance, log=true, logStates=false, logEvents=false, requiredFinalStates=requiredFinalStates)
55+
Modia3D.angularVelocityResolvedInParentStates!(requiredFinalStates, 7, true)
56+
Modia3D.angularVelocityResolvedInParentStates!(requiredFinalStates, 19, true)
57+
simulate!(twoCollidingBalls, stopTime=stopTime, tolerance=tolerance, dtmax=dtmax, log=true, logStates=true, logEvents=true, requiredFinalStates=requiredFinalStates)
5558

5659
@usingModiaPlot
5760
plot(twoCollidingBalls, ["ball1.translation" "ball1.rotation"; "ball1.velocity" "ball1.angularVelocity"], figure=1)
61+
plot(twoCollidingBalls, ["ball2.translation" "ball2.rotation"; "ball2.velocity" "ball2.angularVelocity"], figure=2)
5862

5963
end

0 commit comments

Comments
 (0)