Collision detection between respondable objects

Typically: "How do I... ", "How can I... " questions
Post Reply
atoz
Posts: 57
Joined: 18 Oct 2013, 09:02

Collision detection between respondable objects

Post by atoz » 05 Aug 2017, 20:20

Hi,

I'm trying to use the collision detection module to detect collisions between 2 objects that are respondable. Object_1 is dynamic and respondable while Object_2 is static and respondable. Dynamic module is also enabled.

The collision detection does not seem to work as no collision is registered although dynamic module shows contact points. However, if I set Object_2 to be non-respondable, the collision is registered but this causes Object_1 to go through Object_2 which is what I'm trying to prevent. Is this intended behaviour?

How do I record a collision between 2 respondable objects?

Cheers

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

Re: Collision detection between respondable objects

Post by coppelia » 06 Aug 2017, 12:22

Hello,

there are 2 different types of collision detection in V-REP:
  • collision detection that is not linked to any physics engine, and that will also work when the physics engine is turned off. This will simply register if two shapes are overlapping. For that to work, you need to make sure that the two shapes are collidable (i.e. the respondable flag has no effect here). Here you need to either register a collision object, then read the collision state with simReadCollision, or you can directly check for collision with simCheckCollision.
  • Collision detection that is part of a physics engine. This collision detection is used to compute the reaction forces between two respondable shapes (i.e. the collidable flag has no effect here). Here, the collision information can be read via the simGetContactInfo function. Have also a look how the model Models/other/contact display.ttm is working.
Cheers

atoz
Posts: 57
Joined: 18 Oct 2013, 09:02

Re: Collision detection between respondable objects

Post by atoz » 06 Aug 2017, 14:12

Thanks for the prompt reply. I'm in fact talking about the collision detection without physics.

Both my objects are collidable and I have registered the collision object. The reason I mentioned the respondable flag is because switching that on/off is leads to the collision being registered or not. When the flag is off, Object A goes through Object B and the collision is registered, when it is on, Object A cannot go through Object B and the collision is not registered.

This is what I'm confused about. The respondable flag as you mention should not have any effect here. I've uploaded a minimal example with an arm and cube here: https://www.dropbox.com/s/nui2erwr4e9sg ... m.ttt?dl=0.

You control the arm using the manipulation_sphere during simulation. If you collide with the cube using the green tip of the arm, the collision is registered and the collider colour changes. However, collisions with the rest of the arm are not registered. If you uncheck the respondable flag for the cube, the arm can go through the cube and collisions are then also registered.

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

Re: Collision detection between respondable objects

Post by coppelia » 06 Aug 2017, 14:35

You are correct, that shouldn't happen. Can you post a simplified scene that illustrates the problem?

Cheers

atoz
Posts: 57
Joined: 18 Oct 2013, 09:02

Re: Collision detection between respondable objects

Post by atoz » 06 Aug 2017, 15:33

Seems I edited too late.

I've uploaded a minimal example with an arm and cube here: https://www.dropbox.com/s/nui2erwr4e9sg ... m.ttt?dl=0.

You can control the arm using the manipulation_sphere during simulation. If you collide with the cube using the green tip of the arm, the collision is registered and the collider colour changes. However, collisions with the rest of the arm are not registered. If you uncheck the respondable flag for the cube, the arm can go through the cube and collisions are then also registered.

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

Re: Collision detection between respondable objects

Post by coppelia » 06 Aug 2017, 15:52

Ok, I see the problem: the physics engines can actually compute collision responses without the objects actually colliding... this really depends on the physics engine used. Some use a small tolerance around meshes, in order to compute the collision response.
So what you should do is create invisible shapes around the visible shapes, that are collidable. Those invisible shapes should be slightly larger than the original shapes. You can achive this by selecting a shape, creating a convex hull, then inflate the convex hull [Menu bar --> Add --> Inflated convex hull of selection].

Cheers

atoz
Posts: 57
Joined: 18 Oct 2013, 09:02

Re: Collision detection between respondable objects

Post by atoz » 06 Aug 2017, 16:40

Your response gave me an idea and I think I may have found the actual reason for this issue. The dynamically enabled invisible shapes of the arm are slightly larger than the visible shapes used for collision detection. So in the dynamic engine, the 2 objects have already touched but this is not visible and also prevents the visible shapes from touching each other and the collision is not registered.

My short term solution is to just check the collision property for the dynamic shapes. Do you see any issues with this?

Thanks!

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

Re: Collision detection between respondable objects

Post by coppelia » 06 Aug 2017, 21:32

Yes, that should work. You will however have to parse the contact points with simGetContactInfo, and check whether there are contacts with the incriminating shape(s).

Cheers

Post Reply