Obtain CM position and velocity during a simulation
Posted: Wed Oct 09, 2013 11:43 am
Hi All,
Using the Matlab interface to the API, it is possible to obtain the current velocity (or position) of the center of mass of any segment in a model during a simulation using code such as this:
massCenter = Vec3(0.0,0.0,0.0);
velocity = Vec3(0.0,0.0,0.0);
bodySet = osimModel.getBodySet();
bodySet.get('segment_name').getMassCenter(massCenter);
simbodyEngine = osimModel.getSimbodyEngine();
simbodyEngine.getVelocity(osimState,osimModel.getBodySet().get('segment_name'),massCenter,velocity);
My question is how best to obtain the position and velocity of the whole body center of mass during a simulation (something besides querying all of the body segments and then calculating a mass-weighted average). I found a nice C++ example that accomplished this using getMultibodySystem, getMatterSubsystem, and calcSystemMassCenterLocationInGround, but I could not get anything like that to work in Matlab. Any suggestions or insights are greatly appreciated!
Brian
Using the Matlab interface to the API, it is possible to obtain the current velocity (or position) of the center of mass of any segment in a model during a simulation using code such as this:
massCenter = Vec3(0.0,0.0,0.0);
velocity = Vec3(0.0,0.0,0.0);
bodySet = osimModel.getBodySet();
bodySet.get('segment_name').getMassCenter(massCenter);
simbodyEngine = osimModel.getSimbodyEngine();
simbodyEngine.getVelocity(osimState,osimModel.getBodySet().get('segment_name'),massCenter,velocity);
My question is how best to obtain the position and velocity of the whole body center of mass during a simulation (something besides querying all of the body segments and then calculating a mass-weighted average). I found a nice C++ example that accomplished this using getMultibodySystem, getMatterSubsystem, and calcSystemMassCenterLocationInGround, but I could not get anything like that to work in Matlab. Any suggestions or insights are greatly appreciated!
Brian