robotology-legacy / WBI-Toolbox-controllers

[WARNING]: this repository is no more mantained. Please refer to https://github.com/robotology/whole-body-controllers.
4 stars 4 forks source link

Weird behavior of gravity compensation on icubGazeboSim #66

Closed gabrielenava closed 6 years ago

gabrielenava commented 6 years ago

I did a simple modification of wholeBodyImpedance:

screenshot from 2017-10-27 12-40-59

I took the gravity compensation part. I removed the feedback + feedforward part. I substituted it with a block that can do a sweep in frequency on a sine function. I set the AMPLITUDE of the sine to zero to verify the effectiveness of gravity compensation with icubGazeboSim. This is the result (after 30 [s] of simulation):

screenshot from 2017-10-27 12-44-15

It is possible to reproduce the same behavior using wholeBodyImpedance. I did the following modification:

screenshot from 2017-10-27 12-37-37

it is the classical wholeBodyImedance controller but I added three GAIN blocks in which I set the gain to zero in order to remove the feedforward/feedback part. This is the result after 30[s]:

screenshot from 2017-10-27 12-48-12

and these are the gravity torques:

screenshot from 2017-10-27 12-49-01

I know this may be due to integration errors in Gazebo, still these results are really bad to me. It seems to me strange that gravity compensation is so bad. I cannot understand why. Furthermore, this is what happens if I try to control only 1 joint (in the picture: torso pitch, joint torque):

screenshot from 2017-10-27 12-53-30

I cannot understand this at all. Why I can't control only the torso pitch in torque mode?

This is what is inside the gravity compensation block:

screenshot from 2017-10-27 12-59-09

traversaro commented 6 years ago

I cannot understand this at all. Why I can't control only the torso pitch in torque mode?

Remember that if you control only one joint, the model will assume that all other joints are set to 0, so the gravity compensation will probably totally wrong.

traversaro commented 6 years ago

To debug the gravity compensation, I suggest to start by comparing the gravity compensation torques and the torque provided by the PID low level control, to see if they are ~consistent.

traversaro commented 6 years ago

Anyhow, consider that the icubGazeboSim model available in icub-gazebo has been manually modified a lot of time (when the eyes and hands have been added, etc etc). I would suggest to do this tests on the new iCubGazeboV2_5 introduced in https://github.com/robotology-playground/icub-model-generator/pull/71 .

gabrielenava commented 6 years ago

I cannot understand this at all. Why I can't control only the torso pitch in torque mode?

Remember that if you control only one joint, the model will assume that all other joints are set to 0, so the gravity compensation will probably totally wrong.

Ok thanks, this explains why it failed when I tried it only with torso pitch.

I actually tried the same test using Walkman model, and I got the same results. Maybe it is due to numerical integration errors?

traversaro commented 6 years ago

Mhh I think we should chat about this on skype/appear.

gabrielenava commented 6 years ago

I tested the gravity compensation only on the legs. I also compared the desired torques with the measured (are these torques the one provided by the PID low level control also in simulation? does it make sense to do this comparison in simulation?). This is the torque error:

screenshot from 2017-10-27 15-06-57

it is almost always zero, but there's a strange peak and I don't know why, but I don't think is related to the gravity compensation issue. Indeed, the gravity compensation is way better on the legs (the derive is much slower in 30 [s]). See the picture below.

screenshot from 2017-10-27 15-07-22

So I really think we're debugging numerical integration issue.

traversaro commented 6 years ago

numerical integration issue

Nitpick; in general consider that there are several points in which the classical multibody dynamic is "approximated" in the ODE physics engine (see http://robotics.cs.tamu.edu/dshell/papers/simpar2010ode.pdf), so it can be also a numerical simulation issue that is not related to integration algorithms.

gabrielenava commented 6 years ago

I tested the gravity compensator on real robot, it was working fine even without feedback terms. We can close this issue.