Page 1 of 1

A question about computeControls frequency

Posted: Thu Aug 23, 2018 2:25 am
by kaiyang
Hello,everyone!
I have a question about the computeControls's control frequency.
We doing a forward dynamics simulation. we writed a Controller class and the computeControls function was used. But we don't the control frequency and can't set the control frequency.
Can you give me some advice on how to solve this problem?
Thanks!

Re: A question about computeControls frequency

Posted: Thu Aug 23, 2018 5:30 am
by mitkof6
The computeControls is called each time the integrator steps the system. It is possible that the stepping algorithm invalidates a step and goes back in time to ensure that the integration tolerance is not violated. Ideally, your compute controls function should be a pure function (its return value is the same for the same arguments) and you should try to avoid local state as much as possible because this may lead to unexpected behavior. Why is so important to know the frequency in your application? Maybe there is some other way around.

Re: A question about computeControls frequency

Posted: Thu Aug 23, 2018 5:38 pm
by kaiyang
Thank you very much, Dimitar.
" Why is so important to know the frequency in your application?" The reason is my work is to simulate human CNS control, and the control loop involves
"sensory delay" and "command delay". I want to design a delay algorithm, but i don't know the control frequency. When the computeControls is called, i cout the "State.getTime()" to a .txt file. But the time interval for each run is not fixed. Sometimes late timestamps appear before in the files. below is a partial "State.getTime()" data.
And how do i set the integrator steps time?
Thanks!

Re: A question about computeControls frequency

Posted: Sat Aug 25, 2018 8:34 am
by mitkof6
We have done something similar in the past and its a bit tricky. Please look at the following branch and particularly at the DelaySignal class

https://github.com/opensim-org/opensim- ... ered_delay

This is an old branch that was created when the OpenSim component features were under development.