Load an STL file containing a rectangular bin triangulation, and then visualize the bin triangulation.
Create a collision mesh using the points from the triangulation of the bin, and then visualize the mesh. Note that, when you approximate the bin triangulation as one collision mesh, the collisionMesh
object uses the convex hull of the bin triangulation to approximate the bin. As a result the collision mesh is convex, unlike the non-convex bin triangulation. The collisionMesh
object does this because collision checking is most efficient with convex meshes. However, this convex approximation is not ideal for bins because robots can manipulate bins or objects inside of bins.
Create a soda can using a collision cylinder, and set the pose such that it sits in the center of the bin. Then, show it in the convex collision mesh.
Set the box to be transparent so that you can see the overlap between the bin and the soda can.
Check collision between the soda can and the convex approximation of the bin, and note that they are in collision.
To get a better approximation of the bin for collision checking, decompose the original non-convex mesh into multiple convex meshes using voxelized hierarchical approximate convex decomposition (V-HACD).
Use the collisionVHACD
function to decompose the original non-convex triangulation into convex collision meshes. Then, show the decomposed bin with the soda can.
Check collision with all the meshes that approximate the bin. Note that the soda can is not in collision with the decomposed non-convex approximation of the bin. If you require a more accurate decomposition of the bin, you can specify custom solver options using the vhacdOptions
object.
isCollidingAll = logical
0