andreadelprete / consim

GNU General Public License v3.0
14 stars 1 forks source link

ExponentialSimulator accuracy with nonzero impact velocity #25

Closed andreadelprete closed 4 years ago

andreadelprete commented 4 years ago

Carrying on with the benchmarks, I was unable to get good results with the quadruped trotting motion. Exponential shows good stability with large time steps, but for smaller time steps, when also Euler is stable, the integration error is lower for Euler than for Exponential, which doesn't make sense to me.

So I went back to the squatting test, where results were good, and I was able to figure out the difference between squatting and trotting: during squatting we have just one impact (at the beginning of the motion) and contact points have zero velocity. Indeed, by increasing the initial velocity of the base in the vertical downward direction, I was able to deteriorate the accuracy of Exponential:

INITIAL VEL 0
euler  32 Chol Total error: -3.58
exp  32 Total error: -4.59

INITIAL VEL  2e-2
euler  32 Chol Total error: -3.63
exp  32 Total error: -4.28

INITIAL VEL  5e-2
euler  32 Chol Total error: -3.71
exp  32 Total error: -3.98

INITIAL VEL 10e-2
euler  32 Chol Total error: -3.73
exp  32 Total error: -3.70

Also the accuracy of Euler deteriorates with increasing velocity, but much more slowly. I think this points to a bug in the code or a flaw in the theory. I'm investigating. I think this has top priority at the moment over all other aspects.

jcarpent commented 4 years ago

Do you have the force plots?

andreadelprete commented 4 years ago

There was a little bug in the Python simulator, which was the main reason for the problems above. Now Exponential performs better than Euler even if the initial velocity is nonzero. The same bug was not present in the C++ simulator.

However, even after fixing this bug, the performance during trot is still bad, and I don't know why. I'm investigating. Euler still slightly outperforms Exponential if the initial impact velocity is very large, such as 2 m/s, but during trot the impact velocities are much smaller, such as 0.3 m/s, so I don't think this is the problem.

I could report here some of the force plots I've generated, but they all look very good. The predictions done with Exponential look very accurate. I'll keep you posted.

andreadelprete commented 4 years ago

(kind of) Good news: I've repeated the trot test using both Python and C++ simulators. Euler gives exactly the same results in Python and C++. Exponential instead performs very differently. It's better then Euler in Python, but worse than Euler in C++. Therefore, it seems there is just a bug somewhere in the C++ simulator, which is good news because it means that at least the theory is correct.

andreadelprete commented 4 years ago

I've created a script to compare the Python and the C++ simulator using the trotting motion of Solo. Here the results: figure_1 We can see that initially the two simulators give the same result, then at 0.25 s the first foot breaks contact and there the two simulators differ.

andreadelprete commented 4 years ago

This was fixed with ae792b1771d130818454621cc3abb48e4d7fc920