Collision Handling

Collision handling with elastic response calculation is performed for convex shapes that are defined with a contact material or solid material. The elastic response calculation is currently solely based on the information about the largest penetration that is computed with an improved Minkowski Portal Refinement (MPR) algorithm. Collision response with an adaptive integration method works only reasonable, if the convex objects have point-contact.

Collision handling can be globally activated with keyword enableContactDetection = true set in the Scene. Only Solid Object3Ds can take place in collision situations.

The example in "$(Modia3D.path)/test/Tutorial/BouncingSphere.jl" defines a sphere that is bouncing on the ground. The essential statements are:

module BouncingSphere3D

using Modia3D

BouncingSphere = Model3D(
    boxHeigth = 0.1,
    world      = Object3D(feature=Scene(enableContactDetection = true, # default value
                        animationFile="BouncingSphere.json")),
    ground     = Object3D(parent=:world, translation=:[0.0,-boxHeigth/2,0.0],
                    feature=Solid(shape=Box(lengthX=4.0, lengthY=:boxHeigth, lengthZ=0.7),
                        visualMaterial=VisualMaterial(color="DarkGreen"),
                        solidMaterial="Steel", # for mass and force computation
                        collision=true)),      # enable collision flag
    sphere     = Object3D(parent=:world, fixedToParent=false, translation=[0.0, 1.0, 0.0],
                        feature=Solid(shape=Sphere(diameter=0.2),
                        visualMaterial=VisualMaterial(color="Blue"),
                        solidMaterial="Steel", # for mass and force computation
                        massProperties=MassPropertiesFromShapeAndMass(mass=0.001),
                        collision=true)),      # enable collision flag
)

bouncingSphere = @instantiateModel(BouncingSphere, unitless=true)
simulate!(bouncingSphere, stopTime=2.2, dtmax=0.1)

@usingModiaPlot
plot(bouncingSphere, "sphere.translation", figure=1)

end

or

julia> import Modia3D
julia> include("$(Modia3D.path)/test/Tutorial/BouncingSphere.jl")

The commands above generate an instance of the model, simulate it and generate the following plot:

Tutorial-Collision

Note:

  • Only Solid Object3Ds where a shape is defined and collision=true is considered in collision handling.
  • Make sure mass properties are computed and define how it behaves in contact situations. Define a solidMaterial="NameOfSolidMaterial" or a contactMaterial="NameOfContactMaterial" (this defines for example YoungsModulus). The used names must be available in the Modia3D/palettes/contactPairMaterials.json where for various combinations of contact materials, additional data is provided (for example the coefficientOfRestitution). For more details about the contact material data, see Solid material and Contact pair material. The details of the contact computation are sketched in Contact Force Law.