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

Meta issue: easier way to interface controllers to MultibodyPlant #12203

Open
edrumwri opened this issue Oct 16, 2019 · 9 comments
Open

Meta issue: easier way to interface controllers to MultibodyPlant #12203

edrumwri opened this issue Oct 16, 2019 · 9 comments
Assignees
Labels

Comments

@edrumwri
Copy link
Collaborator

(This issue has arisen from discussions resulting from PR #12011).

We can imagine an easier way to interface controllers to MultibodyPlant, generally, than at present. The difficulty with the present approach only arises when only some bodies in a MBP are controlled.

Two anecdotal problems:

  1. A MBP contains multiple model instances that are to be controlled as a single unit (e.g., Rick's planar example that consists of a single model duplicated twice more). The controllers (PID, inverse dynamics, etc.) do not "know" about model instances, and no ready procedure exists for demultiplexing the controller outputs to the actuator inputs.
  2. At least some controllers (PID, inverse dynamics) output vectors in generalized-velocity-coordinates, which is the same dimension (at least for ID) as the actuation inputs. It's too easy to connect the control outputs to the wrong port. In my experience, the order of actuation has been identical to the order of generalized velocities, but only when a MBP has a single model instance.

Solving the problems above might require more than one approach (e.g., using typed input ports for (2) and some intermediate Systems for (1)).

We'll continue to gather information (problems and potential solutions) in this issue.

@rcory @SeanCurtis-TRI @amcastro-tri

@amcastro-tri
Copy link
Contributor

IMO the best way to go with this is working on a specific example (with pseudocode allowed). @rcory, @edrumwri recently mentioned to me that you might have such an example?

@sherm1 sherm1 assigned sherm1 and rcory and unassigned edrumwri Feb 25, 2020
@sherm1
Copy link
Member

sherm1 commented Feb 25, 2020

@rcory do you think this is still an issue? Or should we close it?

@rcory
Copy link
Contributor

rcory commented Feb 25, 2020

I think this is still a valid issue. For an example, see this method in planar_gripper_simulation which defines a local system which demultiplexes the inverse dynamics outputs to MBP actuator inputs. This seems like a common enough use case that perhaps MBP should support this natively?

@amcastro-tri
Copy link
Contributor

I believe the problem you have @rcory could be solved with some improvements to the InverseDynamicsController. What I propose is:

  1. New constructor's signature taking the full model of the plant and a model instance of the particular model to control.
  2. We add an output port to the ID controller with exactly the right format MBP needs to consume. This might not be needed if we use the output generalized forces.

Then in your example you would not need the extra GeneralizedForceToActuationOrdering since the ID controller's output would wire directly to the plant of the whole world.

Thoughts?

@EricCousineau-TRI
Copy link
Contributor

EricCousineau-TRI commented May 19, 2020

Per comment here: #13074 (comment)

I believe my prototype can help workaround some of these pain points - e.g. rather than trying to craft a whole bunch of model instances / coordinates for accessing portions of a plant, just reconstruct the plant (cheaply).

@amcastro-tri
Copy link
Contributor

The last time I wrote here was "thoughts?". Wondering if the solution I described above would not only suffice but be appropriate and, its probably simpler?
That is, if I build an InverseDynamicsController with a full model of the world when I just want to control an arm in it, how can I expect to get the right output/inputs? that is why my suggestion.

@EricCousineau-TRI
Copy link
Contributor

In my mind, I think the solution you described above is more complex; why write yet another overload in MBP / the controller to do the same computation, but only on a subset, add complexity to your testing code, deprecations, etc., when all you really need to do is just copy over a subset?

how can I expect to get the right output/inputs?

Is it just ordering? There can be ways to guarantee that through MBP's construction, or just adding a basic remapping on the port or whatever.

@amcastro-tri
Copy link
Contributor

Is it just ordering? There can be ways to guarantee that through MBP's construction, or just adding a basic remapping on the port or whatever.

That's exactly right. IMO is not that simple (yes, I can hack the code myself), but clearly not simple for most users who have expressed this being the biggest pain point. Designing a general solution to extract a sub-plant and the remap, for a final product in Drake, will require some thought (totally worth it!).

But again, I just think we are asking too much from the InverseDynamicsController API, which was originally written to deal with a small robot model.

@EricCousineau-TRI
Copy link
Contributor

But again, I just think we are asking too much from the InverseDynamicsController API, which was originally written to deal with a small robot model.

Can you expand on "asking too much"?

If you mean, "adding overload(s) for dealing with only a subset of the plant", then I am 100% on board with that statement!

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

No branches or pull requests

7 participants