For loop

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: 101
Joined: Sun Jan 12, 2020 3:48 am

For loop

Post by Samane Amini » Mon Oct 02, 2023 2:46 am

Hi

I would like to compute a variable in a For loop at scriptcontroller. I have done the following code in a script controller by lua

function init( model,par,side)
alpha0 = 1
alpha = 1
phi = 0

for i = 1,10 do
beta = alpha*sin(phi)
alpha_dot = beta + 2 -- differentiate alpha
alpha = math.modf (alpha) -- Integral alpha
end
end

In above code, I am attempting to compute alpha inside a FOR loop. But an error is occurred :

attempt to call a number value (global 'alpha')

How can I fix it?

Thanks in advance

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

Re: For loop

Post by Thomas Geijtenbeek » Mon Oct 02, 2023 5:13 am

Perhaps add "math." before sin?

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

Re: For loop

Post by Samane Amini » Mon Oct 02, 2023 5:18 am

Hi

I corrected it. But it still doesn't work. Actually, the alpha(i) which i=1 isn't recognized.

Best

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

Re: For loop

Post by Thomas Geijtenbeek » Fri Oct 06, 2023 2:29 am

It appears "alpha" is a number and not a function, so you can't do alpha(i).

POST REPLY