Browse Source

Targets moving around

Zhilong Li 4 năm trước cách đây
mục cha
commit
392bdd1780
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      target.py

+ 10 - 2
target.py

@@ -3,5 +3,13 @@ import numpy as np
 
 
 class Target(Robot):
-    def __init__(self, simulator, name: str, id: int, position: np.array, rate) -> None:
-        super().__init__(simulator, name, id, position, rate)
+    def __init__(self, simulator, name: str, id: int, position: np.array) -> None:
+        super().__init__(simulator, name, id, position)
+
+    def job(self):
+        if self.waypoint_ctrl():
+            self.ang = (self.ang + np.deg2rad(15)) % 360
+            # self.waypoint_ctrl(desierd_pos=[1000,1000])
+            self.waypoint_ctrl(speed=20, desierd_pos=(self.position-np.dot([0, 10],
+                                                                           np.asarray([[np.cos(self.ang), -np.sin(self.ang)],
+                                                                                       [np.sin(self.ang), np.cos(self.ang)]]))))