I want to write a function which can produce each circle coordinates in every 30 seconds. So far my code is like this:
import sched, time
import numpy as np
scheduler = sched.scheduler(time.time, time.sleep)
def coords():
theta = np.linspace(0, 2*np.pi, 1000)
radius = .5
x = radius * np.sin( theta )
y = radius * np.cos( theta )
z = 4.2
pos = []
for i in range (0, 1000):
pos = (x[i], y[i], z)
i+=1
#print(pos)
e1 = scheduler.enter(1, 1, coords)
e2 = scheduler.enter(30, 1, coords)
I am not sure what I am doing wrong, please help! Thank you.
Editing to provide more codes:
import time
import numpy as np
def distance(a, b):
distance = np.sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*
(a[1]- b[1])+(a[2]-b[2])*(a[2]-b[2]))
return distance
def coords():
theta = np.linspace(0, 2*np.pi, 1000)
radius = .5
x = radius * np.sin( theta )
y = radius * np.cos( theta )
z = 4.2
pos = []
for i in range (0, 1000):
pos = (x[i], y[i], z)
return pos
def main():
goal = np.array([3.6528202764153976, -7.055446756786874524,
8.52021764])
current = coords()
print(current)
while True:
dis = distance(goal,current)
print(dis)
time.sleep(3)
if __name__ == "__main__":
main()