2Reads data from a serial port and displays it in real-time using matplotlib.
3Make sure to set COM_PORT to the correct value before running.
7from rendering
import PointsInSpace
17 parity=serial.PARITY_NONE,
18 stopbits=serial.STOPBITS_ONE,
19 bytesize=serial.EIGHTBITS,
23print(
"Connected to: " + ser.portstr)
31 "End Effector Position",
39pp.register_plot(
"connected", alpha=0.4)
40pp.register_plot(
"mirror", alpha=0.4)
48 bytes_to_read = ser.in_waiting
49 if bytes_to_read < MIN_MESSAGE_BYTES:
51 line = ser.read(bytes_to_read).decode(
"utf-8")
52 segments = line.split()
58 return float(segments[segments.index(f
"{label}:") + 1])
83 x_mirror_list.append(x_mirror)
84 z_mirror_list.append(z_mirror)
85 except Exception
as e:
89 if len(x_list) > TRAILING_POINTS:
97 pp.draw_points(
"connected", z_list, x_list)
98 pp.draw_points(
"mirror", z_mirror_list, x_mirror_list)
113 except Exception
as e:
116 print(
"Closed connection")
120print(
"Closed connection")