RobotLocomotion / drake

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

Joint limits only supported for 1-dof joints #13121

Open mpetersen94 opened 4 years ago

mpetersen94 commented 4 years ago

Once #13055 merges, Drake will support a multi degree of freedom joint where joint limits are physically meaningful. However, the way joint limits are enforced in MultibodyPlant, assumes that they are only on one dof joints. The AddJointLimitsPenaltyForces method uses joint.GetOnePosition(), joint.GetOneVelocity() and joint.AddInOneForce(). The last of these methods enables selecting among the joints dof's but the other two throw an error if the joint has more that one dof.

I see two options to fix this:

  1. Enable GetOnePosition() and GetOneVelocity() to support multi-dof joints.
  2. Add a position and velocity accessor to Joint that can be used here.
  3. Make each joint enforce joint limits internally (the same way damping is currently enforced).

I would love to have anyone who has thoughts on the best way to implement this add comments, especially @sherm1 and @amcastro-tri .

My reason for pushing this (as well as pushing the new joints) is that we are trying to model a rope and we want to make the model behave in a physically reasonable way.

Possibly related #12942

sherm1 commented 4 years ago

My reason for pushing this (as well as pushing the new joints) is that we are trying to model a rope and we want to make the model behave in a physically reasonable way.

@mpetersen94 it's not obvious to me that a joint limit would be the right way to impose "rope like" behavior on a U-joint connected chain of bodies. Joint limits have the property that they provide zero force until you reach the limit. I don't know much about rope models, but I'm guessing they would resist any bending, likely in some nonlinear way that looks joint limit-ish at the extremes. Have you thought about that? It would be straightforward to add a model like that via a custom ForceElement, applied to the joint but not specified as part of the joint definition.

sherm1 commented 4 years ago

Separately from rope modeling though, I think GetOnePosition() and GetOneVelocity() should allow for a joint_dof to be provided like AddInOneForce() does. The reset of the Joint API seems right for multi-dof joints -- for example all the setting and getting of limits uses a VectorX so can deal with any number of dofs. Likely we should also have GetPositions() and GetVelocities() that return VectorX's for those as well.