Obtaining Intermediate States from osimSimulate
Posted: Sat Nov 13, 2021 6:42 am
Hi there,
I am learning my way through MATLAB scripting for OpenSim. So far, I have learnt how to define bodies and joints to a model. I want to plot the center of mass during a forward simulation (my understanding of forward dynamics?) i.e. given the bodies, joints, actuators and their controllers, letting OpenSim integrate the equations of motion and give the joint angles and velocities of the model.
I want to plot model.calcMassCenterPosition over all the states of the simulation from initState (coming from model.initSystem()) through the finalState (coming from opensimSimulation.simulate(model, initState, 1, true)). I know that this saves the states in a file <model_name>.sto but I dont know how to extract individual states from this file.
I need help in the following:
- What is the structure of state? Is it an array of position and velocity of all bodies with timestamps?
- How do I extract states from .sto files
Thanks.
I am learning my way through MATLAB scripting for OpenSim. So far, I have learnt how to define bodies and joints to a model. I want to plot the center of mass during a forward simulation (my understanding of forward dynamics?) i.e. given the bodies, joints, actuators and their controllers, letting OpenSim integrate the equations of motion and give the joint angles and velocities of the model.
I want to plot model.calcMassCenterPosition over all the states of the simulation from initState (coming from model.initSystem()) through the finalState (coming from opensimSimulation.simulate(model, initState, 1, true)). I know that this saves the states in a file <model_name>.sto but I dont know how to extract individual states from this file.
I need help in the following:
- What is the structure of state? Is it an array of position and velocity of all bodies with timestamps?
- How do I extract states from .sto files
Thanks.