mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-05-30 00:39:32 +00:00
Add saving corrected frames for testing
This commit is contained in:
@@ -119,6 +119,14 @@ def correct_animation(frames, frame_delay=0.1, min_takeoff_height=0.5, move_delt
|
||||
del corrected_frames[i]
|
||||
return corrected_frames, start_action, start_delay
|
||||
|
||||
# Needs for test
|
||||
def save_corrected_animation(frames, filename="corrected_animation.csv"):
|
||||
corrected_animation = open(filename, mode='w+')
|
||||
csv_writer = csv.writer(corrected_animation, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
|
||||
for frame in frames:
|
||||
csv_writer.writerow([frame['number'],frame['x'], frame['y'], frame['z']])
|
||||
# print frame
|
||||
corrected_animation.close()
|
||||
|
||||
def convert_frame(frame):
|
||||
return ((frame['x'], frame['y'], frame['z']), (frame['red'], frame['green'], frame['blue']), frame['yaw'])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[SERVER]
|
||||
port = 25000
|
||||
broadcast_port = 8181
|
||||
host = 192.168.1.184
|
||||
host = 192.168.1.101
|
||||
buffer_size = 1024
|
||||
|
||||
[FILETRANSFER]
|
||||
|
||||
@@ -103,7 +103,23 @@ def _response_selfcheck():
|
||||
|
||||
@messaging.request_callback("anim_id")
|
||||
def _response_animation_id():
|
||||
return animation.get_id()
|
||||
# Load animation
|
||||
result = animation.get_id()
|
||||
if result != 'No animation':
|
||||
print ("Saving corrected animation")
|
||||
frames = animation.load_animation(os.path.abspath("animation.csv"),
|
||||
x0=client.active_client.X0 + client.active_client.X0_COMMON,
|
||||
y0=client.active_client.Y0 + client.active_client.Y0_COMMON,
|
||||
)
|
||||
# Correct start and land frames in animation
|
||||
corrected_frames, start_action, start_delay = animation.correct_animation(frames,
|
||||
check_takeoff=client.active_client.TAKEOFF_CHECK,
|
||||
check_land=client.active_client.LAND_CHECK,
|
||||
)
|
||||
print("Start action: {}".format(start_action))
|
||||
# Save corrected animation
|
||||
animation.save_corrected_animation(corrected_frames)
|
||||
return result
|
||||
|
||||
|
||||
@messaging.request_callback("batt_voltage")
|
||||
@@ -247,7 +263,7 @@ def _play_animation(**kwargs):
|
||||
# Calculate first frame start time
|
||||
frame_time = rfp_time + client.active_client.RFP_TIME
|
||||
|
||||
elif start_action == 'arm'
|
||||
elif start_action == 'arm':
|
||||
# Calculate start time
|
||||
start_time += start_delay
|
||||
# Arm
|
||||
|
||||
Reference in New Issue
Block a user