mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-26 23:19:33 +00:00
Leds off + takeoff fix
This commit is contained in:
@@ -102,7 +102,7 @@ def animation_player(running_event, stop_event):
|
||||
print("Animation thread activated")
|
||||
rate = rospy.Rate(1000 / 100)
|
||||
play_animation.takeoff(TAKEOFF_HEIGHT)
|
||||
for current_frame in play_animation.frame():
|
||||
for current_frame in play_animation.get_frames():
|
||||
running_event.wait()
|
||||
if stop_event.is_set():
|
||||
break
|
||||
@@ -165,6 +165,9 @@ if COPTER_ID == 'default':
|
||||
|
||||
TAKEOFF_HEIGHT = float(config.get('COPTER', 'takeoff_height'))
|
||||
|
||||
USE_LEDS = bool(config.get('COPTER', 'use_leds'))
|
||||
play_animation.USE_LEDS = USE_LEDS
|
||||
|
||||
print("Client started on copter:", COPTER_ID)
|
||||
print("NTP time:", time.ctime(get_ntp_time(NTP_HOST, NTP_PORT)))
|
||||
print("System time", time.ctime(time.time()))
|
||||
@@ -200,8 +203,9 @@ try:
|
||||
send_all(bytes(form_command("response", response)))
|
||||
print("Request responded with:", response)
|
||||
|
||||
except socket.error:
|
||||
print("Connection lost... reconnecting")
|
||||
except socket.error as e:
|
||||
print("Connection lost due error:", e)
|
||||
print("Reconnecting...")
|
||||
reconnect()
|
||||
print("Re-connection successful")
|
||||
except KeyboardInterrupt:
|
||||
|
||||
@@ -11,7 +11,8 @@ host = ntp1.stratum2.ru
|
||||
port = 123
|
||||
|
||||
[COPTER]
|
||||
id = copter6349
|
||||
id = default
|
||||
takeoff_height = 1.75
|
||||
takeoff_timeout = 7
|
||||
use_leds = True
|
||||
animation_file = animation.csv
|
||||
|
||||
@@ -6,17 +6,21 @@ from FlightLib.FlightLib import LedLib
|
||||
|
||||
animation_file_path = 'drone.csv'
|
||||
frames = []
|
||||
USE_LEDS = True
|
||||
|
||||
|
||||
def takeoff(h=1.75):
|
||||
LedLib.wipe_to(0, 255, 0)
|
||||
FlightLib.takeoff(h)
|
||||
if USE_LEDS:
|
||||
LedLib.wipe_to(0, 255, 0)
|
||||
FlightLib.takeoff(h, fixed_delay=True)
|
||||
|
||||
|
||||
def land():
|
||||
LedLib.rainbow()
|
||||
if USE_LEDS:
|
||||
LedLib.blink(0, 255, 0)
|
||||
FlightLib.land()
|
||||
LedLib.off()
|
||||
if USE_LEDS:
|
||||
LedLib.off()
|
||||
|
||||
|
||||
def do_next_animation(current_frame):
|
||||
@@ -24,9 +28,10 @@ def do_next_animation(current_frame):
|
||||
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=round(float(current_frame['speed']), 4)
|
||||
)
|
||||
LedLib.fill(
|
||||
int(current_frame['green']), int(current_frame['red']), int(current_frame['blue'])
|
||||
)
|
||||
if USE_LEDS:
|
||||
LedLib.fill(
|
||||
int(current_frame['green']), int(current_frame['red']), int(current_frame['blue'])
|
||||
)
|
||||
|
||||
|
||||
def read_animation_file(filepath=animation_file_path):
|
||||
@@ -49,7 +54,7 @@ def read_animation_file(filepath=animation_file_path):
|
||||
})
|
||||
|
||||
|
||||
def frame():
|
||||
def get_frames():
|
||||
global frames
|
||||
return frames
|
||||
|
||||
|
||||
Reference in New Issue
Block a user