Source

puma / Shuffleboard.py

Diff from to

File Shuffleboard.py

 
 r = None
 
-# Map x distance to height
-# 250 -45
-# 300 -40
-# 350 -35
-# 400 -30
-# 450 -25
+# Coordinate transform the robot Z distance based on the X distance
+# This needs to be calibrated if the robot is moved or the tool
+# adjusted.
+x1 = 400.0
+z1 = -25.0
+x2 = 200.0
+z2 = -35.0
 
 class ShuffleboardSocket(SocketServer.StreamRequestHandler):
 	def handle(self):
 		self.rx_loop()
 
 	def map_z(self, x):
-		if (x >= 400 ): return -5
-		if (x >= 350 ): return -8
-		if (x >= 300 ): return -16
-		if (x >= 250 ): return -27
-		if (x >= 200 ): return -30
+		return (z2 - z1) / (x2 - x1) * (x - x1) + z1
 		return 0
 
 	def moveto(self,x,angle):