Hi coppelia,

I'm implementing some code in VREP in which I have to do some calculations with the measured variables I obtain from the simulation.

Here the code:

Code: Select all

`harrington_f=function(y,limit)`

ub=limit*0.9

lb=limit

dlb = 0.01

dub = 0.99

lb = 3500

ub = 1000

alpha = math.log(math.log(dub)/math.log(dlb))/(ub-lb)

beta = math.log(-math.log(dub))-alpha*ub

varargout = {math.exp(-math.exp(beta+alpha*y))}

return varargout

end

call_objective_function=function()

get_posandtorque()

for i=1,7,1 do

des=harrington_f(torques[i],limits[i])

real_torques[i]=des

end

a=real_torques[1]

b=real_torques[2]

c=real_torques[3]

d=real_torques[4]

e=real_torques[5]

f=real_torques[6]

g=real_torques[7]

s=1-(a*b*c*d*e*f*g)

return s

end

So, two functions are created. Function

**call_objective_function**call the previous function

**harrington_f**. The problem comes when I work from data stored in tables. In this case, i have torque measurements for every joint, and I use those measured torques in my calculations. However, I get this error message:

Lua runtime error: [string "SCRIPT LBR_iiwa_14_R820"]:43: attempt to perform arithmetic on global 'a' (a table value)

Lua runtime error: [string "SCRIPT LBR_iiwa_14_R820"]:43: attempt to perform arithmetic on global 'a' (a table value)

It's weird that when it runs the function harrington_f I also use table values as numeric inputs and LUA does not recognize that as an error.

What could i do to get rid of this error message?

Thank you very much!!