Skip to content

Collisions between two OCC objects not reliable #251

@8bit-Dude

Description

@8bit-Dude

I have setup a script in which an OCC generated tool moves relative to a box. The box is either generated with ChBodyEasyBox(), or an OCC box converted with ChBodyEasyCascade().

The "EasyBox" produces correct collision counts, but the "OCCBox" does not (it fails to detect collisions with the tool shaft). Here is a sample code, you can switch between chrono and occ box by commenting/uncommenting the system.add() lines:

from pychrono.core import *
from pychrono.cascade import *
ChCollisionModel.SetDefaultSuggestedEnvelope(0.001);
ChCollisionModel.SetDefaultSuggestedMargin(0.001);
material = ChMaterialSurfaceNSC()
tolerance = ChCascadeTriangulateTolerances(0.1 ,True,0.5)

#Create OCC tool
from OCC.Core.BRepPrimAPI import *
from OCC.Core.BRepAlgoAPI import *
sphere = BRepPrimAPI_MakeSphere(2.0).Shape()
cylinder = BRepPrimAPI_MakeCylinder(1.5, 20.0).Shape()
tool = BRepAlgoAPI_Fuse(sphere, cylinder).Shape()
occTool = ChBodyEasyCascade(tool, 1, tolerance, True, material)

#Create OCC box
box = BRepPrimAPI_MakeBox(10.0, 10.0, 2.0).Shape()
occBox = ChBodyEasyCascade(box, 1, tolerance, True, material)
occBox.SetPos(ChVectorD(0.0,0.0,0.0))

#Create CHR box
chrBox = ChBodyEasyBox(10, 10, 2.0, 1, True, True, material)
chrBox.SetPos(ChVectorD(0.0,0.0,0.0))

#Create Physics System (comment/uncomment occBox, chrBox)
system = ChSystemNSC()
system.Add(occTool)
system.Add(occBox) #<- THIS ONE DOES NOT WORK CORRECTLY
#system.Add(chrBox) #<- THIS ONE WORKS CORRECTLY

#Create Viewer for Debugging
from pychrono.irrlicht import *
app = ChIrrApp(system, 'Use OpenCascade shapes', dimension2du(1024,768))
app.AddTypicalSky()
app.AddTypicalLogo(GetChronoDataFile('logo_pychrono_alpha.png'))
app.AddTypicalCamera(vector3df(20,5,5))
app.AddTypicalLights()
app.AssetBindAll();
app.AssetUpdateAll();

#Compute collision state at various positions
from time import *
for z in [15,10,5,0]:
. . . occTool.SetPos(ChVectorD(0,0,z))
. . . system.DoStepDynamics(0)
. . . system.ComputeCollisions()
. . . app.BeginScene(); app.DrawAll(); app.EndScene()
. . . print("Collisions: " + str(system.GetNcontacts()))
. . . sleep(2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions