andreadelprete / consim

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

Sanity check: Sliding point mass #20

Open andreadelprete opened 4 years ago

andreadelprete commented 4 years ago

I've implemented the force projection method in the exponential simulator in Python and I've run some tests with a simple point mass sliding on a flat floor. The outer time step was 5 ms, stiffness 1e5, damping 2e2, and I apply a sinusoidal lateral force to the mass so that it slips. Here you can see the integration errors as a function of the number of inner time steps, in case the Euler simulator is used to compute the ground truth: slipping_point_mass_euler_ground_truth

And here in case the Exponential Simulator is used for the ground truth: slipping_point_mass_exp_ground_truth

As you can see, results are almost the same in the two case, which means that for small time steps the two approaches converge to similar solutions. Moreover, we can see that the exponential simulator works better in general. The large error decrease happening at ndt=4 (which corresponds to an inner time step of 5/4 ms) is due to the improved accuracy in detecting when slippage ends, as we can see in this plot showing the integration error vs time: slipping_point_mass_exp_int_error_vs_time We can also notice that the integration error stays constant during slippage (i.e. [0.03, 0.3]). Next I'm gonna check this works even with the quadruped.

andreadelprete commented 4 years ago

I've repeated the same tests using the cpp simulator. At first the exponential simulator was working really bad because of a bug. After fixing it, results are rather good, but do not match exactly the ones I got in Python.

Here the results using exponential as ground truth: slipping_point_mass_exp_ground_truth_cpp

Here using Euler as ground truth: slipping_point_mass_euler_ground_truth_cpp

When using the Exponential simulator as ground truth results are rather similar. However, when using Euler as ground truth, the Exponential simulator seems to saturate and cannot decrease the integration error. I'll investigate.

andreadelprete commented 4 years ago

I've tried cleaning up the cpp simulator, introducing the anchor point velocity in the computation of the contact forces, rewriting the update of the anchor point position. Unfortunately, Euler and Exponential still don't converge to the same result, even for the simple case of a point mass sliding on a flat floor. You can see it for instance in this plot, where I've used Exponential to compute the ground truth: slipping_point_mass_exp_ground_truth_cpp_2 We can see that after a certain value of ndt, the error of Euler does not decrease. The opposite happens if I use Euler to compute the ground truth. slipping_point_mass_euler_ground_truth_cpp2

Maybe we could postpone investigating this issue until the deadline. In the paper we could simply compare each simulator against itself, as it was done in the paper by Tassa. This would mean taking the Euler line from the second plot, and the Exp line from the first plot, which is fair, and makes Exponential look much better than Euler.

PS: Using the python simulator, I don't get the same results (I don't know why). Here's what I get using Euler for the ground truth slipping_point_mass_euler_ground_truth_py2 I can still see a saturation for Exponential, but overall results are much better for both simulators, suggesting there might be something wrong in C++.

andreadelprete commented 4 years ago

PPS: In python, using Exponential as ground truth I get this: slipping_point_mass_exp_ground_truth_py2 There seems to be no saturation of the error of Euler. Again, this points at something wrong with the c++ simulator, but I cannot figure out what because I've looked at the code and now it should be equivalent to the python simulator.