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

Add ExternallyAppliedSpatialForceMultiplexer #18171

Merged

Conversation

EricCousineau-TRI
Copy link
Contributor

@EricCousineau-TRI EricCousineau-TRI commented Oct 24, 2022

Resolves #13139
Relates #16923

py plant:

  • Remove unneeded qualifier for ExternallyAppliedSpatialForce
  • test_propeller: Use body name rather than magic number

adder_test:

  • Add check for discrete number of states
  • Use std::make_unique instead of .reset()

\cc @amcastro-tri @jwnimmer-tri


This change is Reviewable

py plant:
- Remove unneeded qualifier for ExternallyAppliedSpatialForce
- test_propeller: Use body name rather than magic number

adder_test:
- Add check for discrete number of states
- Use std::make_unique instead of .reset()
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.

+@RussTedrake Might you have time for quick feature review?

Reviewable status: LGTM missing from assignee RussTedrake(platform), needs at least two assigned reviewers, missing label for release notes (waiting on @RussTedrake)

Copy link
Contributor

@RussTedrake RussTedrake 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 just a few comments below. thanks!
+@sherm1 for platform review, please.

Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: 2 unresolved discussions, LGTM missing from assignee sherm1(platform), missing label for release notes (waiting on @EricCousineau-TRI and @sherm1)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 16 at r1 (raw file):

@system
name: ExternallyAppliedSpatialForceMultiplexer

nit: can we make it clear that the inputs are still std::vector (as opposed to just ExternallyAppliedSpatialForce elements by themselves)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 41 at r1 (raw file):

  */

  explicit ExternallyAppliedSpatialForceMultiplexer(int num_inputs);

