Skip to content

Nanobind transition - #24749

Open
rpoyner-tri wants to merge 508 commits into
RobotLocomotion:masterfrom
rpoyner-tri:nanobind-transition
Open

Nanobind transition#24749
rpoyner-tri wants to merge 508 commits into
RobotLocomotion:masterfrom
rpoyner-tri:nanobind-transition

Conversation

@rpoyner-tri

@rpoyner-tri rpoyner-tri commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This is a review refresh from work done in #24513 towards #21572.


This change is Reviewable

jwnimmer-tri and others added 30 commits July 6, 2026 13:04
Add a pybind11::callable alias and switch everywhere to use it.
The prior spelling of constructors was ambiguous for nanobind.

@jwnimmer-tri jwnimmer-tri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We are down to only 1770 lines remaining!

@jwnimmer-tri reviewed 11 files and all commit messages, made 2 comments, and resolved 1 discussion.
Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, labeled "do not merge", commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on rpoyner-tri).


bindings/pydrake/pydrake_pybind.h line 451 at r5 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Working

It's likely that PYDRAKE_OVERRIDE doesn't work at all. All of the remaining instances on this branch are in dead code. The non-dead uses of this all had to be ported to work around the NVI snafu.

Most likely, we should revert this polyfill (or else reimplement it to work correctly.)

Done. Replaced with polyfill.

@jwnimmer-tri jwnimmer-tri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jwnimmer-tri partially reviewed 20 files and all commit messages, and made 1 comment.
Reviewable status: 4 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, labeled "do not merge", commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes.


bindings/pydrake/common/sorted_pair_pybind.h line 61 at r24 (raw file):

      return false;
    }
    return true;

Working

This isn't actually setting the value? Maybe we're missing some tests.

@rpoyner-tri rpoyner-tri left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rpoyner-tri made 1 comment.
Reviewable status: 4 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, labeled "do not merge", commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on jwnimmer-tri).


bindings/pydrake/common/sorted_pair_pybind.h line 61 at r24 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Working

This isn't actually setting the value? Maybe we're missing some tests.

IIRC, the "value" is squirreled away in InnerCaster values as a side-effect of their invocations, and then reconstructed by the Value operator. Are you seeing a symptom?

@jwnimmer-tri jwnimmer-tri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jwnimmer-tri made 1 comment.
Reviewable status: 4 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, labeled "do not merge", commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes.


bindings/pydrake/common/sorted_pair_pybind.h line 61 at r24 (raw file):

Previously, rpoyner-tri (Rick Poyner (rico)) wrote…

IIRC, the "value" is squirreled away in InnerCaster values as a side-effect of their invocations, and then reconstructed by the Value operator. Are you seeing a symptom?

No symptoms, just spotted while reading the code.

I see the logic now, down below. If it remains this way, I'll need to add a comment here so the next reader isn't also confused.

Still, I might try porting to use the NB_TYPE_CASTER macro so that it's more similar to other casters.

@rpoyner-tri rpoyner-tri left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rpoyner-tri made 1 comment.
Reviewable status: 4 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, labeled "do not merge", commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on jwnimmer-tri).


bindings/pydrake/common/sorted_pair_pybind.h line 61 at r24 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

No symptoms, just spotted while reading the code.

I see the logic now, down below. If it remains this way, I'll need to add a comment here so the next reader isn't also confused.

Still, I might try porting to use the NB_TYPE_CASTER macro so that it's more similar to other casters.

I believe this structure resulted from following the nanobind doc advice to use https://github.com/wjakob/nanobind/blob/master/include/nanobind/stl/pair.h as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants