Hi all

I am trying to conduct the static inverse dynamics to calculate the coordinate forces given the vector Q.

I found that the residual force of the locked coordinate is not zero.

Does this value mean the force that is needed to apply for satisfy the lock constraint?

I also can't totally understand the difference between model.getMatterSubsystem().calcResidualForce

and model.getMatterSubsystem().calcResidualForceIgnoringConstraints.

When using the former one, coordinate lock constraint is considered?

Thank you in advance

## Joint lock constraint is ignored when calculating ResidualForce?

- Jiang Ping
**Posts:**132**Joined:**Sun Aug 26, 2012 4:09 am

- Michael Sherman
**Posts:**807**Joined:**Fri Apr 01, 2005 6:05 pm

### Re: Joint lock constraint is ignored when calculating ResidualForce?

Hi, Jiang. I can answer part of your question:

The difference between calcResidualForce() and calcResidualForceIgnoringConstraints() is just whether the method allows you to specify the constraint multipliers lambda. Neither method generates internal constraint forces and both methods ignore prescribed motion.

A separate question is how OpenSim models locked joints. They can be modeled either with constraints or with prescribed motion and I don't know which. Does someone else know the answer?

Regards,

Sherm

The difference between calcResidualForce() and calcResidualForceIgnoringConstraints() is just whether the method allows you to specify the constraint multipliers lambda. Neither method generates internal constraint forces and both methods ignore prescribed motion.

A separate question is how OpenSim models locked joints. They can be modeled either with constraints or with prescribed motion and I don't know which. Does someone else know the answer?

Regards,

Sherm

- Dimitar Stanev
**Posts:**1096**Joined:**Fri Jan 31, 2014 5:14 am

### Re: Joint lock constraint is ignored when calculating ResidualForce?

The internal implementation of OpenSim used the SimTK::Constraint::PrescribedMotion constraint to enforce coordinate locking:

https://github.com/opensim-org/opensim- ... e.cpp#L184

https://simbody.github.io/simbody-3.6-d ... ml#details

https://github.com/opensim-org/opensim- ... e.cpp#L184

https://simbody.github.io/simbody-3.6-d ... ml#details

- Michael Sherman
**Posts:**807**Joined:**Fri Apr 01, 2005 6:05 pm

### Re: Joint lock constraint is ignored when calculating ResidualForce?

Great, thanks Dimitar!

So calculating residual forces using Simbody's calcResidualForce() method does not include forces needed to lock joints unless you supply them yourself through the lambda parameter to that method.

So calculating residual forces using Simbody's calcResidualForce() method does not include forces needed to lock joints unless you supply them yourself through the lambda parameter to that method.

- Jiang Ping
**Posts:**132**Joined:**Sun Aug 26, 2012 4:09 am

### Re: Joint lock constraint is ignored when calculating ResidualForce?

Hi, Sherman and Dimitar

Thank you very much for your reply.

Now I understand that I may need an additional actuator to lock the joints.

I think it would be better to clarify this point in the OpenSim user guidance, which will help people who are dealing with inverse dynamics problem (e.g., calculating the joint torque).

Thank you very much for your reply.

Now I understand that I may need an additional actuator to lock the joints.

I think it would be better to clarify this point in the OpenSim user guidance, which will help people who are dealing with inverse dynamics problem (e.g., calculating the joint torque).

### Re: Joint lock constraint is ignored when calculating ResidualForce?

You do not need additional actuators to lock a joint. You either a.) care about the coordinate force necessary to enforce the lock (that is what ID provides now) or b.) you don't, in which case can simply ignore what ID computes. Adding an actuator to enforce the lock (to result in zero residual) would only mean they would have apply the coordinate force currently being computed for you (i.e. the residual). How would you compute that coordinate force? ID? Apologies if I am missing the purpose here.