Detecting colisions and space occupied

Hi, i'm creating some fitness functions (in python) to use with Breve Creatures but the most interesting ones require me to know if a object other than the body of the agent (or even another agent) are colliding/penetrating.
Ex: In a simulation trying to evolve agents that kick a ball i must make sure that the ball and the agent aren't colliding (at the beginning of the simulation).
I've tried to use checkForPenetrations (ball function inherited from breve.mobile) but somehow the ball ends up at the end of the screen and falls down :/

Also i would like to know the 'space' occupied by an agent. For example the ball kicking problem could be solved if i knew the width/length of the square in witch the agent is confined (on simple terms the maximum distance reached by the agent on the x and z axis).

checkForPenetrations should

checkForPenetrations should work, but it would have to be called before any physics code gets a chance to run, which would detect a deep collision and shoot the ball far away (which is I think what you're seeing). So if you move the ball to its start location and run checkForPenetrations in a single iterate call, I think it should work.

You could also use the getBoundMaximum and getBoundMinimum functions of the Real objects to figure out the occupied space of an object, but because of rotations and irregular shapes, I think this would be the harder way to go.

- jon

Thanks, i'll try that :)

Thanks, i'll try that :)

I couldn't get

I couldn't get checkForPenetrations then i realized that it was deprecated so I tried using getCollidingObjects. I can't detect collisions between the agent (multibody) and the ball (mobile) but i can detect collision between the ball and the floor (reason why the ball appeared at the end of the stage).

I'm using a modified version of the Creatures.py, basically what i'm doing is in the checkPenetration function on the class VirtualCreatures a cycle that checks if the position of the ball is valid:

self.ballstartloc = self.startlocation
self.ballstartloc.y = 0.6 # ball is size 1, 0.6 so it still has 0.1 distance from the floor

self.ball.move ( self.ballstartloc )

print self.ball.getCollidingObjects()

while self.ball.getCollidingObjects():
---self.ballstartloc.x += 1
---self.ball.move ( self.ballstartloc )

What about collisions

What about collisions between the ball and the individual Links in the MultiBody?

- jon

when I print the result of

when I print the result of ball.getCollidingObjects() it returns empty (if I don't put the ball slight above the floor it detects the floor tough)
"print self.ball.getCollidingObjects()"

Is collision detection

Is collision detection enabled for that object pair? Collision detection is enabled if physical simulation is enabled for both objects, OR if a collision handler is set up for them. If these conditions aren't true, then the collisions will not be detected, though in your case it sounds like they should be...

- jon

hmm

I use a instance of PhysicalControl to run the simulation. How do i make sure that physical simulation is enabled for both objects? (Mobile & Multibody)
Also, just in case, how do i set up a collision handler in python?

self.enablePhysics()

The multibody objects should have physics enabled by default.

The Mobile object may need a call to self.enablePhysics()

To setup a collision handler, tell the object the type and the handler method:

self.handleCollisions( 'Floor', 'land' )

- jon

Time to try method 2 ^^

Both have the enablePhysics enabled so ill try to handleCollisions handler method at setUp time.

Still nothing x(

I've tried both methods, nothing is detected still :/ Just in case i tried to detect the collision with the links the multibody is comprised of. The result is the same, the links in the multibody don't detect the ball but they do detect the floor...
Also i created a class to contain the multibody so it would be easier to follow, but in the end i guess it didn't help much :s
Is there another way to check if a body is penetrating another?

This should be working with

This should be working with getCollidingObjects, and in some basic tests of the same idea it's working for me. Any chance you can put together a sample simulation which will demonstrate the problem so I can debug it?

Thanks,

- jon

:(

Sorry for the delay in the response (couldn't help it). Right now i'm trying to get the code to run on a pc rather than my own :x. I'll get back to you once I make sure you will be able to run things on that end.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.