Skip to content

Commit 13e62ce

Browse files
Merge pull request #35 from ModiaSim/an_cleanup
An cleanup
2 parents c14e61c + d7e3d37 commit 13e62ce

File tree

20 files changed

+80
-178
lines changed

20 files changed

+80
-178
lines changed

src/Basics/_module.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ module Basics
1515

1616
export trailingPartOfName
1717

18-
export neps, sign_eps, radToDeg, degToRad
18+
export neps, sign_eps, radToDeg
1919
export getAndCheckFullLibraryPath, getEnvironmentVariable
20-
export zeroMVector, onesMVector, nullMRotation
21-
export ZeroMVector
20+
2221
export normalizeVector, BoundingBox
2322

2423
export readDictOfStructsFromJSON
2524
export listKeys
2625
export deleteItem
2726

2827
export linearMovement
29-
export PositionMVector, RotationMMatrix, assertRotationMatrix
3028

3129
using StaticArrays
3230
using LinearAlgebra

src/Basics/constantsAndFunctions.jl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,8 @@ function normalizeVector(n::SVector{3,Float64})::SVector{3,Float64}
2222
end
2323
end
2424

25-
# MVector / MMatrix
26-
zeroMVector() = MVector{3,Float64}(0.0, 0.0, 0.0)
27-
onesMVector() = MVector{3,Float64}(1.0, 1.0, 1.0)
28-
nullMRotation() = MMatrix{3,3,Float64,9}(1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0)
29-
3025
# Standard constants
31-
const degToRad = pi/180.0
3226
const radToDeg = 180.0/pi
33-
const ZeroMVector = MVector{3,Float64}(0.0,0.0,0.0)
34-
const NoNameDefined = "_NoNameDefined"
35-
36-
37-
# Standard types
38-
const PositionMVector = MVector{3,Float64}
39-
const RotationMMatrix = MMatrix{3,3,Float64,9}
40-
4127

4228
""" mutable struct BoundingBox - Smallest box that contains a visual element"""
4329
mutable struct BoundingBox

