Page 1 of 2
SCONE_feedforward controller for joint
Posted: Tue May 24, 2022 10:07 am
by amini_opensim
Hi guys
I would like to add a feedforward controller as polynominal to ankle joint at gait contoller as following:
ConditionalController {
states = "EarlyStance LateStance, Liftoff,Swing Landing"
Controller {
type = FeedForwardController
symmetric = 1
Function {
type = Polynomial
source = ankle_angle
degree = 8
coefficient0 = #
coefficient1 = #
coefficient2 = #
coefficient3 = #
coefficient4 = #
coefficient5 = #
coefficient6 = #
coefficient7 = #
coefficient8 = #
}
}
Although there isn't any error meanwhile the optimizaton, but cost function is not changed at all!! . in fact, I want optimizae muscle forces, but it doesn't work.
Would you please point outed me where I make a mistake?
Thanks
}
Re: SCONE_feedforward controller for joint
Posted: Wed May 25, 2022 12:17 am
by tgeijten
Did you add your ConditionalController as part of the GaitStateController? If so, it should be be activated. An easy way to check is to set coefficient0 = 1 and see if it is activated.
Also note that "source = ankle_angle" is not a valid setting for a FeedForwardController. Feedforward controllers do not have a source input, their output is always a function of time.
If you want to apply a torque based on the ankle_angle, I suggest you use a ScriptController. Please look at the
Script Examples for more information.
Finally, note that degree=8 is very high. If you use a polynomial, I would advise to start with degree=1 or degree=2, and only increase the degree afterwards to see if it improves the result.
Re: SCONE_feedforward controller for joint
Posted: Thu May 26, 2022 9:44 am
by amini_opensim
Hello Thomas
Thank you for helping
in fact, ankle_angle is the target. I've edited it.
Now I want to know if how to import a polynomial, Fourier, or spline torque profile to the joint? the low degree polynomial wouldn't be true in my case.
Thanks
Re: SCONE_feedforward controller for joint
Posted: Fri May 27, 2022 7:01 am
by tgeijten
The coefficients you'll have to find yourself, using matlab, or numpy, or any other tool of your liking.
Since you only need to specify a short torque profile per gait phase (e.g. one for stance and one for swing), a low-degree polynomial should suffice.
Re: SCONE_feedforward controller for joint
Posted: Mon May 30, 2022 9:01 am
by amini_opensim
Hi Thomas
I would like to implement polynomial to Stance phase. But an error has been made. Do you what's the problem? for swing there is no error.
ConditionalController {
states = Stance
Controller {
type = FeedForwardController
symmetric = 1
Function {
type = Polynomial
target = ankle_angle
degree = 4
coefficient0 = #
coefficient1 = #
coefficient2 = #
coefficient3 = #
coefficient4 = #
}
}
}
![eert.PNG](./download/file.php?id=5888&sid=c62b497215f52d12ecaf88d85399751b)
- eert.PNG (8.17 KiB) Viewed 467 times
Re: SCONE_feedforward controller for joint
Posted: Mon May 30, 2022 10:35 am
by tgeijten
"Stance" is not a valid state, you should instead use:
Re: SCONE_feedforward controller for joint
Posted: Mon Jun 06, 2022 2:46 am
by amini_opensim
Hello Thomas
As I said, I'd like to apply a torque polynomial to the ankle joint. I've generated two polynomials (swing and stance) according to time. Swing one works well at the first swing but gradually goes up at the next swing. And stance one doesn't work. Do you think what's the problem?
I was wondering how to define the torque based on ankle angle (gait phase) through script controller
Would you please help me to fix it?
Best
Re: SCONE_feedforward controller for joint
Posted: Tue Jun 07, 2022 1:09 am
by tgeijten
If your FeedForwardController is part of a GaitStateController, then time starts from zero for each new phase. You can check the actuator inputs in the Analysis view to see what's happening. If the Controller isn't stable and stays in swing, then time will indeed continue and the signal might increase. You might need to optimize your control parameters to get a stable gait. It could also help to start of with relatively small polynomial coefficients.
For adding torques via the script controller, please look at the
Script Tutorials. These examples show how to compute polynomials based on time, how to get dof values (i.e. ankle angle), and how to set actuator inputs via a Script.
Re: SCONE_feedforward controller for joint
Posted: Tue Jun 07, 2022 3:52 am
by tgeijten
Another potential issue: if you have multiple controllers in a single state in your
GaitStateController, then you should use define them inside a single
CompositeController, e.g.:
Code: Select all
ConditionalController {
states = "EarlyStance LateStance"
CompositeController {
FeedForwardController { ... }
ReflexController { ... }
}
}
Re: SCONE_feedforward controller for joint
Posted: Thu Jun 09, 2022 11:10 am
by amini_opensim
Thank you very much Thomas
by replacing the controller with CompositeController, It works extremely well
Now to getting better, I would like to optimize the profile torque coefficients so that these are tuned based on a new cost function. Would you please guide me how to define another cost function which is differ from main fitness function?
Best