diff --git a/hardware.py b/hardware.py index d5cdd25..9b6e664 100644 --- a/hardware.py +++ b/hardware.py @@ -3,6 +3,7 @@ import socket import GCode_Interpreterdc from controller import DummyController + class Hardware: def __init__(self, bind): self.s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) @@ -19,7 +20,6 @@ class SimuHardware(Hardware): def __init__(self, bind): Hardware.__init__(self, bind) - def probe(self, gtm): self.s.send("request\n".encode()) encoder_x = int(socket.SocketIO(self.s, "rw").readline()) @@ -67,11 +67,10 @@ class SimuHardware(Hardware): self.s.send(str(gtm.z_direction).encode() + b" " + str(gtm.FAST_Z_FEEDRATE / gtm.z_throttle).encode() + b"\n") - if __name__ == '__main__': b = "socket.sock" sh = SimuHardware(b) - ctrl=DummyController() + ctrl = DummyController() gtm1 = GCode_Interpreterdc.GCodeToMotors(ctrl, sh) sh.probe(gtm1) print(gtm1.current_units) diff --git a/simulator.py b/simulator.py index 7ce3cb7..ad10050 100755 --- a/simulator.py +++ b/simulator.py @@ -3,17 +3,6 @@ import os import time import numpy as np import matplotlib.pyplot as plt -#from color import Color - - -#c1 = Color("#7d1dd3") -#c2 = Color("#ffe500") -#colors = list(c1.range_to(c2, 42)) - - -def infinite_colors(): - for x in iter(int, 1): - yield colors[x % 42] def parse_speed(text): @@ -99,11 +88,6 @@ class Simulator: class Douche: - colors = infinite_colors() - - last_x = None - last_y = None - def __init__(self): # We will assume no points are `really` in 3D. plt.ion() @@ -113,7 +97,7 @@ class Douche: self.ys = [] ax.set_xlim([0, 300]) ax.set_ylim([0, 300]) - self.line, = ax.plot(self.xs, self.ys) + self.line, = ax.plot(self.xs, self.ys, c="#7d1dd3") def add_point(self, x, y): self.xs.append(x) @@ -156,7 +140,7 @@ class NaiveSimulator(Simulator, Douche): return self.last_update = lt gamma = self.G*(self.command_spd - self.speed) - + self.pos += self.speed * self.time_step self.speed += 1./self.J * (gamma - self.f*self.speed) * self.time_step #print("timestep ", self.time_step)