src/Composition/_module.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Andrea Neumayr and Martin Otter, [DLR - Institute of System Dynamics and Control
2121
module Composition
2222

2323
export initialize, initAnalysis!, performAnalysis!, closeAnalysis!, visualize!, visualizeWorld!
24-
export updatePosition!, update!, driveJoint!
24+
export updatePosition!, update!
2525
export Object3D
2626
export RotationVariables, RCardan123
2727
export WStartVariables, WCartesian, WCardan123
@@ -51,7 +51,7 @@ export animationData, animationStep
5151

5252
export DLR_Visualization, DLR_Visualization_renderer
5353

54-
export ContactDetectionMPR, ContactDetectionMPR_handler
54+
export ContactDetectionMPR_handler
5555
export initializeContactDetection!, selectContactPairsNoEvent!, selectContactPairsWithEvent!, getDistances!, setComputationFlag, closeContactDetection!
5656

5757
export responseCalculation, print_ModelVariables
@@ -99,6 +99,9 @@ include(joinpath("joints", "Fix.jl"))
9999
include(joinpath("joints", "Revolute.jl"))
100100
include(joinpath("joints", "Prismatic.jl"))
101101

102+
include("contactPairs.jl")
103+
include(joinpath(Modia3D.path, "src", "contactDetection", "ContactDetectionMPR", "ContactDetectionMPR_handler.jl"))
104+
102105
include("scene.jl") # must be included after superObjects.jl
103106
include(joinpath("joints", "joints.jl"))
104107
include(joinpath("joints", "changeJointState.jl"))

src/Composition/contactPairs.jl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
#-------------------------------------- Default Contact Detection -------------------------------
3+
4+
"""
5+
ContactPairs(nzmax, collSuperObjs, noCPairs, dummyObject3D)
6+
7+
Generate a new ContactPairs structure used for communication between the Object3D handler and a ContactDetection handler.
8+
9+
- `DummyObject3D::Modia3D.AbstractObject3DFeature`: A dummy Object3D that can be used in the struct as element of a vector of Object3Ds
10+
to fill the vector with a dummy value of the correct type.
11+
"""
12+
mutable struct ContactPairs
13+
# Solid shapes used in contact detection (provided by Object3D handler)
14+
allowedToMove::Vector{Union{Bool,Nothing}}
15+
dummyObject3D::Modia3D.AbstractObject3DFeature # Dummy Object3D for non-used elements of z-Vector.
16+
17+
# Dimensions
18+
ne::Int # length(collSuperObjs)
19+
nz::Int # length(z)
20+
nzContact::Int # length(z | z has contact) length of z where zi has contact
21+
22+
function ContactPairs(world::Composition.Object3D, AABB::Vector{Vector{Basics.BoundingBox}}, superObjs::Vector{SuperObjsRow},
23+
allowedToMove::Vector{Union{Bool,Nothing}}, visualizeBoundingBox::Bool, nVisualContSupPoints::Int,
24+
visualizeContactPoints::Bool, visualizeSupportPoints::Bool, defaultContactSphereDiameter::Float64)
25+
@assert(length(superObjs) > 0)
26+
@assert(nVisualContSupPoints > 0)
27+
dummyObject3D = Composition.emptyObject3DFeature
28+
29+
lengthCollSuperObjs = length(superObjs)
30+
if lengthCollSuperObjs <= 1
31+
error("There's nothing to collide. All Object3Ds are rigidly connected.")
32+
end
33+
34+
nzContact = 0
35+
nz = 2
36+
37+
if lengthCollSuperObjs > 2
38+
nz = lengthCollSuperObjs
39+
end
40+
41+
if visualizeContactPoints
42+
addContactVisuObjToWorld!(world, nVisualContSupPoints, defaultContactSphereDiameter)
43+
end
44+
if visualizeSupportPoints
45+
addSupportVisuObjToWorld!(world, nVisualContSupPoints, defaultContactSphereDiameter)
46+
end
47+
48+
if visualizeBoundingBox
49+
addAABBVisuToWorld!(world, AABB)
50+
end
51+
52+
new(allowedToMove, dummyObject3D, lengthCollSuperObjs, nz, nzContact)
53+
end
54+
end
55+
56+
initializeContactDetection!(ch::Modia3D.AbstractContactDetection, collSuperObjs::Vector{Vector{Modia3D.AbstractObject3DFeature}}, noCPairs::Vector{Vector{Int64}}) = error("No contact detection handler defined.")
57+
selectContactPairsWithEvent!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
58+
selectContactPairsNoEvent!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
59+
getDistances!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
60+
setComputationFlag(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
61+
closeContactDetection!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")

src/Composition/massPropertiesComputation.jl

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,7 @@ function initializeMassComputation!(scene::Scene)
1919
buffer = scene.buffer
2020
for i = 1:length(buffer)
2121
rootSuperObj = buffer[i]
22-
#=
23-
if featureHasMass(rootSuperObj) # feature of root object has already mass properties
24-
rootSuperObj.objectHasMass = true
25-
copyMassPropertiesFromFeatureToObject3D(rootSuperObj.massProperties, rootSuperObj.feature.massProperties.m,
26-
rootSuperObj.feature.massProperties.rCM, rootSuperObj.feature.massProperties.I)
27-
callInitialInertiaTensor!(rootSuperObj, superObjs[i].superObjMass.superObj)
28-
else # root obj's feature has no mass properties, but common mass super object do
29-
if length(superObjs[i].superObjMass.superObj) > 0
30-
rootSuperObj.objectHasMass = true
31-
callInitialInertiaTensor!(rootSuperObj, superObjs[i].superObjMass.superObj)
32-
end
33-
end
34-
=#
22+
3523
if featureHasMass(rootSuperObj) # feature of root object has already mass properties
3624
rootSuperObj.hasMass = true
3725
rootSuperObj.m = rootSuperObj.feature.massProperties.m
@@ -52,12 +40,10 @@ function initializeMassComputation!(scene::Scene)
5240
end
5341
end
5442

55-
# callInitialInertiaTensor! is called at initialization.
5643
# It loops over all objects of an actual mass super object.
5744
# It sums up common mass, inertia tensor and center of mass.
5845
# The results are stored twice in actual root of super object:
5946
# massProperties: container for actual values
60-
# function callInitialInertiaTensor!(rootSuperObj::Object3D, actualMassSuperObject::Vector{Object3D,1})
6147
function addMassPropertiesOfAllSuperObjChildsToRootSuperObj!(rootSuperObj::Object3D, actualMassSuperObject::Vector{Object3D})
6248
if length(actualMassSuperObject) > 0
6349
for i=1:length(actualMassSuperObject)
@@ -158,13 +144,3 @@ function addOrSubtractMassPropertiesOfChildToRoot!(obj_root, obj_child; add=true
158144
obj_root.I_CM = I
159145
return nothing
160146
end; end
161-
162-
163-
# helper function for assigning mass properties
164-
#=
165-
function assignMassProperties(massProperties, m, rCM, I)
166-
massProperties.m = m
167-
massProperties.rCM = rCM
168-
massProperties.I = I
169-
end
170-
=#

src/Composition/object3D.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,6 @@ function canCollide(obj::Object3D)::Bool
539539
end
540540

541541

542-
function driveJoint!(obj::Object3D)::Nothing
543-
obj.isDriven = true
544-
return nothing
545-
end
546-
547-
548542
""" rootObject3D(obj) - returns the root Object3D of all parents of obj"""
549543
function rootObject3D(obj::Object3D)::Object3D
550544
obj1 = obj

src/Composition/printObject3D.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ function printScene(scene)
6363
println(" v = ", obj.joint.specific.v)
6464
println(" w = ", obj.joint.specific.w)
6565
end
66-
67-
hasMassProperties = scene.options.useOptimizedStructure && objectHasMass(obj) ||
68-
!scene.options.useOptimizedStructure && featureHasMass(obj)
69-
if hasMassProperties
70-
massProperties::Shapes.InternalMassProperties = scene.options.useOptimizedStructure ? obj.massProperties : obj.feature.massProperties
71-
println(" massProperties")
72-
println(" m = ", massProperties.m)
73-
println(" rCM = ", massProperties.rCM)
74-
end
7566
end
7667
println()
7768
end

src/Composition/scene.jl

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,73 +14,6 @@ visualize!(renderer::Modia3D.AbstractRenderer, time::Float64) = error("No render
1414
closeVisualization(renderer::Modia3D.AbstractRenderer) = error("No renderer defined.")
1515

1616

17-
#-------------------------------------- Default Contact Detection -------------------------------
18-
19-
"""
20-
ContactPairs(nzmax, collSuperObjs, noCPairs, dummyObject3D)
21-
22-
Generate a new ContactPairs structure used for communication between the Object3D handler and a ContactDetection handler.
23-
24-
- `DummyObject3D::Modia3D.AbstractObject3DFeature`: A dummy Object3D that can be used in the struct as element of a vector of Object3Ds
25-
to fill the vector with a dummy value of the correct type.
26-
"""
27-
mutable struct ContactPairs
28-
# Solid shapes used in contact detection (provided by Object3D handler)
29-
allowedToMove::Vector{Union{Bool,Nothing}}
30-
dummyObject3D::Modia3D.AbstractObject3DFeature # Dummy Object3D for non-used elements of z-Vector.
31-
32-
# Dimensions
33-
ne::Int # length(collSuperObjs)
34-
nz::Int # length(z)
35-
nzContact::Int # length(z | z has contact) length of z where zi has contact
36-
37-
function ContactPairs(world::Composition.Object3D, AABB::Vector{Vector{Basics.BoundingBox}}, superObjs::Vector{SuperObjsRow},
38-
allowedToMove::Vector{Union{Bool,Nothing}}, visualizeBoundingBox::Bool, nVisualContSupPoints::Int,
39-
visualizeContactPoints::Bool, visualizeSupportPoints::Bool, defaultContactSphereDiameter::Float64)
40-
@assert(length(superObjs) > 0)
41-
@assert(nVisualContSupPoints > 0)
42-
dummyObject3D = Composition.emptyObject3DFeature
43-
44-
lengthCollSuperObjs = length(superObjs)
45-
if lengthCollSuperObjs <= 1
46-
error("There's nothing to collide. All Object3Ds are rigidly connected.")
47-
end
48-
49-
nzContact = 0
50-
nz = 2
51-
52-
if lengthCollSuperObjs > 2
53-
nz = lengthCollSuperObjs
54-
end
55-
56-
amountVisuPoints = 1
57-
amountSuppPoints = 1
58-
if visualizeContactPoints
59-
addContactVisuObjToWorld!(world, nVisualContSupPoints, defaultContactSphereDiameter)
60-
end
61-
if visualizeSupportPoints
62-
addSupportVisuObjToWorld!(world, nVisualContSupPoints, defaultContactSphereDiameter)
63-
end
64-
65-
if visualizeBoundingBox
66-
addAABBVisuToWorld!(world, AABB)
67-
end
68-
69-
70-
new(allowedToMove, dummyObject3D, lengthCollSuperObjs, nz, nzContact)
71-
end
72-
end
73-
74-
initializeContactDetection!(ch::Modia3D.AbstractContactDetection, collSuperObjs::Vector{Vector{Modia3D.AbstractObject3DFeature}}, noCPairs::Vector{Vector{Int64}}) = error("No contact detection handler defined.")
75-
selectContactPairsWithEvent!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
76-
selectContactPairsNoEvent!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
77-
getDistances!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
78-
setComputationFlag(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
79-
closeContactDetection!(ch::Modia3D.AbstractContactDetection) = error("No contact detection handler defined.")
80-
81-
include(joinpath(Modia3D.path, "src", "contactDetection", "ContactDetectionMPR", "ContactDetectionMPR_handler.jl"))
82-
83-
8417

8518
#-------------------------------------- Gravity field ----------------------------------
8619

src/Shapes/_module.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ export supportPoint_Sphere, supportPoint_Ellipsoid, supportPoint_Box, supportPoi
5757
export supportPoint_i_Box, supportPoint_i_Cylinder, supportPoint_i_Cone, supportPoint_i_Capsule,supportPoint_i_Beam, supportPoint_i_Ellipsoid, supportPoint_i_FileMesh
5858

5959
# Solid materials
60-
export InternalMassProperties, MassProperties, SolidMaterial, ContactMaterialElastic, dummyMassProperties
60+
export MassProperties, SolidMaterial
6161

6262
export MassPropertiesFromShape, MassPropertiesFromShapeAndMass
6363

64-
export solidMaterial, solidMaterialPalette, defaultContactMaterial
64+
export solidMaterial, solidMaterialPalette
6565
export regularize, resultantCoefficientOfRestitution, resultantDampingCoefficient
66-
export solidMaterialPairsPalette, CommonCollisionProperties, getCommonCollisionProperties
6766

6867
# Observer materials
6968

src/Shapes/contactPairMaterials.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ contactPairMaterialPalette = readContactPairMaterialFromJSON( joinpath(Modia3D.p
140140

141141

142142

143-
144-
145-
146143
"""
147144
material = getContactPairMaterial(name1, name2)
148145

0 commit comments

Comments
 (0)