-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MultibodyPlant should check Context validity #11252
Comments
would you prefer ASSERT (only debug) or DEMAND? |
Context-validating is potentially very expensive. |
I think ASSERT, definitely. |
See related issue #11801. |
Should this be an MBP feature or a |
The check proposed by #12564 should never be disarmed (i.e., not only in Debug builds). For the "correctly-mated System vs Context" checking:
|
Agreed. Eventually you would probably hit a framework method that would barf on the mismatch, but the delayed detection would be less helpful for users. (Would be better if the ValidateContext method would report the name of the failing API though.) |
I think that #14389 resolved this. |
While #14389 resolved the issue for MbP's direct API, there are several other public classes on the MbT-related side that still lack calls to |
How expensive are those ValidateContext()? can they safely be placed on release builds? |
Per its API Doc, calling PR #14389 already added the checks to all of the MbP methods. What's still needed here is to add it to any of the |
@amcastro-tri do you have any work-in-progress on this? If not, I think i have a patch that should do the job. |
Closes RobotLocomotion#11252. Since all of the context-taking methods in multibody/tree lead eventually to MultiBodyTreeSystem, ensure that all of its public methods validate the context.
Your patch is excellent. Thanks @rpoyner-tri! |
Closes #11252. Since all of the context-taking methods in multibody/tree lead eventually to MultiBodyTreeSystem, ensure that all of its public methods validate the context.
In #15489, I found that |
Passing a diagram context into
Frame::CalcPose()
results in the following assertion:I spent a fair few minutes wondering what had gone wrong in my diagram before I realized that the issue was a context mismatch. If the assertion had come from a
MultibodyPlant
method this would have been more apparent. We could addin user-facing non-systems-framework methods of
MultibodyPlant
.The text was updated successfully, but these errors were encountered: