Page 1 of 1

Setting the system state in a model with constraints

Posted: Thu Mar 06, 2014 1:44 pm
by ananthgk
Hi,

I've been trying to use the API to compute moment arms for my musculoskeletal model for different values of the generalized coordinates. Out of around 15 dofs in the model, only 4 are truly independent and each of the remaining 11 are functions of one of the 4, linked through a 'CoordinateCouplerConstraint'. I am thus only interested in computing moment arms about these 4 independent dofs.

In my C++ code, I tried using coordinate.setValue(state,Q), for the independent coordinates and expected that this procedure will automatically call system assembly to satisfy the constraints and automatically update the coordinate values for the corresponding dependent coordinates. This doesn't seem to be happening, and I'd be very grateful if someone could suggest how I could accomplish this? Thank you.


P.S: Another approach I tried was to first come up with a fairly accurate guess value for all 15 coordinates using an independently computed jacobian, and then do the following. This met with little success as well.

state.setQ(q_guess);
model.getMatterSubsystem().getSystem().projectQ(state);

Re: Setting the system state in a model with constraints

Posted: Mon Mar 10, 2014 4:03 pm
by aseth
Coordinate does have a flag to enforce constraints (see defn):

Code: Select all

void Coordinate::setValue(SimTK::State& s, double aValue , bool enforceConstraints) const
The default for enforceConstraints is true.
If project() fails when you give it a "good" guess then it may indicate a problem with the constraint definition(s).
Perhaps the constraints are not consistent- that is satisfying one constraint requires violating another and the assembly solver is finding the least violation (the compromise) solution. If you have verified that the constraints have a feasible solution, then please post them here or post a relevant model so we can investigate. Thanks.