Convex decomposition C++

Report crashes, strange behaviour, or apparent bugs
Post Reply
darkPaladin
Posts: 4
Joined: 11 Sep 2018, 16:25

Convex decomposition C++

Post by darkPaladin »

Hi all,

I'm using convex decomposition in V-rep and it works fine using GUI and Lua but for some reason it's not working when using C++. I get this message "Computing the convex decomposition (HACD)..."" and I have waited for hours and nothing happens. I'm using V-rep in Linux. I was wondering if I could get some help.

This is the code snippet that I used in Lua and it works:

Code: Select all

handle=sim.importShape(3, "Model.stl", 0, 1.0, 0.001);
result=sim.setObjectSpecialProperty(handle,sim.objectspecialproperty_collidable);
result=sim.setObjectInt32Parameter(handle,sim.shapeintparam_static,0);
result=sim.setObjectInt32Parameter(handle,sim.shapeintparam_respondable,1);
handle = sim.convexDecompose(handle, 25, {1,1000000,1000000,0,0,10000,20,4,4,20},{0.001,30,0.25,0.0,0.0,0.0025,0.05,0.05,0.00125,0.0001});
This is the code snippet that I used in C++ and it doesn't work:

Code: Select all

int shapeHandle = -1;
int shapeDynHandle = -1;
int convDecomIntPams[] = {1,1000000,1000000,0,0,10000,20,4,4,20};
float convDecomFloatPams[] = {0.001,30,0.25,0.0,0.0,0.0025,0.05,0.05,0.00125,0.0001};
shapeDynHandle = simImportShape(3, "Model.stl", 3, 0.0, 0.001); // Import dynamic model
 simSetObjectSpecialProperty(shapeDynHandle, sim_objectspecialproperty_collidable); // Object is collidable
simSetObjectInt32Parameter(shapeDynHandle,sim_shapeintparam_static,0); // Object is dynamic
simSetObjectInt32Parameter(shapeDynHandle,sim_shapeintparam_respondable,1); // Object is respondalbe
simSetObjectInt32Parameter(shapeDynHandle,sim_shapeintparam_convex,1);
shapeDynHandle = simConvexDecompose(shapeDynHandle, 25, convDecomIntPams, convDecomFloatPams); // Convex decomposition

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Convex decomposition C++

Post by coppelia »

Thanks for reporting this. Does this happen with any shape?

As a workaround, you can always create an add-on script, that contains a function with the Lua-version of your code. Then simply call that add-on function with simCallScriptFunctionEx. Make sure to use V-REP V3.6.1 rev1 or older.

Cheers

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Convex decomposition C++

Post by coppelia »

Just noticed a difference how you call sim.importShape and simImportShape: the arguments are not the same. COuld that be the reason?

Cheers

Post Reply