1
0
Эх сурвалжийг харах

remove speed adjustment, fix rho drift,fix threading issue

Tuan Nguyen 1 жил өмнө
parent
commit
06f472b0de
2 өөрчлөгдсөн 17 нэмэгдсэн , 5 устгасан
  1. 17 0
      app.py
  2. 0 5
      esp32/esp32.ino

+ 17 - 0
app.py

@@ -103,6 +103,23 @@ def parse_theta_rho_file(file_path):
         print(f"Error reading file: {e}")
         return coordinates
 
+    # ---- Normalization Step ----
+    if coordinates:
+        # Take the first coordinate's theta
+        first_theta = coordinates[0][0]
+
+        # Shift all thetas so the first coordinate has theta=0
+        normalized = []
+        for (theta, rho) in coordinates:
+            if rho > 1:
+                rho = 1
+            elif rho < 0:
+                rho = 0
+            normalized.append((theta - first_theta, rho))
+
+        # Replace original list with normalized data
+        coordinates = normalized
+
     return coordinates
 
 def send_coordinate_batch(ser, coordinates):

+ 0 - 5
esp32/esp32.ino

@@ -190,11 +190,6 @@ void homing()
 
 void movePolar(double theta, double rho)
 {
-    if (rho < 0.0) 
-        rho = 0.0;
-    else if (rho > 1.0) 
-        rho = 1.0;
-
     long rotSteps = lround(theta * (rot_total_steps / (2.0f * M_PI)));
     double revolutions = theta / (2.0 * M_PI);
     long offsetSteps = lround(revolutions * (rot_total_steps / gearRatio));