Skip to content
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

py geometry: Expose RenderEngine API and trampoline for inheritance #13835

Conversation

EricCousineau-TRI
Copy link
Contributor

@EricCousineau-TRI EricCousineau-TRI commented Aug 6, 2020

Resolves #13834

FYI @thduynguyen and @SeanCurtis-TRI Review will be coming y'all's way once this is ready ;)


This change is Reviewable

@EricCousineau-TRI
Copy link
Contributor Author

@thduynguyen Handing off to you for completion. Feel free to push here and/or start a separate PR.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+@thduynguyen for finishing up

Reviewable status: LGTM missing from assignee thduynguyen, needs platform reviewer assigned, needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @thduynguyen)

@EricCousineau-TRI
Copy link
Contributor Author

See PR: EricCousineau-TRI#13

@EricCousineau-TRI
Copy link
Contributor Author

Tagging @takuya-ikeda-tri

@EricCousineau-TRI
Copy link
Contributor Author

@thduynguyen Does this happen to have your latest changes? (I just merged your PR in)

@EricCousineau-TRI
Copy link
Contributor Author

From Duy:
thduynguyen@fbe17ba

@EricCousineau-TRI EricCousineau-TRI force-pushed the issue-13834-py-render-engine branch 2 times, most recently from fe08ebf to d05a866 Compare October 20, 2020 22:04
@EricCousineau-TRI EricCousineau-TRI marked this pull request as ready for review October 20, 2020 22:04
Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+@thduynguyen for feature review, please
+@SeanCurtis-TRI for platform review, please

Reviewable status: LGTM missing from assignees SeanCurtis-TRI(platform),thduynguyen (waiting on @SeanCurtis-TRI and @thduynguyen)

Copy link
Contributor

@thduynguyen thduynguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: with some nits. Thanks!

Reviewed 1 of 2 files at r1.
Reviewable status: 4 unresolved discussions, LGTM missing from assignee SeanCurtis-TRI(platform) (waiting on @EricCousineau-TRI, @SeanCurtis-TRI, and @thduynguyen)


bindings/pydrake/test/geometry_test.py, line 18 at r1 (raw file):

from pydrake.common.value import AbstractValue, Value
from pydrake.lcm import DrakeLcm, Subscriber
from pydrake.math import RigidTransform, RigidTransform_

BTW, what's the difference between RigidTransform and RigidTransform_? There are many re-definitions of RigidTransform = RigidTransform_[float] below in this file and that causes confusion. Can you either remove this or change the aliases to RigidTransformf?


bindings/pydrake/test/geometry_test.py, line 636 at r1 (raw file):

        Value[mut.render.RenderLabel]

    def test_render_camera_api(self):

BTW, are these 2 lines needed?


bindings/pydrake/test/geometry_test.py, line 643 at r1 (raw file):

            """Mirror of C++ DummyRenderEngine."""

            latest_intance = None

nit, variable name typo: latest_instance


bindings/pydrake/test/geometry_test.py, line 643 at r1 (raw file):

            """Mirror of C++ DummyRenderEngine."""

            latest_intance = None

nit, can you add a comment here stating this's only needed for testing (and why)?


bindings/pydrake/test/geometry_test.py, line 682 at r1 (raw file):

            def ImplementGeometry(self, shape, user_data):
                DummyRenderEngine.latest_instance = self
                pass

nit, redundant pass.


bindings/pydrake/test/geometry_test.py, line 703 at r1 (raw file):

            def DoClone(self):
                DummyRenderEngine.latest_instance = self

nit, shouldn't latest_instance = new in this case?

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: LGTM missing from assignee SeanCurtis-TRI(platform) (waiting on @SeanCurtis-TRI and @thduynguyen)


bindings/pydrake/test/geometry_test.py, line 18 at r1 (raw file):

Previously, thduynguyen (Duy-Nguyen Ta) wrote…

BTW, what's the difference between RigidTransform and RigidTransform_? There are many re-definitions of RigidTransform = RigidTransform_[float] below in this file and that causes confusion. Can you either remove this or change the aliases to RigidTransformf?

