From 9b69a0862558ff1afe49ddf980981ca1510de454 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 11 六月 2024 16:33:27 +0800
Subject: [PATCH] #

---
 src/components/agv.jsx |   45 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/components/agv.jsx b/src/components/agv.jsx
index 861b4fb..a7ee415 100644
--- a/src/components/agv.jsx
+++ b/src/components/agv.jsx
@@ -127,8 +127,41 @@
     }
 }
 
+const getMajorPos = (position, bodyAngle, offset) => {
+    const majorAngle = Common.positiveAngle(bodyAngle);
+    // console.log(position, majorAngle, offset);
+    if (majorAngle > 360 - 10 || majorAngle < 0 + 10) {
+        return {
+            x: (position?.[2] + offset) * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
+            y: position?.[1] * REAL_COMPARE_MAP_SCALE,
+            z: position?.[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z,
+        }
+    }
+    if (majorAngle > 180 - 10 && majorAngle < 180 + 10) {
+        return {
+            x: (position?.[2] - offset) * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
+            y: position?.[1] * REAL_COMPARE_MAP_SCALE,
+            z: position?.[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z,
+        }
+    }
+    if (majorAngle > 90 - 10 && majorAngle < 90 + 10) {
+        return {
+            x: position?.[2] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
+            y: position?.[1] * REAL_COMPARE_MAP_SCALE,
+            z: (position?.[0] - offset) * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z,
+        }
+    }
+    if (majorAngle > 270 - 10 && majorAngle < 270 + 10) {
+        return {
+            x: position?.[2] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
+            y: position?.[1] * REAL_COMPARE_MAP_SCALE,
+            z: (position?.[0] + offset) * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z,
+        }
+    }
+}
+
 const Agv = (props) => {
-    const { agvNo, position, trayList, hasBox, finger1, finger2, finger3, finger4, inOutFlag } = props;
+    const { agvNo, position, trayList, hasBox, finger1, finger2, finger3, finger4, inOutFlag, offset } = props;
     const theta = -props.theta;
     const height = props.height * 0.0655;
 
@@ -144,12 +177,11 @@
             return;
         }
 
+        // group theta
+        const targetTheta = Common.normalizeAngle(theta - groupTheta) + groupTheta;
         // group position
-        const pos = {
-            x: position?.[2] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
-            y: position?.[1] * REAL_COMPARE_MAP_SCALE,
-            z: position?.[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z,
-        }
+        const pos = getMajorPos(position, targetTheta, offset);
+
         if (!Common.deepEqual(groupPos, pos) && props.position !== null) {
             new TWEEN.Tween(groupPos)
                 .to(pos, INTERVAL_TIME)
@@ -164,7 +196,6 @@
 
         // group theta
         if (groupTheta !== theta && props.theta !== null) {
-            const targetTheta = Common.normalizeAngle(theta - groupTheta) + groupTheta;
             new TWEEN.Tween({ value: groupTheta })
                 .to({ value: targetTheta }, INTERVAL_TIME)
                 .easing(TWEEN.Easing.Linear.None)

--
Gitblit v1.9.1