Anonymous avatar Anonymous committed 4b982b4

Send voltage and track it

Comments (0)

Files changed (2)

 		self.joints = joints
 		self.counts = [0,0,0,0,0]
 		self.last_xyz = False
+		self.volts = 0
 		self.fk = PumaFK(joints)
 		self.ik = PumaIK(False, True, joints)
 		self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 				break
 			line = line.strip()
 			counts = line.split(",")
-			if len(counts) != 6:
+			if len(counts) != 7:
 				print "Parse error: " + line
 				continue
-			self.counts = [int(x) for x in counts]
+			volts = int(counts[0]) / 10.0
+			self.counts = [int(x) for x in counts[1:]]
 			#print "rx: " + line
 			self.fk.update(self.counts)
 			#print [int(x) for x in r.fk.p]
 
+			if volts < 12.0 and self.volts > 12.0:
+				print "NO VOLTAGE"
+			elif volts > 12.0 and self.volts < 12.0:
+				print "DANGER: Motors are live: " + str(round(volts,2)) + " volts"
+			self.volts = volts
+
 		print "RX THREAD EXITED"
 		self.live = False
 
 
 	def tx_loop(self):
 		while self.alive:
-			#counts = MDC.get_volts()
+			volts = MDC.get_volts()
 			counts = MDC.get_counts()
-			self.wfile.write(','.join(counts) + '\n')
+			self.wfile.write(volts[1] + ',' + ','.join(counts) + '\n')
 			time.sleep(0.1)
 
 def write_log():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.