Page 1 of 1

Forward simulation: basic steps

Posted: Mon Oct 27, 2014 12:18 pm
by mariakrgrg
Hello there!
I try to implement a forward simulation, for example knee flexion (it could be something else for now, I just want to practice some things).

Can someone tell me the steps I should follow?

For example, should I know the exact forces the muscle produce to move the knee? If yes, how can I define them?

Also, what is exactly the utility of a controller? Is it necessary for implemeting a simulation or it just helps for something specific?

Thank you!

Re: Forward simulation: basic steps

Posted: Sat Nov 01, 2014 2:57 pm
by jimmy
Hi Maria,

The tug-of-war example uses a control signal in a forward simulation;
http://simtk-confluence.stanford.edu:80 ... ompetition

Re: Forward simulation: basic steps

Posted: Sun Nov 02, 2014 5:05 am
by mariakrgrg
Thank you for your reply.

I have seen these examples but there aren't examples with C++ code an that's where I have problems (mostly).
I have seen the tutorials "How to create a Controller" and "How to do simulation" also, but they are too simple and don't help much. :?

For example I have some questions like that:
What exactly is supposed to do function

Code: Select all

computeControls(const State &s, Vector &controls)
of

Code: Select all

class Controller
?

Re: Forward simulation: basic steps

Posted: Tue Nov 04, 2014 12:02 pm
by aseth
Perhaps what you are looking for is in the Doxygen that documents the code base.
Locally you can find it here: <OpenSim32_Install_DIR>\sdk\doc\OpenSimAPI.html
Online: https://simtk.org/api_docs/opensim/api_docs/

Furthermore, a Controller is an OpenSim component whose job it is to generate controls for Actuators. Actuators are force elements (Forces) that generate force on the multibody system based on the state (e.g. time, joint coordinates and speeds, muscle activations and fiber-lengths, ...) and a control input. A Muscle is an Actuator in OpenSim and so is a an ideal motor (CoordinateActuator). You can perform a forward dynamics simulation without a controller. A default control value of zero is assumed for most actuators if no control is provided. You can perform a simulation of passive knee swing this way.

A Controller computes controls for its actuators based on the state of the model. If you are trying to write your own Controller, there is an example in the <OpenSim32_Install_DIR>\sdk\APIExamples\ folder.

Re: Forward simulation: basic steps

Posted: Wed Nov 05, 2014 1:31 pm
by mariakrgrg
Thanks for your time.

Maybe I should be more specific. Let's say I want to simulate the movement of squat at the lower limb body.
How can I know exactly which actuators should get a control signal and what's the value of this signals?

And correct me if I am wrong:
next thing to do is to draw the curve control_signal vs. time
and do something like that to take control of the muscle I want:

Code: Select all

const Millard2012EquilibriumMuscle* muscle1 = static_cast<const Millard2012EquilibriumMuscle*>(&getActuatorSet().get("muscle_name"));
and then I use

Code: Select all

muscle1->addInControls(muscleControl, controls);
to set the force I want.