Accessing functions of parent templatized class (specifically BushingForce to TwoFrameLinker<Force, PhysicalFrame>)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Rebecca Abbott
Posts: 12
Joined: Wed Sep 26, 2012 12:09 pm

Accessing functions of parent templatized class (specifically BushingForce to TwoFrameLinker<Force, PhysicalFrame>)

Post by Rebecca Abbott » Fri Dec 21, 2018 2:51 pm

I am working with a version of the OpenSim neck model that has a BushingForce between each vertebral body. I need to populate a vector of the torques from the bushings to add to my equation of motion.

The parent class of BushingForce is a templatized class TwoFrameLinker<Force, PhysicalFrame>. I am able to access the public functions in TwoFrameLinker to compute the deflection and get the stiffness vectors, but I am unable to access the protected function addInPhysicalForcesFromInternal. I get the following error message:

error C2248:
'OpenSim::TwoFrameLinker<OpenSim::Force,OpenSim::PhysicalFrame>::addInPhysicalForcesFromInternal':
cannot access protected member declared in class

How would I access this protected function?

Here is a snippet of code in case it is helpful:

Code: Select all


		//get BushingForce component between cerv6 and cerv7 vertebral bodies
		const OpenSim::BushingForce& bushingObj = m_model->getComponent<BushingForce>("./forceset/C7_C6_Bushing");

		//extract stiffness and damping parameters 
		SimTK::Vec6 stiffness = osimVec3ToVec6(bushingObj.get_rotational_stiffness(), bushingObj.get_translational_stiffness());
		SimTK::Vec6 damping = osimVec3ToVec6(bushingObj.get_rotational_damping(), bushingObj.get_translational_stiffness());
		
		//compute state dependent deflection and deflection rate between cerv6 and cerv7 PhysicalFrames 
		SimTK::Vec6 deflection = bushingObj.computeDeflection(*m_state);
		SimTK::Vec6 deflectionrate = bushingObj.computeDeflectionRate(*m_state);
		
		//compute internal bushing forces 
		SimTK::Vec6 fk = - stiffness.elementwiseMultiply(deflection);
		SimTK::Vec6 fv = - damping.elementwiseMultiply(deflectionrate);
		SimTK::Vec6 bushingForces = fk + fv;
		
		//Set up spatial vectors, F1 in ground and F2 in ground
		SimTK::SpatialVec F1_G;
		SimTK::SpatialVec F2_G;
		
		//THIS PART DOESN'T WORK
		bushingObj.convertInternalForceToForcesOnFrames(*m_state, bushingForces, F1_G, F2_G);
		
		auto& frame1_mobodindex = bushingObj.getFrame1().getMobilizedBodyIndex();
		auto& frame2_mobodindex = bushingObj.getFrame2().getMobilizedBodyIndex();
		
		SimTK::Vector_<SpatialVec> F_G;
		F_G[frame1_mobodindex] = F1_G;
		F_G[frame2_mobodindex] = F2_G;

		SimTK::Vector tau_bushings;
		smss.multiplyBySystemJacobianTranspose(*m_state, F_G, tau_bushings);


I haven't tested the vector indexing yet so that is just pseudocode. I am more interested in feedback about accessing the convertInternalToForcesOnFrames function.

Thank you for any help!
Rebecca

Northwestern University
Department of Mechanical Engineering
Department of Physical Therapy and Human Movement Sciences

Tags:


User avatar
Rebecca Abbott
Posts: 12
Joined: Wed Sep 26, 2012 12:09 pm

Re: Accessing functions of parent templatized class (specifically BushingForce to TwoFrameLinker<Force, PhysicalFrame>)

Post by Rebecca Abbott » Wed Jan 02, 2019 11:42 am

Ah thank you Dimitar!

I will just create my own function to implement that functionality. Thanks for your help.

POST REPLY