OK I'd like to keep it as-is for now. See here:
https://drake.mit.edu/python_bindings.html#differences-with-c-api

(Could consider as a separate PR focused on that, but I wanna punt for now ;)


bindings/pydrake/test/geometry_test.py, line 636 at r1 (raw file):

Previously, thduynguyen (Duy-Nguyen Ta) wrote…

BTW, are these 2 lines needed?

Done. Oops!


bindings/pydrake/test/geometry_test.py, line 643 at r1 (raw file):

Previously, thduynguyen (Duy-Nguyen Ta) wrote…

nit, variable name typo: latest_instance

Done. Oops as well!


bindings/pydrake/test/geometry_test.py, line 643 at r1 (raw file):

Previously, thduynguyen (Duy-Nguyen Ta) wrote…

nit, can you add a comment here stating this's only needed for testing (and why)?

Done.


bindings/pydrake/test/geometry_test.py, line 682 at r1 (raw file):

Previously, thduynguyen (Duy-Nguyen Ta) wrote…

nit, redundant pass.

Done.


bindings/pydrake/test/geometry_test.py, line 703 at r1 (raw file):

Previously, thduynguyen (Duy-Nguyen Ta) wrote…

nit, shouldn't latest_instance = new in this case?

OK Nah, that smells a tad odd. I can explain more if you like.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-@SeanCurtis-TRI +@sammy-tri for platform, please!

Reviewable status: LGTM missing from assignee sammy-tri(platform) (waiting on @sammy-tri and @thduynguyen)

@EricCousineau-TRI
Copy link
Contributor Author

Removed excess bindings / using statements, and made a comment here: #13834 (comment)

PTAL!

@EricCousineau-TRI
Copy link
Contributor Author

Er... On second though, mayhaps I should keep the pure virtual NVI methods?
Otherwise, they won't appear in Sphinx docs....

Copy link
Contributor

@sammy-tri sammy-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r1, 1 of 1 files at r2, 1 of 1 files at r3.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee sammy-tri(platform) (waiting on @EricCousineau-TRI)


bindings/pydrake/geometry_py.cc, line 316 at r3 (raw file):

                &Class::default_render_label),
            cls_doc.default_render_label.doc)
        .def("GetRenderLabelOrThrow",

is it worth adding a comment explaining that we're deliberately binding to the trampoline even though https://pybind11.readthedocs.io/en/stable/advanced/classes.html#overriding-virtual-functions-in-python says not to? (I assume it's something to do with moving these functions into the public section).

Co-Authored-By: Duy-Nguyen Ta <duynguyen.ta@tri.global>
Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per Slack, will keep the pure virtual NVI methods out for now. Yes, there may be a lack of docs; we can always come back and cherry-pick from r2 if need be.

Reviewable status: 1 unresolved discussion, LGTM missing from assignee sammy-tri(platform) (waiting on @sammy-tri)


bindings/pydrake/geometry_py.cc, line 316 at r3 (raw file):

Previously, sammy-tri (Sam Creasey) wrote…

is it worth adding a comment explaining that we're deliberately binding to the trampoline even though https://pybind11.readthedocs.io/en/stable/advanced/classes.html#overriding-virtual-functions-in-python says not to? (I assume it's something to do with moving these functions into the public section).

Done. Thanks!

Copy link
Contributor

@sammy-tri sammy-tri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r4.
Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignees sammy-tri(platform),thduynguyen

@EricCousineau-TRI
Copy link
Contributor Author

Skipping slow build

@SeanCurtis-TRI
Copy link
Contributor

@thduynguyen @EricCousineau-TRI

In looking at the bindings in PyRenderEngine, we've bound the API that should be deprecated (the ones that take CameraProperties and DepthCameraProperties). Life would be easiest if we can simply kill those APIs from the bindings. All rendering logic should be in the DoRender*Image methods and not in the Render*Image methods.

Given it's only been 16 days since the merge, do you think we can get away with this (without deprecation, that is)?

@EricCousineau-TRI
Copy link
Contributor Author

Yeah, I'd be fine with that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

py geometry: Should permit RenderEngine to be extended in Python
4 participants