Skip to content

Commit 3056f70

Browse files
committed
throw a warning if a collision pairing material is not defined at initialization + adapt YouBotPingPong.jl
1 parent 0641af2 commit 3056f70

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/Composition/contactPairs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ mutable struct ContactPairs
4949
nextSuperObj = superObjs[js].superObjCollision.superObj
5050
for j = 1:length(nextSuperObj)
5151
nextObj = nextSuperObj[j]
52-
Shapes.getContactPairMaterial(actObj, nextObj)
52+
Shapes.checkContactPairMaterialInit(actObj, nextObj)
5353
end
5454
end
5555
end

src/Shapes/contactPairMaterials.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,28 @@ function getContactPairMaterial(obj1, obj2)::Modia3D.AbstractContactPairMaterial
163163
end
164164
return value
165165
end
166+
167+
168+
"""
169+
material = checkContactPairMaterialInit(obj1, obj2)
170+
171+
Return a contact pair material object of the materials with the
172+
names `name1` and `name2` from dictionary `Modia3D.contactPairMaterialPalette`.
173+
"""
174+
function checkContactPairMaterialInit(obj1, obj2)::Nothing
175+
name1 = obj1.feature.contactMaterial
176+
name2 = obj2.feature.contactMaterial
177+
178+
value = get(contactPairMaterialPalette, TwoNamesKey(name1,name2), NoContactPairMaterial())
179+
if typeof(value) == NoContactPairMaterial
180+
# Combination name1,name2 is not present
181+
value1 = get(contactPairMaterialPalette, TwoNamesKey(name1,name1), NoContactPairMaterial())
182+
value2 = get(contactPairMaterialPalette, TwoNamesKey(name2,name2), NoContactPairMaterial())
183+
if typeof(value1) != NoContactPairMaterial && typeof(value2) != NoContactPairMaterial
184+
return nothing
185+
else
186+
@warn("If a contact between $(Modia3D.fullName(obj1)) and $(Modia3D.fullName(obj2)) occurs during simulation a pairing of contact materials $name1 and $name2 will be required. But this combination is not available in $Modia3D.path/palettes/contactPairMaterials.json.")
187+
end
188+
end
189+
return nothing
190+
end

test/Robot/YouBotPingPong.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Link = Model(
339339
trans = [0,0,0],
340340
rota = Par(value = :(nullRot)), #rotation1, #Modia3D.rot1(180u"°"),
341341

342-
obj1 = Object3D(parent=:parent1, rotation=:rota, visualizeFrame=false), # feature=:featureVisual,
342+
obj1 = Object3D(parent=:parent1, rotation=:rota), # feature=:featureVisual,
343343
body = Object3D(feature = :featureBody),
344344
obj2 = Object3D(parent =:body, translation = :trans),
345345
)

0 commit comments

Comments
 (0)