RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.35k stars 1.27k forks source link

Force element contributions are confusing? #13476

Open mposa opened 4 years ago

mposa commented 4 years ago

There is currently no easy way to calculate the contributions of all force elements as a generalized force (net force in generalized velocity coordinates).

plant.CalcForceElementsContribution seems closest to this use case, but it separates out what I think of as generalized forces into two terms:

Per a conversation with @amcastro-tri , what seems to be missing is the ability to add these two terms together.

This stems from our basic need to calculate the manipulator equations, e..g

M(q) * vdot = f + Bu

or

M(q) * vdot + C(q,v)v = f + Bu

where we can reliability compute f in this expression.

amcastro-tri commented 4 years ago

Let me add that the confusion stems from the fact that CalcForceElementsContribution() stores the result in a MultibodyForces. Unfortunately it wasn't clear for @mposa that the raw result as obtained with MultibodyForces::generalized_forces() is not what he wanted. This is clearly a defect to be addressed.

IMO the problems are:

Very closely related to previous issues #12911 and #12942.

EricCousineau-TRI commented 4 years ago

Awesome!

However, I would vote against having sugar API in MBP, and instead vote for having something directly on MultibodyForces that more clearly shows what is wanted, e.g. MultibodyForces::CalcTotalGeneralizedForces.

Perhaps ::generalized_forces() should be deprecated in lieu of a better name, like ::purely_computed_generalized_forces() or something that shows that it doesn't incorporate all of the force contributions that may be expected.

EricCousineau-TRI commented 4 years ago

That being said, is #13459 (and it's PR) moot now? Should I close it and the PR if all the math is available, but just needs some polishing? That, or I am happy to still port over part of the unittest or whatever.

amcastro-tri commented 4 years ago

I believe that CalcAppliedForces could be useful. It just didn't directly address Michael's need (all generalized forces). I believe what he needs is more like a MBP::CalcForceElementsGeneralizedForces(), f in his issue post.

Actually, something like CalcAppliedForces() would only add confusion as far as I could tell, given we don't really explain well what MultibodyForces::generalized_forces() actually mean.

So ok, talking myself out of it. I would not make CalcAppliedForces(), not yet at least until we provide properly documented sugar to deal with MultibodyForces objects.

EricCousineau-TRI commented 4 years ago

SGTM! Going to close issue and PR for now; can reopen later!