summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoNainRatio <120639162+AntoNainRatio@users.noreply.github.com>2024-04-02 14:37:42 +0300
committerAntoNainRatio <120639162+AntoNainRatio@users.noreply.github.com>2024-04-02 14:37:42 +0300
commit40e1f17920fc453149379495bf47a8d12a50a43e (patch)
tree73894e2dab81efadb5514b408068602cd2f318c0
parent36e299381ad106fc5eeb6b6b0b87aed396188175 (diff)
opti angle 1
-rw-r--r--robot.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/robot.js b/robot.js
index 11409c0..7a89de9 100644
--- a/robot.js
+++ b/robot.js
@@ -34,6 +34,14 @@ async function moveTo(x,y)
var dist = Math.sqrt(x * x + y * y)
console.log('dist is '+dist)
var angle = (Math.atan2(y,x))*180/Math.PI
+ if(angle>180)
+ {
+ angle-=180
+ }
+ else if(angle<-180)
+ {
+ angle+=180
+ }
console.log(angle.toString())
var str = 'T'+(Math.floor(angle)-90).toString()
client.publish('move',str)