From 148566abf7aecd8d49958e443fd9396183adbbe0 Mon Sep 17 00:00:00 2001 From: goldarte Date: Tue, 18 Dec 2018 18:55:20 +0000 Subject: [PATCH 1/8] Change Flightlib submodule to my fork --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 2918b783..908d3b01 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "Drone/FlightLib"] path = Drone/FlightLib - url = git://github.com/artem30801/CleverFlightLib.git + url = git://github.com/goldarte/CleverFlightLib.git From 4ace21ef919af4c03a24e9d721e222f6977275da Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 25 Feb 2019 17:07:45 +0300 Subject: [PATCH 2/8] .gitignore update for test_animation folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 44de96fa..d343f30e 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,4 @@ venv.bak/ .mypy_cache/ .vscode/settings.json Server/tests.py +Drone/test_animation/ From 3bdd6584fdb0796840a7781ebf76d04d915e889a Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 25 Feb 2019 17:10:40 +0300 Subject: [PATCH 3/8] Change column order in read_animation_file due to the latest version of blender-csv-animaton --- Drone/play_animation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Drone/play_animation.py b/Drone/play_animation.py index e23b6938..5d79cd6b 100644 --- a/Drone/play_animation.py +++ b/Drone/play_animation.py @@ -41,13 +41,13 @@ def read_animation_file(filepath=animation_file_path): animation_file, delimiter=',', quotechar='|' ) for row in csv_reader: - frame_number, x, y, z, speed, red, green, blue, yaw = row + frame_number, x, y, z, yaw, red, green, blue = row frames.append({ 'number': frame_number, 'x': x, 'y': y, 'z': z, - 'speed': speed, + #'speed': speed, 'red': red, 'green': green, 'blue': blue, From 90c4b934004a58469fc4c2a4e6945ef2660451d3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 25 Feb 2019 18:46:35 +0300 Subject: [PATCH 4/8] 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 5d79cd6b..b4534d9f 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), }) From b85ecf131726a2b3087c6622354823f97b9a87bb Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 26 Feb 2019 11:28:55 +0300 Subject: [PATCH 5/8] Change test chain in main function --- Drone/play_animation.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Drone/play_animation.py b/Drone/play_animation.py index b4534d9f..5b498814 100644 --- a/Drone/play_animation.py +++ b/Drone/play_animation.py @@ -60,14 +60,12 @@ def get_frames(): LedLib.init_led() read_animation_file() - + rate = rospy.Rate(10) #first_frame = frames[0] #takeoff(round(float(first_frame['x']), 4), round(float(first_frame['y']), 4), round(float(first_frame['z']), 4)) takeoff() - #FlightLib.reach() + FlightLib.reach(x=frames[0]['x'], y=frames[0]['y'], z=frames[0]['z']) for frame in frames: - time.sleep(0.1) + rate.sleep() do_next_animation(frame) - - land() - time.sleep(3) \ No newline at end of file + land() \ No newline at end of file From 7f7af0b2f709269f14ce8988947d48f2e150075f Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 26 Feb 2019 17:28:55 +0000 Subject: [PATCH 6/8] Changed test animation file path --- Drone/play_animation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Drone/play_animation.py b/Drone/play_animation.py index 5b498814..83a5c749 100644 --- a/Drone/play_animation.py +++ b/Drone/play_animation.py @@ -5,7 +5,7 @@ #FlightLib.init('SingleCleverFlight') from FlightLib.FlightLib import LedLib -animation_file_path = 'animation.csv' +animation_file_path = 'test_animation/test_1.csv' frames = [] USE_LEDS = True @@ -65,7 +65,7 @@ def get_frames(): #takeoff(round(float(first_frame['x']), 4), round(float(first_frame['y']), 4), round(float(first_frame['z']), 4)) takeoff() FlightLib.reach(x=frames[0]['x'], y=frames[0]['y'], z=frames[0]['z']) - for frame in frames: - rate.sleep() - do_next_animation(frame) + #for frame in frames: + # rate.sleep() + # do_next_animation(frame) land() \ No newline at end of file From 328350e2ab00f725b8beb0a5f6973c184dad6658 Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 26 Feb 2019 21:01:24 +0000 Subject: [PATCH 7/8] Final test version of play_animation.py --- Drone/play_animation.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Drone/play_animation.py b/Drone/play_animation.py index 83a5c749..35672387 100644 --- a/Drone/play_animation.py +++ b/Drone/play_animation.py @@ -13,19 +13,19 @@ def takeoff(): #x, y, z if USE_LEDS: LedLib.wipe_to(0, 255, 0) - FlightLib.takeoff() + FlightLib.takeoff1() def land(): if USE_LEDS: LedLib.blink(0, 255, 0) - FlightLib.land() + FlightLib.land1() if USE_LEDS: LedLib.off() -def do_next_animation(current_frame): - FlightLib.navto(current_frame['x'], current_frame['y'], current_frame['z'], speed=current_frame['speed']) +def do_next_animation(current_frame, x0 = 0, y0 = 0): + FlightLib.navto(current_frame['x']+x0, current_frame['y']+y0, current_frame['z'], yaw = 1.57) if USE_LEDS: LedLib.fill(current_frame['green'], current_frame['red'], current_frame['blue']) @@ -36,8 +36,7 @@ def read_animation_file(filepath=animation_file_path): animation_file, delimiter=',', quotechar='|' ) for row in csv_reader: - frame_number, x, y, z, yaw, red, green, blue = row - speed = FlightLib.get_distance() + frame_number, x, y, z, speed, red, green, blue = row frames.append({ 'number': int(frame_number), 'x': float(x), @@ -57,15 +56,17 @@ def get_frames(): if __name__ == '__main__': rospy.init_node('Animation_player', anonymous=True) - LedLib.init_led() - + if USE_LEDS: + LedLib.init_led() + X0 = 0.5 + Y0 = 1.0 read_animation_file() rate = rospy.Rate(10) #first_frame = frames[0] #takeoff(round(float(first_frame['x']), 4), round(float(first_frame['y']), 4), round(float(first_frame['z']), 4)) takeoff() - FlightLib.reach(x=frames[0]['x'], y=frames[0]['y'], z=frames[0]['z']) - #for frame in frames: - # rate.sleep() - # do_next_animation(frame) + FlightLib.reach(x=frames[0]['x']+X0, y=frames[0]['y']+Y0, z=frames[0]['z'], yaw = 1.57) + for frame in frames: + rate.sleep() + do_next_animation(frame, x0 = X0, y0 = Y0) land() \ No newline at end of file From 2b33a3879c897e0b3af2513ce91b4964160bad5e Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 27 Feb 2019 17:28:56 +0300 Subject: [PATCH 8/8] Corrected led color order --- Drone/play_animation.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Drone/play_animation.py b/Drone/play_animation.py index 5b498814..3cfa5112 100644 --- a/Drone/play_animation.py +++ b/Drone/play_animation.py @@ -5,29 +5,29 @@ #FlightLib.init('SingleCleverFlight') from FlightLib.FlightLib import LedLib -animation_file_path = 'animation.csv' +animation_file_path = 'test_animation/test_1.csv' frames = [] USE_LEDS = True def takeoff(): #x, y, z if USE_LEDS: - LedLib.wipe_to(0, 255, 0) - FlightLib.takeoff() + LedLib.wipe_to(255, 0, 0) + FlightLib.takeoff1() def land(): if USE_LEDS: - LedLib.blink(0, 255, 0) - FlightLib.land() + LedLib.blink(255, 0, 0) + FlightLib.land1() if USE_LEDS: LedLib.off() -def do_next_animation(current_frame): - FlightLib.navto(current_frame['x'], current_frame['y'], current_frame['z'], speed=current_frame['speed']) +def do_next_animation(current_frame, x0 = 0, y0 = 0): + FlightLib.navto(current_frame['x']+x0, current_frame['y']+y0, current_frame['z'], yaw = 1.57) if USE_LEDS: - LedLib.fill(current_frame['green'], current_frame['red'], current_frame['blue']) + LedLib.fill(current_frame['red'], current_frame['green'], current_frame['blue']) def read_animation_file(filepath=animation_file_path): @@ -37,13 +37,12 @@ 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': int(frame_number), 'x': float(x), 'y': float(y), 'z': float(z), - 'speed': float(speed), + 'yaw': float(yaw), 'red': int(red), 'green': int(green), 'blue': int(blue), @@ -57,15 +56,15 @@ def get_frames(): if __name__ == '__main__': rospy.init_node('Animation_player', anonymous=True) - LedLib.init_led() - + if USE_LEDS: + LedLib.init_led() + X0 = 0.5 + Y0 = 1.0 read_animation_file() - rate = rospy.Rate(10) - #first_frame = frames[0] - #takeoff(round(float(first_frame['x']), 4), round(float(first_frame['y']), 4), round(float(first_frame['z']), 4)) + rate = rospy.Rate(8) takeoff() - FlightLib.reach(x=frames[0]['x'], y=frames[0]['y'], z=frames[0]['z']) + FlightLib.reach(x=frames[0]['x']+X0, y=frames[0]['y']+Y0, z=frames[0]['z'], yaw = 1.57) for frame in frames: + do_next_animation(frame, x0 = X0, y0 = Y0) rate.sleep() - do_next_animation(frame) land() \ No newline at end of file