nit: strange whitespace (between the comment and the method, but then no whitespace after...?

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 sherm1(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @RussTedrake and @sherm1)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 16 at r1 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

nit: can we make it clear that the inputs are still std::vector (as opposed to just ExternallyAppliedSpatialForce elements by themselves)

Done, I think?
Though admittedly, this name is now super long.

Should I just revert, and denote input port types instead?


multibody/plant/externally_applied_spatial_force_multiplexer.h line 41 at r1 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

nit: strange whitespace (between the comment and the method, but then no whitespace after...?

Done. Oops!

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: 1 unresolved discussion, LGTM missing from assignee sherm1(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @RussTedrake and @sherm1)

a discussion (no related file):
Working: Mark revision.


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.

Russ / Sherm, if y'all have a chance, please look at base..r2 and base..r3 and let me know which names you prefer.

Reviewable status: LGTM missing from assignee sherm1(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @RussTedrake and @sherm1)

a discussion (no related file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Working: Mark revision.

Done. Restored shorter name, relied on docs.


Copy link
Contributor

@RussTedrake RussTedrake 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 5 files at r3.
Reviewable status: LGTM missing from assignee sherm1(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @sherm1)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 16 at r1 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Done, I think?
Though admittedly, this name is now super long.

Should I just revert, and denote input port types instead?

I prefer the shorter name. I just want it to be clear in the docs.

Copy link
Contributor

@RussTedrake RussTedrake left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 5 files at r3, all commit messages.
Reviewable status: LGTM missing from assignee sherm1(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @sherm1)

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 sherm1(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @sherm1)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 16 at r1 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

I prefer the shorter name. I just want it to be clear in the docs.

OK Thanks!

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.

I also prefer the shorter name.

"Combining" forces usually means adding them together, which is what I expected here at first. I see that what is actually happening is concatenation, rather than combining. To avoid confusion, please consider saying that explicitly here and naming the output port "concatenated" rather than "combined".

Platform :lgtm: pending a few minor things.

Reviewed 2 of 7 files at r1, 5 of 5 files at r3, all commit messages.
Reviewable status: 5 unresolved discussions, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @EricCousineau-TRI)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 13 at r3 (raw file):

/**
Combines multiple std::vector<>'s of ExternallyAppliedSpatialForce<T>.

BTW Combines->Concatenates

Also consider promising that the inputs are concatenated in order of input port number, or say explicitly that the concatenation order is undefined. (I mildly prefer the former because I think that's what users would expect.)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 22 at r3 (raw file):

- u(N-1)
output_ports:
- combined

BTW consider "concatenated" rather than "combined" per comment above


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 16 at r3 (raw file):

namespace {

using ListType = std::vector<ExternallyAppliedSpatialForce<double>>;

BTW better to tie this to the dut. Consider:

Code snippet:

using ListType = 
    ExternallyAppliedSpatialForceMultiplexer<double>::ListType;

multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 75 at r3 (raw file):

// Tests that the system computes the correct sum.
TEST_F(ExternallyAppliedSpatialForceMultiplexerTest, AddTwoVectors) {

nit: sum -> concatenation, AddTwoVectors -> ConcatenateTwoVectors


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 94 at r3 (raw file):

// Asserts that adders have direct-feedthrough from all inputs to the output.
TEST_F(ExternallyAppliedSpatialForceMultiplexerTest, AdderIsDirectFeedthrough) {

nit: adders, Adder -> multiplexers, Multiplexer

@jwnimmer-tri
Copy link
Collaborator

multibody/plant/externally_applied_spatial_force_multiplexer.h line 34 at r3 (raw file):

  using ValueType = ExternallyAppliedSpatialForce<T>;
  using ListType = std::vector<ValueType>;

nit If we're going to publish these as public types, then we need to Doxygen-document them.

(My own preference would be to bury them in 'private' anyway. They don't appear to be useful to users at all.)

@jwnimmer-tri
Copy link
Collaborator

multibody/plant/externally_applied_spatial_force_multiplexer.h line 22 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

BTW consider "concatenated" rather than "combined" per comment above

FWIW my 2c would be just y0 for consistency since that's what https://drake.mit.edu/doxygen_cxx/classdrake_1_1systems_1_1_multiplexer.html calls it and it likewise that system also does concatenation.

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: 1 unresolved discussion, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @RussTedrake and @sherm1)


multibody/plant/externally_applied_spatial_force_multiplexer.h line 13 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

BTW Combines->Concatenates

Also consider promising that the inputs are concatenated in order of input port number, or say explicitly that the concatenation order is undefined. (I mildly prefer the former because I think that's what users would expect.)

Done.


multibody/plant/externally_applied_spatial_force_multiplexer.h line 22 at r3 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

FWIW my 2c would be just y0 for consistency since that's what https://drake.mit.edu/doxygen_cxx/classdrake_1_1systems_1_1_multiplexer.html calls it and it likewise that system also does concatenation.

Done, going for y0


multibody/plant/externally_applied_spatial_force_multiplexer.h line 34 at r3 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

nit If we're going to publish these as public types, then we need to Doxygen-document them.

(My own preference would be to bury them in 'private' anyway. They don't appear to be useful to users at all.)

Done.


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 16 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

BTW better to tie this to the dut. Consider:

OK Buried privately, but thanks!


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 75 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

nit: sum -> concatenation, AddTwoVectors -> ConcatenateTwoVectors

Done.


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 94 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

nit: adders, Adder -> multiplexers, Multiplexer

Done. Removed qualifier (sufficiently informative, IMO)

@jwnimmer-tri
Copy link
Collaborator

multibody/plant/externally_applied_spatial_force_multiplexer.cc line 22 at r4 (raw file):

    }
    this->DeclareAbstractOutputPort(
        "combined",

typo

Suggestion:

"y0"

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: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @RussTedrake and @sherm1)


multibody/plant/externally_applied_spatial_force_multiplexer.cc line 22 at r4 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

typo

Done. D'oh, thanks! Used kUseDefaultName

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 2 of 2 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @EricCousineau-TRI)


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 75 at r3 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Done.

Still says "sum" in the comment above.


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 94 at r3 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Done. Removed qualifier (sufficiently informative, IMO)

Still says "adder" in the comment above

Copy link
Contributor

@RussTedrake RussTedrake left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @EricCousineau-TRI)

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: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @RussTedrake and @sherm1)


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 75 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

Still says "sum" in the comment above.

Done.


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 94 at r3 (raw file):

Previously, sherm1 (Michael Sherman) wrote…

Still says "adder" in the comment above

Done. Sorry!

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 r6, all commit messages.
Reviewable status: commits need curation (https://drake.mit.edu/reviewable.html#curated-commits), missing label for release notes (waiting on @EricCousineau-TRI)


multibody/plant/test/externally_applied_spatial_force_multiplexer_test.cc line 94 at r3 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Done. Sorry!

No worries!

@EricCousineau-TRI EricCousineau-TRI added status: squashing now https://drake.mit.edu/reviewable.html#curated-commits release notes: feature This pull request contains a new feature labels Oct 26, 2022
@EricCousineau-TRI EricCousineau-TRI merged commit 8fde778 into RobotLocomotion:master Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: feature This pull request contains a new feature status: squashing now https://drake.mit.edu/reviewable.html#curated-commits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need a ValueMultiplexer or at very least ExternalAppliedSpatialForceMultiplexer
4 participants