Using ChBodyEasyClusterOfSpheres with PyChrono

17 views
Skip to first unread message

Owen Zoyt

unread,
May 17, 2024, 11:49:47 PM5/17/24
to ProjectChrono
Hello,

I'm looking to use ChBodyEasyClusterOfSpheres to create a simplified collider for a larger simulation I'm working on. It seems I can pass it a vector of vectors of points that the spheres are centered on, so that's what I tried to do. SphereCenters is an Nx3 numpy array. Based on my read of the documentation and the errors I'm getting, I am passing the right data types, but evidently I'm missing something, as it still isn't working. 

[setup code, all of this has been working]... 
mesh_for_collision = chrono.ChBodyEasyClusterOfSpheres(
chrono.ChVector3d(chrono.ChVector3d(*sphereCenter) for sphereCenter in sphereCenters),
vrad,
1.0,
False,
True)
   
torus_mesh.AddCollisionShape(mesh_for_collision)
torus_mesh.EnableCollision(True)
sys.Add(torus_mesh)

[then all the chronoirr code for visualization]

This still raises the error:
Traceback (most recent call last):
  File "C:\Users\user\PycharmProject\mesh-collapse\mesh_collapse\chrono.py", line 167, in <module>
    Generation(0.5, 0.15, 0,0,1,1, 0, 0, 0)
  File "C:\Users\user\PycharmProject\mesh-collapse\mesh_collapse\chrono.py", line 117, in  Generation
    chrono.ChVector3d(chrono.ChVector3d(*sphereCenter) for sphereCenter in sphereCenters),
  File "C:\Users\user\anaconda3\envs\mesh-collapse-chrono\lib\site-packages\pychrono\core.py", line 626, in __init__
    _core.ChVector3d_swiginit(self, _core.new_ChVector3d(*args))
TypeError: Wrong number or type of arguments for overloaded function 'new_ChVector3d'.
  Possible C/C++ prototypes are:
    chrono::ChVector3< double >::ChVector3()
    chrono::ChVector3< double >::ChVector3(double,double,double)
    chrono::ChVector3< double >::ChVector3(double)
    chrono::ChVector3< double >::ChVector3(chrono::ChVector3< double > const &)

Any thoughts or insight would be greatly appreciated!
Reply all
Reply to author
Forward
0 new messages