summaryrefslogtreecommitdiff
path: root/robot.js
diff options
context:
space:
mode:
Diffstat (limited to 'robot.js')
-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)