cyberbotics / webots

Webots Robot Simulator
https://cyberbotics.com
Apache License 2.0
3.14k stars 1.66k forks source link

HingeJoint's minStop and maxStop attributes do not work correctly #3947

Closed VladimirVincan closed 1 year ago

VladimirVincan commented 2 years ago

Hello,

I was trying to implement a simple mechanism that requires the use of a joint. The cards, shown on the GIFs, are supposed to be pushed by a robot, and then fall and stay vertically downwards due to gravity. The problem is, that I cannot limit the cards to stay vertically downwards. If I say that the joint's maxStop attribute has a value of π (or a bit less, e.g. 3), the cards won't stop rotating, as shown on the first GIF. If the maxStop attribute has a value of ~2.6 (the second GIF), the cards rotate once or twice before they get limited by minStop and maxStop. If the maxStop attribute has a value of ~2 or less (the third GIF), I have not encountered an error.

I would like to be able to set maxStop to be around π, so that the cards can stay vertically downwards. I could not find a reason why my PROTO file creates this kind of problem, so I believe it is a bug. Please take a look at the world on this link, it is named eurobot_2022.wbt. Also, please take a look at the PROTO file on this link, it is named ExcavationSquare.proto. Everything is done on the excavation_squares branch.

Thank you beforehand!

max_stop_3_3

max_stop_2_6

max_stop_2

ad-daniel commented 2 years ago

That's an odd behavior, to an extent is normal insofar as adding an excessive force will probably break the constraint, however curiously enough using this method I haven't been able to break the minStop limit, meaning I can't get it to rotate by turning it counter clockwise. Turning clockwise however the maxStop is violated much more frequently and easily, so given the asymmetry of the behavior something fishy must be happening

ygoumaz commented 1 year ago

Upon conducting several tests, it appears that the system encounters a singularity when the limits are set close to -pi and +pi. While it is difficult to exceed the limit when it is set below 2.6, as the limit approaches pi, it becomes increasingly easier to violate the condition with even low torques or forces applied. This behavior may indicate a bug in ODE, causing the position field value (in the Webots scene tree) to grow or decrease beyond the limit when the condition is violated.