Page 1 of 1

Trying to update the state with motion's coordinates

Posted: Fri Dec 01, 2023 5:02 am
by giuliaghielmi
Hello everyone! :D

I'm trying to use this function https://github.com/modenaxe/MuscleForce ... athAsMat.m from Luca Modenese to extract the muscle path.

I'm encountering problems regarding the state. For now I've used only:
state = model.initSystem();

My goal is to get the muscle path updated according to the kinematics of the system, then introducing the motion. Then, I would like to extract the muscle path for each time instant of the motion.

I'm thinking to extract all the coordinates for each instant and then update the state with the new value of coordinates. But I don't know how to implement it because the functions that I've tried to use don't work.
I've tried in this way:
motionData = Storage('motion_file.mot');
stateVector = motionData.getStateVector();
state = model.updState();
model.setState(state, stateVector);

I always receive this message: Undefined function or variable. :?

Thanks in advance :P

Re: Trying to update the state with motion's coordinates

Posted: Tue Dec 05, 2023 3:53 pm
by nbianco
Hi Guilia,

If you retrieve the coordinate set from the model via model.getCoordinateSet(), you can set coordinate values and speeds via Coordinate::setValue() and Coordinate::setSpeedValue(). Both of those methods take a State argument, and update the correct slot in the state for the associated coordinate value/speed.

Best,
Nick

Re: Trying to update the state with motion's coordinates

Posted: Tue Mar 05, 2024 4:53 am
by giuliaghielmi
It worked, thanks for the help! :D