Dear all,
I am trying to prescribe an experimentally measured knee flexion torque to a model while running a Static Optimization simulation through the Matlab API.
According to a previous post (viewtopicPhpbb.php?f=91&t=12742&p=36438&start=0&view=), the best way to do so in OpenSim is with a Cooordinate Actuator and a Prescribed Controller. However, if I follow this process (see attached code), when I run Static Optimization, it seems that the function defined through the prescribed controller is not taken into account (i.e., the generated torque is constant, and equal to the optimal force). Does the prescribed controller work only in Forward Dynamic simulations?
I found a possible work-around in this other post (viewtopicPhpbb.php?f=91&t=4870&p=28472&start=0&view=), where external torques were imposed as a PrescribedForce to mimick the effect of exoskeletons. This approach seems to work, as the prescribed torque profile is correct (i.e., same as on the experimental data). In my specific case, I applied a PrescribedForce to the tibial body (i.e. on the tibial reference system (?), which is close to but not coincident with the knee joint reference frame) aiming to apply a knee flexion moment. Does this make sense?
Thanks in advance,
Francesca
Prescribed Controller with Static Optimization
- francesca bottin
- Posts: 6
- Joined: Tue Mar 26, 2019 1:06 pm
Prescribed Controller with Static Optimization
- Attachments
-
- Code.PNG (131.92 KiB) Viewed 1254 times
Tags:
- Carmichael Ong
- Posts: 401
- Joined: Fri Feb 24, 2012 11:50 am
Re: Prescribed Controller with Static Optimization
I have also found that prescribed controllers do not work as intended with static optimization, but they do work with CMC. I think you're likely correct that it's because static optimization is not actually performing an integration (but forward dynamics and CMC both perform an integration).
I think your approach of instead using a PrescribedForce makes sense too.
I think your approach of instead using a PrescribedForce makes sense too.
- Jacob J. Banks
- Posts: 97
- Joined: Tue Jul 15, 2014 5:17 am
Re: Prescribed Controller with Static Optimization
I'm having a very similar issue (assigning an actuator force and SOpt not considering it). I've been testing variations of an approach posted a few years ago:
viewtopicPhpbb.php?f=91&t=6499&p=29752&start=0&view=
I don't get any error's, but SOpt simply does not consider the assigned actuator forces/activations (I'm using a pathactuator and then prescribedcontroller).
I find it difficult, and admittedly frustrating, to believe this just simply doesn't work in SOpt? If it doesn't, perhaps this is worth looking into with 4.2beta (Note: all >4 versions don't seem to work, unsure about 3.3... may look into that shortly)?
As an alternative, if prescribing forces (controls) or torques can be done in CMC, can one perhaps trick CMC into acting like SOpt (i.e. only look at 1 frame, and not integrate)? I'm not that familiar with CMC and fear it's intended functionality would not work with well with the full-body lower back models (200-600 MTAs) I work with. Otherwise, one probably just needs to write a custom SOpt API code in Matlab.
In addition, I would argue that assigning an external force is not the same (in the above torque example)... it may generate a similar moment, but joint reactions (particularly shears) would be totally different in the 2 scenarios. In terms of a force actuator (as I wish to use), it is definitely not equivalent, as actuators (and muscles) apply a tensile force between points. One could potentially have 2 opposing forces acting at 'points', but this would get rather complicated with via points and coordinate systems etc.
At any rate, any advice on if assigning a control with SOpt is 'doable' or if I need consider an alternative would be greatly appreciated. Thanks in advance.
viewtopicPhpbb.php?f=91&t=6499&p=29752&start=0&view=
I don't get any error's, but SOpt simply does not consider the assigned actuator forces/activations (I'm using a pathactuator and then prescribedcontroller).
I find it difficult, and admittedly frustrating, to believe this just simply doesn't work in SOpt? If it doesn't, perhaps this is worth looking into with 4.2beta (Note: all >4 versions don't seem to work, unsure about 3.3... may look into that shortly)?
As an alternative, if prescribing forces (controls) or torques can be done in CMC, can one perhaps trick CMC into acting like SOpt (i.e. only look at 1 frame, and not integrate)? I'm not that familiar with CMC and fear it's intended functionality would not work with well with the full-body lower back models (200-600 MTAs) I work with. Otherwise, one probably just needs to write a custom SOpt API code in Matlab.
In addition, I would argue that assigning an external force is not the same (in the above torque example)... it may generate a similar moment, but joint reactions (particularly shears) would be totally different in the 2 scenarios. In terms of a force actuator (as I wish to use), it is definitely not equivalent, as actuators (and muscles) apply a tensile force between points. One could potentially have 2 opposing forces acting at 'points', but this would get rather complicated with via points and coordinate systems etc.
At any rate, any advice on if assigning a control with SOpt is 'doable' or if I need consider an alternative would be greatly appreciated. Thanks in advance.
- Colin Smith
- Posts: 53
- Joined: Fri Feb 24, 2012 11:50 am
Re: Prescribed Controller with Static Optimization
I know that all controllers are turned off in the source code of the static optimization tool, so there is currently no way to use a controller within static optimization through the GUI in any version.
https://github.com/opensim-org/opensim- ... n.cpp#L543
You could use this example to setup your own static optimization code in matlab that accomodates controllers.
https://simtk-confluence.stanford.edu/d ... +in+MATLAB
https://github.com/opensim-org/opensim- ... n.cpp#L543
You could use this example to setup your own static optimization code in matlab that accomodates controllers.
https://simtk-confluence.stanford.edu/d ... +in+MATLAB
- francesca bottin
- Posts: 6
- Joined: Tue Mar 26, 2019 1:06 pm
Re: Prescribed Controller with Static Optimization
Thanks all for your answers, appreciated!
I will try to build my own Static Optimization (to bypass the problem with controllers).
Cheers,
Francesca
I will try to build my own Static Optimization (to bypass the problem with controllers).
Cheers,
Francesca