Leds off + takeoff fix

This commit is contained in:
Artem30801
2019-01-20 12:07:27 +03:00
parent 28c1a56cbd
commit b300db8601
3 changed files with 22 additions and 12 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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