andreadelprete / consim

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

Quadruped Trot Results #28

Closed andreadelprete closed 3 years ago

andreadelprete commented 4 years ago

Now that the C++ and the Python versions of the simulators are giving the same results, I've repeated the tests with Solo12 trotting: figure_1 Exponential is always better than Euler, except for the smallest time step tested, which is 1/16 ms. Looking at the error over time we can see that actually Exponential is always better than Euler until the very end of the motion, when a very large error occurs that make the overall performance of Exponential worse of Euler: figure_3 The superiority of Exponential is even clearer if we reset the state of the system to the ground truth after every step, so that we measure the local integration error rather than the global one. figure_3 There are only two time instants when Exponential has a larger error than Euler, but since one of these errors is very large (at 2.6 s), this makes the total error of Exponential be larger than the one of Euler. We need to investigate to understand what happens at that specific moment in time.

jcarpent commented 4 years ago

Very nice results @andreadelprete. Minor small questions, but might lead to other insights:

andreadelprete commented 4 years ago
* What is your error norm?

Good question! The error norm is simply computed as $||x - \hat{x}||$, where $x$ is the ground truth state, and $\hat{x}$ is the state computed by the integration scheme. The ground truth is computed with the same integration scheme, but with a time step that is at least 8 times smaller (I've verified that using an even smaller time step for the ground truth does not change the results).

Now that I think about it, since $x$ contains the floating base, it is not appropriate to compute the mere difference, but I should use the operators implemented in pinocchio. If we're lucky that could be the reason behind the large error at 2.6 s.

* Have you tried semi-explicit Euler?

Not yet. Before facing a stronger opponent I'd like to be sure we beat explicit Euler at least. :)

* Do you check the total mechanical energy?

Not yet, but it could be nice to do it as soon as the integration errors seem good.

jcarpent commented 4 years ago

OK. Thanks for the clarification. Yes, using the difference operator of Pinocchio will give you something more reasonable. And you can also use the infinite norm, which is something I've found more relevant in general.

andreadelprete commented 4 years ago

I've tried switch to the difference operator, but it makes no difference (visually). The scripts I'm using generate also the infinite norm plots, but I'm never reporting them here because the results are always visually equivalent to the 2 norm.

andreadelprete commented 4 years ago

I had a bug in my script. I've cleaned up the code for computing the integration errors and now they look better. Here the mean value (over time) of the 2-norm of the error: figure_1 Here the mean value of the infinity norm of the error: figure_2 And finally, the max value of the infinity norm of the error: figure_3-1 Euler beats Exponential only according to this last error, which we already knew (and which I am still investigating). The good news is that, if we look at the average integration error instead, regardless which norm we consider, Exponential is roughly 2 orders of magnitude better than Euler. We can see that to get the same error with the two methods we should use a time step that is roughly 16 times smaller for Euler.

andreadelprete commented 4 years ago

I've investigate a bit what happens at 2.6 s, when the integration error of Exponential is larger than Euler. It seems that the error is mainly due to a delay in collision checking due to the "large" time step used. Both Euler and Exponential are subject to this error, but for some unclear reason, this seems to affect Exponential more than Euler. However, this happens only at this time step and for this specific motion (this doesn't occur with the jump, nor with Romeo walking), so I am starting to think it's just a case of "bad luck" and not a symptom of a bug.

andreadelprete commented 4 years ago

New results for the same test. Here I'm showing the local integration error as a function of the computation time (per time step, which is 2 ms in this test): local_err_vs_comp_time Euler never beats Exponential. We also see that it's never convenient to use the default number of matrix multiplications in expm. In this test using 1 or 0 multiplications is the optimal choice.