animation_lib: add get_start_xy function

This commit is contained in:
Arthur Golubtsov
2019-10-25 15:18:56 +01:00
parent d33cc0c32d
commit dc85d9bd3f

View File

@@ -37,9 +37,43 @@ def get_id(filepath="animation.csv"):
anim_id = row_0[0]
print("Got animation_id: {}".format(anim_id))
else:
anim_id = "Empty id"
print("No animation id in file")
return anim_id
def get_start_xy(filepath="animation.csv"):
try:
animation_file = open(filepath)
except IOError:
logging.error("File {} can't be opened".format(filepath))
anim_id = "No animation"
return float('nan'), float('nan')
else:
with animation_file:
csv_reader = csv.reader(
animation_file, delimiter=',', quotechar='|'
)
try:
row_0 = csv_reader.next()
except:
return float('nan'), float('nan')
if len(row_0) == 1:
anim_id = row_0[0]
print("Got animation_id: {}".format(anim_id))
try:
frame_number, x, y, z, yaw, red, green, blue = csv_reader.next()
except:
return float('nan'), float('nan')
else:
anim_id = "Empty id"
print("No animation id in file")
try:
frame_number, x, y, z, yaw, red, green, blue = row_0
except:
return float('nan'), float('nan')
return float(x), float(y)
def load_animation(filepath="animation.csv", x0=0, y0=0, z0=0, x_ratio=1, y_ratio=1, z_ratio=1):
imported_frames = []
global anim_id