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

[systems/lcm] Use shared_ptr for LCM serializers #19369

Merged

Conversation

jwnimmer-tri
Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri commented May 6, 2023

Towards #19250. Undoes #15394.

  • Anzu CI passed.

This change is Reviewable

@jwnimmer-tri jwnimmer-tri marked this pull request as ready for review May 6, 2023 02:21
@jwnimmer-tri jwnimmer-tri force-pushed the rm-uniqueptr-lcmserializer branch from 0d69707 to d535da8 Compare May 9, 2023 22:17
@jwnimmer-tri jwnimmer-tri added release notes: newly deprecated This pull request contains new deprecations release notes: fix This pull request contains fixes (no new features) labels May 9, 2023
@jwnimmer-tri jwnimmer-tri force-pushed the rm-uniqueptr-lcmserializer branch from d535da8 to 8debfbe Compare May 9, 2023 23:05
@jwnimmer-tri jwnimmer-tri force-pushed the rm-uniqueptr-lcmserializer branch from 8debfbe to b81a91c Compare May 9, 2023 23:21
@jwnimmer-tri
Copy link
Collaborator Author

+@EricCousineau-TRI do you have time for feature review? (Or at least, design review?)

Copy link
Contributor

@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.

:lgtm: feature + design!
+@sherm1 for platform review, please!

Reviewed 11 of 12 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee sherm1(platform) (waiting on @sherm1)


-- commits line 8 at r2:
BTW I'm not sure if it'd be completely useless, but yeah, I can't think of a workflow that would merit it for now.

Copy link
Collaborator Author

@jwnimmer-tri jwnimmer-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: 1 unresolved discussion, LGTM missing from assignee sherm1(platform) (waiting on @sherm1)


-- commits line 8 at r2:

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

BTW I'm not sure if it'd be completely useless, but yeah, I can't think of a workflow that would merit it for now.

I should amend the commit message when we merge.

My main reason to deprecate is that our "is cloneable" signature class Foo { virtual unique_ptr<Foo> Clone() = 0; } is extremely difficult to override correctly in Python, where unique ownership requires dangerous games with identifying shared_ptr use_count == 1 and then stealing the object.

So the reasoning for removal is more like "very little value + very high complexity".

Copy link
Member

@sherm1 sherm1 left a comment

Choose a reason for hiding this comment

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

Platform :lgtm: pending one request for clarification.

Reviewed 11 of 12 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: 2 unresolved discussions


systems/lcm/serializer.h line 20 at r2 (raw file):

 * %SerializerInterface translates between LCM message bytes and
 * drake::AbstractValue objects that contain LCM messages, e.g., a
 * Value<lcmt_drake_signal>.  All `const` methods should be threadsafe.

minor: not clear how to interpret this sentence. Is it an instruction to developers about how to write const methods ("must be threadsafe") or a promise to users of the class ("const methods are threadsafe")? Please clarify.

For a given message type, it's OK to use one const serializer across
all systems that publish or subscribe for efficiency. This also allows
us to greatly simplify the Python bindings.

Deprecate SerializerInterface::Clone. It now has very little upside,
but is extremely difficult to override correctly in Python.
@jwnimmer-tri jwnimmer-tri force-pushed the rm-uniqueptr-lcmserializer branch from b81a91c to c9b02b9 Compare May 10, 2023 17:56
Copy link
Collaborator Author

@jwnimmer-tri jwnimmer-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: 2 unresolved discussions


systems/lcm/serializer.h line 20 at r2 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

minor: not clear how to interpret this sentence. Is it an instruction to developers about how to write const methods ("must be threadsafe") or a promise to users of the class ("const methods are threadsafe")? Please clarify.

Hmm, it's both. I tried some working that is hopefully better. WDYT?

Copy link
Member

@sherm1 sherm1 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 1 files at r3, all commit messages.
Reviewable status: 1 unresolved discussion


systems/lcm/serializer.h line 20 at r2 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Hmm, it's both. I tried some working that is hopefully better. WDYT?

This is good, thanks. The contract term for the user is all you need -- developers are automatically bound to deliver it.

@jwnimmer-tri jwnimmer-tri merged commit fd48af2 into RobotLocomotion:master May 10, 2023
@jwnimmer-tri jwnimmer-tri deleted the rm-uniqueptr-lcmserializer branch May 10, 2023 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low release notes: fix This pull request contains fixes (no new features) release notes: newly deprecated This pull request contains new deprecations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants