enki-community / enki

A fast 2-D robot simulator. To contact us, please open an issue.
Other
36 stars 34 forks source link

Friction not working #5

Open daydin opened 10 years ago

daydin commented 10 years ago

Hello!

I am currently trying to incorporate some friction into the world to simulate realistic robot-wall collisions. In order to I do this, I simply set the dryFrictionCoefficient to 1 for all wall objects and the e-puck. However, this doesn't seem to impede the robot dragging along the wall so far as I can see.

I also thought to make the collisions perfectly inelastic (collisionElasticity = 0) such that the robot gets stuck on the wall if it collides with it. Again, I had no luck observing a real inelastic collision.

I was just curious if there is something I am missing. Any advice on how to overcome this problem is much welcome.

stephanemagnenat commented 10 years ago

The problem in the collision between a robot and the wall is that two "wrong" models have a very bad interference:

A solution would be to have a finite friction between the robot's wheels and the ground, but that is probably not trivial to implement right.

daydin commented 10 years ago

Dear Stéphane,

Where is the part of code that determines this infinite friction between the wheel and the floor?

I was looking at collideWithStaticObject in PhysicalEngine.cpp and the collision code (also repeated in line 573-589 of the same file) is said to be borrowed from http://www.myphysicslab.com/collision.html. I don't quite understand some of the expressions there. It seems that there is no equivalent of the "Thrust force vector" and "rubber band force vector" in there, is that correct? Do you mind explaining this method (collideWithStaticObject)? I don't see how the equations there are related to the ones on the website...

Insights are much welcome!

Deniz

stephanemagnenat commented 10 years ago

Dear Deniz,

For "bare" PhysicalObjects, collisions results in changes in speed and angSpeed, which are then affected by friction in PhysicalObject::applyForces() and finally used to integrate the position in PhysicalObject::initPhysicsInteractions(). However, robots inherits from DifferentialWheeled, which overwrites applyForces() and forces the speed to the command from the robot, effectively implementing a model of infinite friction between the ground and the robot. The only way other objects can affect a DifferentialWheeled is through de-interlacing.

The model in PhysicalObject::collideWithStaticObject() implements the collision part of the referred page, especially a simplified version of equation (11) when one object is static (i.e. has infinite mass and moment of inertia).