Rotation error in Gazebo simulation

Hi everywhere. I wrote the following robot model in URDF and then I built a controller to teleoperate with it.

The result, as you can see in the video is not the expected, since they rotate on itself doing strange things (which seems more difficult when the spin is somehow aligned with the axis of coordinates of the world). Any ideas? I tried to change values ​​Mu1, Mu2, Kp, Kd and others like selfCollide with no success. I compared with models such as the Erratic and PR2 and finds no difference to me.

Here is the video that I recorded with the problem.

Thanks!

P.S: I want to add that the result is the same in teleoperation and in applying joint efforts directly to the wheels. With this I want to say that there is not a problem of the controller.

Originally posted by mbj on ROS Answers with karma: 197 on 2011-04-04

Post score: 3

Thanks for the videos, I think I understand the issue better now. (It would still be great if you can insert your URDF in the message directly as quoted text in your posting?)

The speed up and slow down you see is an artifact of the fact that the friction forces between the wheels and the ground is dominating the dynamics and also because ODE is solving friction forces using a friction pyramid rather than a friction cone. If you look more closely at each contact point between a wheel and the ground, initially the base resists rotation because the friction force in the direction perpendicular to the wheel alignment has a longer moment arm about the CG of your system then the friction force aligned with the wheel's rolling direction. Because of numerical errors and drift, the base is eventually perturbed from its axis aligned orientation, and once the perturbation is large enough, the artifact of friction pyramid takes over and starts rotating the base until you hit another axis alignment 90 degrees later.

Without digging further into the equations of motion, have you tried using a lower friction coefficient <mu> and see if the effect you described can be reduced?

The fix is by setting the friction pyramid axis in alignment with the wheel frame by setting dContactFdir1 for wheel contacts [(see ODE manual for description)](http://opende.sourceforge.net/wiki/index.php/Manual_(Joint_Types_and_Functions). Gazebo does not have that API right now, but should be able to added it easily.

Originally posted by hsu with karma: 5780 on 2011-04-07

This answer was ACCEPTED on the original site

Post score: 5

Comment by mbj on 2011-04-12:
Hi John. Thank you again for answering me, all this is helping me a lot to understand the ROS working. Unfortunately, since you answered me, I've been trying to apply the changes you propose to me without success. I didn't want to ask you this but I'm already 3 days without any progress. Firstly, I installed a version from the ROS source to compile (http://www.ros.org/wiki/diamondback/Installation/Ubuntu/Source), I made the appropriate changes to simulator_gazebo and I compiled everything successfully (with rosmake). Unfortunately, testing with my model I have not found any significant change. Later, I tried to introduce errors intentionally in the code and compile the simulator (also with rosmake) to see if I'm compiling correctly. As I imagined, it gives no errors. What should I do to successfully compile the code and test the changes?

Comment by hsu on 2011-04-08:
https://code.ros.org/trac/ros-pkg/changeset/36581 - pass through for fdir1

Comment by hsu on 2011-04-08:
https://kforge.ros.org/gazebo/hg/rev/d1c050d67b0a - set fdir1 for each contact

Comment by mbj on 2011-04-07:
Thank you very much for your response hsu! Actually, I have tried almost all combinations of mu1 and mu2 possibles both kp and kd, however the most convincing result I have found is the exposed.

If I haven't misunderstood you, dContactFDir1 defines the direction of friction mu1. This isn't implemented in the Gazebo API, but he uses it internally for some calculations like this.

According to your explain, it isn't difficult to add this parameter to the API. I think that this isn't the right way, but I searched through the simulator files and I have found references in the files physics_xml_tags and ODEPhysics. It would have to add or modify some parameter/function here?

here's a smooth sliding sim after all the fixes, running from trunk of simulator_gazebo and setting fdir1, mu1 and mu2 for the wheel geoms.

Originally posted by hsu with karma: 5780 on 2011-04-22

This answer was NOT ACCEPTED on the original site

Post score: 1