collision only with the floor

Typically: "How do I... ", "How can I... " questions
Post Reply
rico
Posts: 6
Joined: 07 Jun 2013, 19:50

collision only with the floor

Post by rico » 10 Feb 2015, 21:34

Hello V-REP community

I would like to have several instances of the same wheeled robot, being able to collide only with the ground (in order not to fall) and being able to go through each others (like a ghost). I set the objects composing my robot to not respondable, but if the wheels are not respondables, the robot goes through the floor. Apparently I can not find a way to set the respondable masks to have the wheels respondable with only with the floor. The robots going through each others are colliding when their wheels are touching the wheels of the other robot.
How can I achieve this?

Thanks

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

Re: collision only with the floor

Post by coppelia » 11 Feb 2015, 09:52

Hello Rico,

you have two possibilities:
  • Either you change the global respondable masks for each individual robot, so that they do not collide with each other. This works fine if you have at most 8 robots, and you have them in the scene beforehand.
  • Another way would be to write a contact callback script, that handles each individual contact that the physics engine has to handle. For example:

Code: Select all

objectHandle1,objectHandle2,engine=...

if not retTable1 then
	if engine==sim_physics_bullet then
		retTable1={0,0,0}
		retTable2={1,0,0,0,0,0,0,0,0,0,0,0,0,0}
	end
	if engine==sim_physics_ode then
		retTable1={0,4,4+8+16+2048}
		retTable2={0.25,0,0,0,0.25,0,0,0,0,0,0,0,0,0}
	end
	if engine==sim_physics_vortex then
		retTable1={0,0,0}
		retTable2={0,0,0,0,0,0,0,0,0,0,0,0,0,0}
	end
	floor=simGetObjectHandle('ResizableFloor_5_25_element') -- make sure to specify the correct name here!
end

if objectHandle1==floor or objectHandle2==floor then
	return 1,retTable1,retTable2
else
	return 0,retTable1,retTable2
end
(Make sure to use V-REP V3.2.0 or later!)

Cheers

RobAtLab
Posts: 74
Joined: 10 Jan 2018, 17:49

Re: collision only with the floor

Post by RobAtLab » 05 Feb 2018, 21:40

I've just found myself in a similar situation to this. I have objects that need to be able to go through each other but must respond to the floor, ad I have far more thsn the mask method can handle. Should that contact callback script method still work for the latest V-REP versions? Are there any other ways beyond that script method, I guess it requires you to precisely name within the script each object you don't want to experience collisions and list which other objects you want them not to collide with, now available on the current V-REP version.

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

Re: collision only with the floor

Post by coppelia » 07 Feb 2018, 18:10

Hello,

yes, you will very probably have to use the contact callback function in that case, Make sure to use the last V-REP version (V3.5.0), since that functionality has been improved/simplified.

Cheers

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

Re: collision only with the floor

Post by coppelia » 27 Nov 2019, 14:24

Have a look at this reply, that offers a probably better alternative.

Cheers

Post Reply