瀏覽代碼

Targets moving around

Zhilong Li 4 年之前
父節點
當前提交
392bdd1780
共有 1 個文件被更改,包括 10 次插入2 次删除
  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)]]))))