I can't get Sim3D PreciseContacts to work

I have some concave STL mesh that I put in the 3d sim world, I noticed the collisions (require physics enabled) or overlap are detected according to a simplified convex hull around the part.
I figured the parameter PreciseContacts should do the trick, but when activated then collision events or overlap events are no longer detected.

Answers (1)

Hi Jesse, do you have a script or model that you can share so that I can replicate this behavior?

4 Comments

Jesse
Jesse on 17 Jun 2024
Edited: Jesse on 17 Jun 2024
This is the closest I get to make it work, it seems like the concave part needs to have precise contacts enabled, but not the other part, which has to be convex, and only one of the parts can have precise contacts enabled or else there's no collision at all.
Also, the part who doesn't have precise contacts enabled must have physics enabled, which cause a bunch of problems (not possible to have hierarchy of actors, no control of the movement, it just bounces randomly when collision is detected).
I was trying to simulate a robot in this environment but it's basically unusable.
Here's my simplified code, i put the stl in attachments :
clear all
world = sim3d.World('Output', @outputImpl, 'Update', @updateImpl);
% Concave part
Part1 = sim3d.Actor('ActorName', 'A1', 'Mobility', sim3d.utils.MobilityTypes.Movable);
Part1.load('A1.stl', 0.001*[1, 1, 1]);
Part1.Translation = [0 0 -1];
Part1.HitEventEnabled = true;
Part1.Collisions = true;
Part1.PreciseContacts = true;
% Part1.Physics = true;
world.add(Part1);
% Convex part
Part2 = sim3d.Actor('ActorName', 'Z2', 'Mobility', sim3d.utils.MobilityTypes.Movable);
Part2.load('Z2.stl', 0.001*[1, 1, 1]);
Part2.Rotation = [0 pi 0];
Part2.HitEventEnabled = true;
Part2.Collisions = true;
% Part2.PreciseContacts = true;
Part2.Physics = true;
world.add(Part2);
viewport = createViewport(world);
viewport.Translation = [-1, -3, 0];
viewport.Rotation = [0, 0, 1];
run(world,0.05,5)
delete(world)
function outputImpl(world)
T = world.SimulationTime;
world.Actors.Z2.Translation = [0 0 -T];
end
function updateImpl(world)
if ~isempty(world.HitActors)
"HIT"
end
if ~isempty(world.BeginOverlappedActors)
"Overlap"
end
end
Hi Jesse,
It is a documented limitation that when PreciseContacts are enabled for an object, Physics and Gravity are disabled for that actor.
In your case, the part on the top does not have precise contacts enabled - and you enabled physics on it. If you enable gravity for this part and have a starting point closer to the part below, it seems to behave as expected, colliding with the part on the bottom and then resting on it as shown below:
I have some questions about the following:
"Also, the part who doesn't have precise contacts enabled must have physics enabled, which cause a bunch of problems (not possible to have hierarchy of actors, no control of the movement, it just bounces randomly when collision is detected)."
- What kind of hierarchy are you unable to achieve?
- What kind of movement control are you hoping for? In the script you provided, you are manually specifying the translation of the top part. Are you expecting the top part to ignore the specified translation once a collision with the bottom part takes place?
- I notice some jitter too when the objects are first resting on top of each other but this eventually resolves itself - is this what you are referring to?
I'm eager to learn more about what you are trying to do here and provide any support I can, so please let me know how I can help!
Nishan
Thanks for taking the time !
For example my goal was to create a whole robot/machine with translation/rotation joints between the parts.
It works really well when physics is disabled, but physics has to be enabled to detect collisions.
I also tried to use overlap instead (which was my first choice) but overlap doesn't seem to work with precisecollisions, the overlap is detected correctly only for convex parts.
Hi Jesse, this appears to be a limitation with using PreciseContacts due to the fact that PreciseContacts uses complex collision, and collision detection happens with very single vertices and faces of the object mesh.
Objects with PreciseContacts set to true cannot generate events while
  1. Moving kinematically and interacting with static or moving objects.
  2. Static and interacting with static or moving objects which also has PreciseContacts true.
This limitation will be better documented in the future but I wanted to provide you an update here.
Nishan

Sign in to comment.

Categories

Find more on Simulation in Help Center and File Exchange

Products

Release

R2024a

Tags

Asked:

on 14 Jun 2024

Commented:

on 24 Jun 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!