-
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
Deprecate CalcCenterOfMassPosition() in favor of CalcCenterOfMassPositionInWorld(). #14538
Deprecate CalcCenterOfMassPosition() in favor of CalcCenterOfMassPositionInWorld(). #14538
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feature review +@EricCousineau-TRI
Hi Eric -- I was hoping you might review this hopefully straight-forward PR.
It is mostly a "cut and paste", with a small effect on python, so I was hoping you might take a look.
Reviewable status: LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers (waiting on @EricCousineau-TRI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, sounds good! Just needs Python deprecations.
Reviewed 8 of 9 files at r1.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 286 at r1 (raw file):
// overload that (a) services MBP directly and (b) uses body // association that is less awkward than implicit BodyNodeIndex. .def("CalcCenterOfMassPositionInWorld",
This is not backwards compatible; it requires deprecation in Python too.
See:
https://drake.mit.edu/code_review_checklist.html#is-the-code-the-minimal-set-of-what-you-want
https://drake.mit.edu/doxygen_cxx/group__python__bindings.html#PydrakeDeprecation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
py::arg("context"), py::arg("model_instances"), cls_doc.CalcCenterOfMassPosition.doc_2args) #pragma GCC diagnostic pop
I looked at the deprecation_example, but it was not immediately obvious how to apply it to what might be a simpler problem. Here is my first guess, but it does not pass CI and it is unclear how many guesses I will make before converging.
I just talked to Sherm and he said you might be able to help get me back on track.
Do you have a simple example in which a single method (rather than parts of an entire class) are deprecated? Or perhaps you can point me to a tiny PR that accomplishes what I am trying to do.
Note: Perhaps a simpler deprecation example would be helpful to understand what needs to be added to the file (perhaps some #includes) and the strategy to place some #pragmas, and any other pitfalls. It is difficult to see how this specific problem gets fixed as the example addresses a more complicated problem.
Once I get the simplest concept down, and see how to extend it a little, I usually can extrapolate from there. I have a more difficult time trying to a generalization and making it more specific. I blame my elementary math teachers who taught me how to add 3 + 5 rather than matrices -- hopefully your Mathworks background made you smile :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
Did you see these two examples and the preceding comments, and review the documentation that exists regarding docstrings (e.g. .doc_deprecated
)?
// Bind deprecated overload. | |
#pragma GCC diagnostic push | |
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
cls.def("overload", | |
WrapDeprecated(cls_doc.overload.doc_deprecated, | |
py::overload_cast<int>(&ExampleCppClass::overload)), | |
cls_doc.overload.doc_deprecated); | |
#pragma GCC diagnostic pop | |
// Bind entirely deprecated method. | |
#pragma GCC diagnostic push | |
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
cls.def("DeprecatedMethod", &ExampleCppClass::DeprecatedMethod, | |
cls_doc.DeprecatedMethod.doc_deprecated); | |
#pragma GCC diagnostic pop | |
DeprecateAttribute( | |
cls, "DeprecatedMethod", cls_doc.DeprecatedMethod.doc_deprecated); |
[...] is unclear how many guesses I will make before converging.
The fact that your write "guess" given that docs and code exist is part of the problem ;)
But yeah, let's address the general readability of this example in a separate PR that I will start, and then you can take lessons learned and apply it here.
Sound good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
Did you see these two examples and the preceding comments, and review the documentation that exists regarding docstrings (e.g.
.doc_deprecated
)?
// Bind deprecated overload. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" cls.def("overload", WrapDeprecated(cls_doc.overload.doc_deprecated, py::overload_cast<int>(&ExampleCppClass::overload)), cls_doc.overload.doc_deprecated); #pragma GCC diagnostic pop // Bind entirely deprecated method. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" cls.def("DeprecatedMethod", &ExampleCppClass::DeprecatedMethod, cls_doc.DeprecatedMethod.doc_deprecated); #pragma GCC diagnostic pop DeprecateAttribute( cls, "DeprecatedMethod", cls_doc.DeprecatedMethod.doc_deprecated); [...] is unclear how many guesses I will make before converging.
The fact that your write "guess" given that docs and code exist is part of the problem ;)
But yeah, let's address the general readability of this example in a separate PR that I will start, and then you can take lessons learned and apply it here.
Sound good?
Correction: [...] given that docs, code, and compiler errors exist [...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
Correction: [...] given that docs, code, and compiler errors exist [...]
See minimum-effort PR here for easier-to-cargo-cult examples:
#14546
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
hopefully your Mathworks background made you smile :)
And hehe, yup!
… MultibodyPlant::CalcCenterOfMassPosition().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EricCousineau-TRI Thanks for taking time for the f2f. I updated multibody_plant.h.
Thanks for agreeing to showing me how to deprecate the API in the Python/C++ bindings.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 9 files at r1, 1 of 2 files at r3.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
hopefully your Mathworks background made you smile :)
And hehe, yup!
See PR that fixes the deprecation:
https://github.com/mitiguy/drake/pull/4/files
multibody/plant/test/multibody_plant_com_test.cc, line 24 at r3 (raw file):
auto context_ = plant.CreateDefaultContext(); DRAKE_EXPECT_THROWS_MESSAGE( plant.CalcCenterOfMassPositionInWorld(*context_),
This file still needs to do a basic test of the deprecated API.
Please test that the deprecated API still exists within a #pragma...
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
bindings/pydrake/multibody/plant_py.cc, line 299 at r2 (raw file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
See PR that fixes the deprecation:
https://github.com/mitiguy/drake/pull/4/files
(You'll want to merge it in here, of course!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
a discussion (no related file):
FYI Requires a deps update:
https://drake-cdash.csail.mit.edu/test/109660810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EricCousineau-TRI
Ugh -- I am sure I am doing something silly, but this does not pass CI.
From the error stack on CI, it seems like the error points to:
File: plant_test.py, line 76 which is:
from pydrake.common.test_utilities.deprecation import catch_drake_warnings
ModuleNotFoundError: No module named 'pydrake.common.test_utilities.deprecation'
I looked for ModuleNotFoundError with Drake and found these issues -- but am unsure if they are relevant.
#11005
https://stackoverflow.com/questions/62292888/building-and-using-pydrake-from-source
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
multibody/plant/test/multibody_plant_com_test.cc, line 24 at r3 (raw file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
This file still needs to do a basic test of the deprecated API.
Please test that the deprecated API still exists within a
#pragma...
block.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just missing Bazel deps:
61d53483f8#diff-e7881d2775f3e47f7b244280446b48d080e23710d79a218171114ad447578870R477
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
a discussion (no related file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
FYI Requires a deps update:
https://drake-cdash.csail.mit.edu/test/109660810
@mitiguy Did you see this comment?
Per prior PR:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI and @mitiguy)
a discussion (no related file):
Previously, EricCousineau-TRI (Eric Cousineau) wrote…
@mitiguy Did you see this comment?
Per prior PR:
OK Oops. Sorry, meant to strike out this message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r4.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @mitiguy)
…is is probably insufficient/wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EricCousineau-TRI
This is nearing completion and may (or may not) just have a single typo.
Thank you for your help thus far. PTAL.
Reviewed 5 of 9 files at r1, 1 of 2 files at r3, 1 of 3 files at r4, 1 of 1 files at r5, 2 of 2 files at r6.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee EricCousineau-TRI(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits)
bindings/pydrake/multibody/plant_py.cc, line 299 at r6 (raw file):
overload_cast_explicit<Vector3<T>, const Context<T>&, const std::vector<ModelInstanceIndex>&>( &Class::CalcCenterOfMassPositionInWorld)),
@EricCousineau-TRI
I cut and paste from your very helpful example from:
https://github.com/mitiguy/drake/pull/4/files
I was wondering if the previous line should instead be:
&Class::CalcCenterOfMassPosition)),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+@sammy-tri for platform review, please!
Reviewed 1 of 1 files at r5, 2 of 2 files at r6.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee sammy-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @mitiguy and @sammy-tri)
bindings/pydrake/multibody/plant_py.cc, line 299 at r6 (raw file):
Previously, mitiguy (Mitiguy) wrote…
@EricCousineau-TRI
I cut and paste from your very helpful example from:
https://github.com/mitiguy/drake/pull/4/filesI was wondering if the previous line should instead be:
&Class::CalcCenterOfMassPosition)),
Ah, yup, that was a typo on my part! It should be the deprecated overload, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sammy-tri I fixed typo and if this passes CI, it is ready for your platform review.
Reviewed 1 of 1 files at r7.
Reviewable status: LGTM missing from assignee sammy-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @sammy-tri)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r7.
Reviewable status: LGTM missing from assignee sammy-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @sammy-tri)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 9 files at r1, 1 of 2 files at r3, 1 of 3 files at r4, 2 of 2 files at r6, 1 of 1 files at r7.
Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+(status: squashing now)
Reviewable status: complete! all discussions resolved, LGTM from assignees sammy-tri(platform),EricCousineau-TRI(platform)
Remember to round up all deprecation dates to the first of the month, otherwise we tend to miss when they come due (#15050). |
Ah, sorry for missing that! |
Resolves issue #14537
This change is