How to import variable from scriptcontroller to scriptmeasure

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
POST REPLY
User avatar
Samane Amini
Posts: 97
Joined: Sun Jan 12, 2020 3:48 am

How to import variable from scriptcontroller to scriptmeasure

Post by Samane Amini » Mon Jan 22, 2024 11:31 pm

Hi all

I want to use an objective function that minimize an error in scriptmeasure. Actually, I have defined a new variable at script controller, and I want to use the error (difference between the new variable and joint angle) in scriptmeasure. But as far as I know, I can't import a variable defined in script controller in script measure. Is this correct?

Do you have any idea to save this variable in script controller and use it in the script measure?


Best regards

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

Re: How to import variable from scriptcontroller to scriptmeasure

Post by Thomas Geijtenbeek » Tue Jan 23, 2024 5:44 am

Unfortunately, you cannot access these variables, since the controller and measure run independently. The best solution would be to simply recompute the value in the ScriptMeasure.

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

Re: How to import variable from scriptcontroller to scriptmeasure

Post by Samane Amini » Tue Jan 23, 2024 6:07 am

Thanks for your quick reply.

Actually, the variable is computed by some parameters that I want to optimize them. so if I recompute the variable in the scriptmeasure, I will have to define these parameters again and it's false. Unless I can import the optimization parameters to the scripmeasure without re-optimizing them. Is it possible?

Best

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

Re: How to import variable from scriptcontroller to scriptmeasure

Post by Thomas Geijtenbeek » Thu Feb 01, 2024 2:50 am

You do actually have access to all the parameters in the ScriptMeasure. Simply use the following init function:

Code: Select all

function init( model, par )
	-- par can be used here
end
I realize this wasn't in the documentation, so I will update it!

POST REPLY