## VHACD -> CoACD?

Requests or suggestions for new features
zorro
Posts: 27
Joined: 06 Nov 2023, 09:31

### VHACD -> CoACD?

Hello!

I am trying to make a peg-in-hole scene, it seems the CoACD has better performance than VHACD in decomposing non-convex shapes. Will you guys consider adding this module into CoppeliaSim? I believe the addition of this component would greatly assist tasks with complex mechanical characteristics.

Here are some related links for CoACD:
https://github.com/SarahWeiii/CoACD
https://arxiv.org/pdf/2205.02961.pdf

coppelia
Posts: 10366
Joined: 14 Dec 2012, 00:25

### Re: VHACD -> CoACD?

Hello,

you can already use CoACD with following Python script (e.g. as a CoppeliaSim embedded script):

Code: Select all

# python

import numpy as np
import coacd

def getConvexDecomposed(shapeHandle):
p = sim.getObjectPose(shapeHandle)
vertices, indices, normals = sim.getShapeMesh(shapeHandle)
vertices = sim.multiplyVector(p, vertices)
vertices = np.array(vertices).reshape(-1, 3)
indices = np.array(indices).reshape(-1, 3)
mesh = coacd.Mesh(vertices, indices)
parts = coacd.run_coacd(mesh, threshold = 0.02) # a list of convex hulls.
newShapes = []
for p in parts:
vert = p[0].flatten().tolist()
ind = p[1].flatten().tolist()
newShapes.append(sim.createShape(0, 0.0, vert, ind))
return sim.groupShapes(newShapes)

def sysCall_init():
sim = require('sim')
h = sim.getObject('/path/to/shape')
convexDecomposedCompound = getConvexDecomposed(h)