I know there are quite a few threads about this matter, but I couldn't get it working so far. At the moment it prints the string and not the actual value (i.E. 12, 20,..)
import time
global a1
global v1
a1 = 0.4
v1 = 0.5
global varZup
global varZdown
varZup=0.0065
varZdown=0
xx00=12
yy00=12
zz00=12
rx00=12
ry00=12
rz00=12
xx01=20
yy01=20
rx01=20
ry01=20
rz01=20
xx02=312
yy02=312
rx02=312
ry02=312
rz02=312
xx03=41
yy03=41
rx03=41
ry03=41
rz03=41
global varCnt
varCnt = 0
global posCnt
posCnt = 0
while posCnt < 40:
sendx = "xx" + str(varCnt).zfill(2)
sendy = "yy" + str(varCnt).zfill(2)
sendrx = "rx" + str(varCnt).zfill(2)
sendry = "ry" + str(varCnt).zfill(2)
sendrz = "rz" + str(varCnt).zfill(2)
#print(eval('sendx'))
#exec("%s = %d" % (sendx,int(sendx)))
#print("movep(p[" + exec(str(sendx)) + ", " + exec(str(sendy)) + ", " + "{:.5f}".format(varZup) + ", " + exec(str(sendrx)) + ", " + exec(str(sendry)) + ", " + exec(str(sendrz)) + "], a=" + "{:.5f}".format(a1) + ", v=" + "{:.5f}".format(v1) + ", r=0)")
print("movep(p[" + sendx + ", " + sendy + ", " + "{:.5f}".format(varZup) + ", " + sendrx + ", " + sendry + ", " + sendrz + "], a=" + "{:.5f}".format(a1) + ", v=" + "{:.5f}".format(v1) + ", r=0)")
#s.send(("movep(p[" + "{:.5f}".format(sendx) + ", " + "{:.5f}".format(sendy) + ", " + "{:.5f}".format(varzUp) + ", " + "{:.5f}".format(sendrx) + ", " + "{:.5f}".format(sendry) + ", " + "{:.5f}".format(sendrz) + "], a=" + "{:.5f}".format(a1) + ", v=" + "{:.5f}".format(v1) + ", r=0)" + "\n").encode("utf8"))
varCnt+=1
time.sleep(1)
My tries with exec and eval failed so far (there ist nothing to execute), also it would be nice to get a one liner for the conversion and "send" command.
I just wan't to "fill in" the variables into the string that gets sent to a robot later.
EDIT: this works and gets better with every edit
my_list0 = [0.11946,-0.27553,-0.00058,3.14098,0.00296]
my_list1 = [0.24737,-0.27553,2.20186,-2.23966,-0.00281]
my_list2 = [0.31433,-0.27552,2.20190,-2.23959,-0.00277]
my_list3 = [0.38954,-0.27554,2.20182,-2.23973,-0.00289]
call_list = [my_list0, my_list1, my_list2, my_list3]
while True:
print(*call_list[varCnt][0:1], sep=", ")
print(*call_list[varCnt][3:4], sep=", ")
print("")
varCnt+=1
time.sleep(1)
EDIT2: now I need to compare some data using "math", how to get floats in or out of these lists?
TypeError: 'float' object is not iterable
compareX = map(float, *call_list[varCnt][0:1])
compareY = map(float, *call_list[varCnt][1:2])
compare = math.isclose(compareX-xAct, compareY-yAct, abs_tol=0.0001)