diff --git a/Drone/animation_lib.py b/Drone/animation_lib.py index 6f490df..943ff0a 100644 --- a/Drone/animation_lib.py +++ b/Drone/animation_lib.py @@ -40,7 +40,7 @@ def get_id(filepath="animation.csv"): print("No animation id in file") return anim_id -def load_animation(filepath="animation.csv", x0=0, y0=0, z0=0): +def load_animation(filepath="animation.csv", x0=0, y0=0, z0=0, ratio=1): imported_frames = [] global anim_id try: @@ -62,9 +62,9 @@ def load_animation(filepath="animation.csv", x0=0, y0=0, z0=0): frame_number, x, y, z, yaw, red, green, blue = row_0 imported_frames.append({ 'number': int(frame_number), - 'x': float(x) + x0, - 'y': float(y) + y0, - 'z': float(z) + z0, + 'x': ratio*float(x) + x0, + 'y': ratio*float(y) + y0, + 'z': ratio*float(z) + z0, 'yaw': float(yaw), 'red': int(red), 'green': int(green), @@ -74,9 +74,9 @@ def load_animation(filepath="animation.csv", x0=0, y0=0, z0=0): frame_number, x, y, z, yaw, red, green, blue = row imported_frames.append({ 'number': int(frame_number), - 'x': float(x) + x0, - 'y': float(y) + y0, - 'z': float(z) + z0, + 'x': ratio*float(x) + x0, + 'y': ratio*float(y) + y0, + 'z': ratio*float(z) + z0, 'yaw': float(yaw), 'red': int(red), 'green': int(green), diff --git a/Drone/copter_client.py b/Drone/copter_client.py index baea0d8..22d7ea4 100644 --- a/Drone/copter_client.py +++ b/Drone/copter_client.py @@ -151,6 +151,7 @@ def _response_animation_id(): x0=client.active_client.X0 + client.active_client.X0_COMMON, y0=client.active_client.Y0 + client.active_client.Y0_COMMON, z0=client.active_client.Z0 + client.active_client.Z0_COMMON, + ratio=client.active_client.RATIO, ) # Correct start and land frames in animation corrected_frames, start_action, start_delay = animation.correct_animation(frames, @@ -215,6 +216,7 @@ def _command_move_start_to_current_position(**kwargs): frames = animation.load_animation(os.path.abspath("animation.csv"), x0=client.active_client.X0_COMMON, y0=client.active_client.Y0_COMMON, + ratio=client.active_client.RATIO, ) # Correct start and land frames in animation corrected_frames, start_action, start_delay = animation.correct_animation(frames, @@ -362,6 +364,7 @@ def _play_animation(**kwargs): x0=client.active_client.X0 + client.active_client.X0_COMMON, y0=client.active_client.Y0 + client.active_client.Y0_COMMON, z0=client.active_client.Z0 + client.active_client.Z0_COMMON, + ratio=client.active_client.RATIO, ) # Correct start and land frames in animation corrected_frames, start_action, start_delay = animation.correct_animation(frames,