-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differentiation through contact not working correctly #73
Comments
Basically, yes. See appendix F of https://openreview.net/pdf?id=B1eB5xSFvr for some discussion on this point. Though the simulator here is a somewhat different flavor than the one used there, the same points apply. They suggest a fix for their simulator; although the simplest and most generic fix is to implement a sping-based collision handler, rather than the impulse-one used here. That will require more timesteps to resolve stiff contacts, but at least it makes it conceptually the clearest whats going on. |
Eelco is totally right--we actually had time of impact based collisions (which are another way of fixing this) in an extremely early build, but removed it because it didn't seem to effect much, but this is a pretty clear demonstration of the breakdown. I should have some cycles in the next week or so to try a toi-based patch. |
I will add, however, that I'm not sure that this is the issue appearing here--I think this particular failure mode is arising from an insufficiently small numerical step size used when calculating the numerical derivative. Your smallest window "h" is only about Here are some numerical derivatives for smaller step sizes:
|
Closing, but feel free to reopen if you think this issue is not resolved by smaller |
I'm trying to do a simple example of differentiation through contact. I created a function that simulates a ball falling and bounding for 20 time steps. When I try taking the derivative of the final height with respect to the initial height, it always returns 1, even though it should not be a linear dependence. I've put together a example notebook demonstrating this, where I compute the aforementioned derivative numerically and analytically, and the two do not agree. I also plotted the numerical derivative as a function of starting height -- the derivative is only 1 when the ball is sufficiently high, but that's just because it does not hit the ground in 20 timesteps. Here's the notebook: https://colab.research.google.com/drive/1btgxkX640FTGysYmlWmmgG2BXMfPrx05?usp=sharing
Is differentiating through contacts bugged?
The text was updated successfully, but these errors were encountered: