Using SimTK Assemblar object to assemble Closed-Chain systems

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Musa Audu
Posts: 47
Joined: Mon Nov 24, 2008 11:30 am

Using SimTK Assemblar object to assemble Closed-Chain systems

Post by Musa Audu » Thu Jul 11, 2024 9:58 am

We are trying to enforce constraints for a system with closed-chains using the Assembler object using the following:

Code: Select all

auto &system = osimModel.getMultibodySystem();
Assembler assembler(system);
assembler.assemble(state);
This assembles the model but most of the generalized coordinate bounds were violated. So we tried to enforce the bounds by adding the following before invoking assembler.assemble(state):

Code: Select all

for (i = 0; i < numGenCoords; ++i)
{
	SimTK::MobilizedBodyIndex mbx = coords[i].getBodyIndex();
	SimTK::MobilizerQIndex qx = coords[i].getMobilizerQIndex();
	double lb = coords[i].getRangeMin()*180/Pi;
	double ub = coords[i].getRangeMax() * 180 / Pi;
	assembler.restrictQ(mbx, qx, lb, ub); 
}
However this causes a compiler error because the second argument of the function restrictQ requires a SimTK:: MobilizerQIndex type while OpenSim:Coordinate class function getMobilizerQIndex() returns an integer! We tried the following which did not work:

Code: Select all

SimTK::MobilizerQIndex qx = MobilizerQIndex::safeDownCast(coords[i].getMobilizerQIndex());
This resulted in the error:

Code: Select all

'safeDownCast': is not a member of 'SimTK::MobilizerQIndex'.
Can anybody give us insight on how to get around this problem?

Tags:

User avatar
Michael Sherman
Posts: 808
Joined: Fri Apr 01, 2005 6:05 pm

Re: Using SimTK Assemblar object to assemble Closed-Chain systems

Post by Michael Sherman » Thu Jul 11, 2024 10:20 am

I think all you need is a C-style cast like
SimTK::MobilizerQIndex(int)

User avatar
Musa Audu
Posts: 47
Joined: Mon Nov 24, 2008 11:30 am

Re: Using SimTK Assemblar object to assemble Closed-Chain systems

Post by Musa Audu » Thu Jul 11, 2024 12:13 pm

Thanks a lot Sherm. That works for compilation. Now I have another problem. The assembler only runs once: assembler.getNumAssemblySteps() = 1 and assembler.getNumGoalEvals() = 1. The gen coords are not changed from their mis-assembled values. Am I doing something wrong or missing a step somewhere? Thanks.

POST REPLY