mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-04 11:09:33 +00:00
Syntax fixes
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import socket
|
||||
import play_animation
|
||||
import time
|
||||
import ntplib
|
||||
from threading import Thread
|
||||
sock = socket.socket()
|
||||
serv = '192.168.1.10' # Change to server ip
|
||||
serv = '192.168.1.10' # Change to server ip
|
||||
port = 35001
|
||||
sock.connect((serv, port))
|
||||
sock.send(bytes('left','utf-8'))
|
||||
sock.send(bytes('left', 'utf-8'))
|
||||
command = ''
|
||||
|
||||
|
||||
def receive():
|
||||
global command
|
||||
|
||||
try:
|
||||
while True:
|
||||
data = str(sock.recv(1024))
|
||||
@@ -48,6 +50,7 @@ def receive():
|
||||
led.off()
|
||||
sock.close()
|
||||
|
||||
|
||||
def time_synch():
|
||||
c = ntplib.NTPClient()
|
||||
response = c.request('ntp1.stratum2.ru')
|
||||
@@ -57,13 +60,13 @@ def time_synch():
|
||||
def pl_anim():
|
||||
global command
|
||||
play_animation.read_animation_file()
|
||||
dtime=time_synch() - time.time()
|
||||
dtime = time_synch() - time.time()
|
||||
|
||||
while True:
|
||||
|
||||
if 'begin_anim' in command:
|
||||
t_st = int(command[command.index('('):])
|
||||
if t_st==dtime+time.time:
|
||||
if t_st == dtime+time.time:
|
||||
break
|
||||
if 'synch' in command:
|
||||
dtime=time_synch() - time.time()
|
||||
@@ -76,9 +79,7 @@ def pl_anim():
|
||||
play_animation.do_next_animation(frame)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__==__main__:
|
||||
if __name__ == "__main__":
|
||||
t_0 = Thread(target=receive)
|
||||
t_0.daemon = True
|
||||
t_0.start()
|
||||
|
||||
@@ -3,21 +3,14 @@ import csv
|
||||
from FlightLib.FlightLib import FlightLib
|
||||
FlightLib.init('SingleCleverFlight')
|
||||
from FlightLib.FlightLib import LedLib
|
||||
import ntplib
|
||||
|
||||
|
||||
animation_file_path = 'drone.csv'
|
||||
frames = []
|
||||
'''
|
||||
def time_synch():
|
||||
c = ntplib.NTPClient()
|
||||
response = c.request('ntp1.stratum2.ru')
|
||||
return response.tx_time-time.time()
|
||||
'''
|
||||
|
||||
|
||||
def takeoff():
|
||||
FlightLib.takeoff(1.75)
|
||||
LedLib.wipe_to(0, 255, 0)
|
||||
FlightLib.takeoff(1.75)
|
||||
|
||||
|
||||
def land():
|
||||
@@ -29,7 +22,7 @@ def land():
|
||||
def do_next_animation(current_frame):
|
||||
FlightLib.navto(
|
||||
round(float(current_frame['x']), 4), round(float(current_frame['y']), 4), round(float(current_frame['z']), 4),
|
||||
round(float(current_frame['yaw']), 4), speed=2
|
||||
round(float(current_frame['yaw']), 4), speed=round(float(current_frame['speed']), 4)
|
||||
)
|
||||
LedLib.fill(
|
||||
int(current_frame['green']), int(current_frame['red']), int(current_frame['blue'])
|
||||
@@ -54,20 +47,21 @@ def read_animation_file():
|
||||
'blue': blue,
|
||||
'yaw': yaw
|
||||
})
|
||||
def frame()
|
||||
|
||||
|
||||
def frame():
|
||||
global frames
|
||||
return frames
|
||||
'''
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
read_animation_file()
|
||||
#dtime=time_synch()-time.time()
|
||||
#while True:
|
||||
# if t_st==dtime+time.time:
|
||||
# break
|
||||
|
||||
takeoff()
|
||||
#FlightLib.reach()
|
||||
for frame in frames:
|
||||
time.sleep(0.1)#cut for using ntp
|
||||
time.sleep(0.1)
|
||||
do_next_animation(frame)
|
||||
|
||||
land()
|
||||
time.sleep(3)'''
|
||||
time.sleep(3)
|
||||
Reference in New Issue
Block a user