Source

puma / Puma.py

Diff from to

File Puma.py

 		#print cmd
 		self.sock.send(cmd + "\r\n")
 
+	# Move one axis to a set of counts
+	def moveto(self, axis, count, vel):
+		cmd = "move," + str(int(axis)) + "," + str(int(count)) + "," + str(int(vel))
+		self.sock.send(cmd + "\r\n")
+
 	def home(self):
 		self.move_raw(2000, [0,0,0,0,0,0])
+	def start(self):
+		self.move_raw(2000, [4552, 3893, -16821, 23999, -11607, -4646])
+
+	def swing(self, speed):
+		cur = self.counts[5]
+		self.moveto(6, cur + 10000, 1000)
+		time.sleep(1)
+		self.moveto(6, cur - 10000, speed)
+		time.sleep(1)
+		self.moveto(6, cur, 1000)
 
 	# Move immediately to an explicit IK computed position
 	def move_ik(self, ms, xyz, a, s, n):
 		cur_s = self.fk.s[:]
 		cur_n = self.fk.n[:]
 
-		# Use a tool-down, face forward ASN
-		cur_a = [0,0,-1]
-		cur_s = [0,1,0]
-		cur_n = [-1,0,0]
+		# For the swinging tool on the left side of the board,
+		# the position is facing (approach) due X,
+		# sliding in Z and the normal to Y
+		cur_a = [1,0,0]
+		cur_s = [0,0,1]
+		cur_n = [0,1,0]
 
 		dx = dst_xyz[0] - xyz[0]
 		dy = dst_xyz[1] - xyz[1]
 		if line == "home":
 			r.home()
 			continue
+		if line == "start":
+			r.start()
+			continue
+		if line == "swing":
+			r.swing(30000)
+			continue
 		if line == "hold":
 			r.move_raw(1000, r.counts)
 			r.last_xyz = False