From 90c4b934004a58469fc4c2a4e6945ef2660451d3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 25 Feb 2019 18:46:35 +0300 Subject: [PATCH] Refactor do_next_animation and read_animation_file --- Drone/play_animation.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Drone/play_animation.py b/Drone/play_animation.py index 5d79cd6..b4534d9 100644 --- a/Drone/play_animation.py +++ b/Drone/play_animation.py @@ -25,14 +25,9 @@ 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=round(float(current_frame['speed']), 4) - ) + FlightLib.navto(current_frame['x'], current_frame['y'], current_frame['z'], speed=current_frame['speed']) if USE_LEDS: - LedLib.fill( - int(current_frame['green']), int(current_frame['red']), int(current_frame['blue']) - ) + LedLib.fill(current_frame['green'], current_frame['red'], current_frame['blue']) def read_animation_file(filepath=animation_file_path): @@ -42,16 +37,16 @@ def read_animation_file(filepath=animation_file_path): ) for row in csv_reader: frame_number, x, y, z, yaw, red, green, blue = row + speed = FlightLib.get_distance() frames.append({ - 'number': frame_number, - 'x': x, - 'y': y, - 'z': z, - #'speed': speed, - 'red': red, - 'green': green, - 'blue': blue, - 'yaw': yaw + 'number': int(frame_number), + 'x': float(x), + 'y': float(y), + 'z': float(z), + 'speed': float(speed), + 'red': int(red), + 'green': int(green), + 'blue': int(blue), })