SCONE_feedforward controller for joint

SCONE is a software tool for predictive simulations of biomechanical movement. It uses OpenSim for modeling and simulation, and performs optimization using various control strategies, including feed-forward control, proprioceptic feedback control, and bal
User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

SCONE_feedforward controller for joint

Post by Samane Amini » Tue May 24, 2022 10:07 am

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

}

User avatar
Thomas Geijtenbeek
Posts: 450
Joined: Wed Mar 12, 2014 8:08 am

Re: SCONE_feedforward controller for joint

Post by Thomas Geijtenbeek » Wed May 25, 2022 12:17 am

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.

User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Re: SCONE_feedforward controller for joint

Post by Samane Amini » Thu May 26, 2022 9:44 am

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

User avatar
Thomas Geijtenbeek
Posts: 450
Joined: Wed Mar 12, 2014 8:08 am

Re: SCONE_feedforward controller for joint

Post by Thomas Geijtenbeek » Fri May 27, 2022 7:01 am

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.

User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Re: SCONE_feedforward controller for joint

Post by Samane Amini » Mon May 30, 2022 9:01 am

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
eert.PNG (8.17 KiB) Viewed 535 times

User avatar
Thomas Geijtenbeek
Posts: 450
Joined: Wed Mar 12, 2014 8:08 am

Re: SCONE_feedforward controller for joint

Post by Thomas Geijtenbeek » Mon May 30, 2022 10:35 am

"Stance" is not a valid state, you should instead use:

Code: Select all

states = "EarlyStance LateStance"

User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Re: SCONE_feedforward controller for joint

Post by Samane Amini » Mon Jun 06, 2022 2:46 am

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

User avatar
Thomas Geijtenbeek
Posts: 450
Joined: Wed Mar 12, 2014 8:08 am

Re: SCONE_feedforward controller for joint

Post by Thomas Geijtenbeek » Tue Jun 07, 2022 1:09 am

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.

User avatar
Thomas Geijtenbeek
Posts: 450
Joined: Wed Mar 12, 2014 8:08 am

Re: SCONE_feedforward controller for joint

Post by Thomas Geijtenbeek » Tue Jun 07, 2022 3:52 am

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 { ... }
	}
}

User avatar
Samane Amini
Posts: 101
Joined: Sun Jan 12, 2020 3:48 am

Re: SCONE_feedforward controller for joint

Post by Samane Amini » Thu Jun 09, 2022 11:10 am

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

POST REPLY