|
|
@@ -47,7 +47,7 @@ def restart_serial(port, baudrate=115200):
|
|
|
disconnect_serial()
|
|
|
connect_to_serial(port, baudrate)
|
|
|
|
|
|
-def parse_theta_rho_file(file_path, apply_transformations=False):
|
|
|
+def parse_theta_rho_file(file_path):
|
|
|
"""
|
|
|
Parse a theta-rho file and return a list of (theta, rho) pairs.
|
|
|
Optionally apply transformations (rotation and mirroring).
|
|
|
@@ -64,20 +64,7 @@ def parse_theta_rho_file(file_path, apply_transformations=False):
|
|
|
# Parse lines with theta and rho separated by spaces
|
|
|
try:
|
|
|
theta, rho = map(float, line.split())
|
|
|
- if apply_transformations:
|
|
|
- # Rotate 90 degrees clockwise
|
|
|
- theta_rotated = theta - (math.pi / 2)
|
|
|
- if theta_rotated < 0: # Ensure theta stays within [0, 2π)
|
|
|
- theta_rotated += 2 * math.pi
|
|
|
-
|
|
|
- # Apply vertical mirror (negate theta)
|
|
|
- theta_mirrored = -theta_rotated
|
|
|
- if theta_mirrored < 0: # Ensure theta stays within [0, 2π)
|
|
|
- theta_mirrored += 2 * math.pi
|
|
|
-
|
|
|
- coordinates.append((theta_mirrored, rho))
|
|
|
- else:
|
|
|
- coordinates.append((theta, rho))
|
|
|
+ coordinates.append((theta, rho))
|
|
|
except ValueError:
|
|
|
print(f"Skipping invalid line: {line}")
|
|
|
except Exception as e:
|
|
|
@@ -111,7 +98,7 @@ def run_theta_rho_file(file_path):
|
|
|
global stop_requested
|
|
|
stop_requested = False
|
|
|
|
|
|
- coordinates = parse_theta_rho_file(file_path, apply_transformations = False)
|
|
|
+ coordinates = parse_theta_rho_file(file_path)
|
|
|
if len(coordinates) < 2:
|
|
|
print("Not enough coordinates for interpolation.")
|
|
|
return
|
|
|
@@ -332,7 +319,7 @@ def preview_thr():
|
|
|
|
|
|
try:
|
|
|
# Parse the .thr file with transformations
|
|
|
- coordinates = parse_theta_rho_file(file_path, apply_transformations=True)
|
|
|
+ coordinates = parse_theta_rho_file(file_path)
|
|
|
return jsonify({'success': True, 'coordinates': coordinates})
|
|
|
except Exception as e:
|
|
|
return jsonify({'error': str(e)}), 500
|