Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
one more

:facepalm:

remove extra dep

fix typo
  • Loading branch information
misko committed Feb 12, 2024
1 parent cb7142f commit 209ff61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions spf/grbl/grbl_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,13 @@ def move_to(self, points): # takes in a list of points equal to length of map
time.sleep(0.01)

def set_current_position(self, motor_channel, steps):
a_motor_steps, b_motor_steps = steps
motors = self.channel_to_motor_map[motor_channel]
cmd = "G92 %s%0.2f %s%0.2f" % (
motors[0],
steps[0],
b_motor_steps,
motors[1],
steps[1],
a_motor_steps,
)
time.sleep(0.01)
self.s.write((cmd + "\n").encode()) # Send g-code block to grbl
Expand Down
16 changes: 7 additions & 9 deletions spf/grbl/restore_from_power_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from spf.dataset.spf_dataset import SessionsDatasetRealV2
from spf.grbl.grbl_interactive import get_default_dynamics, get_default_gm
from spf.grbl.grbl_interactive import get_default_gm

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -40,21 +40,19 @@
assert np.isclose(rx0, rx1).all()

# get the emitter
tx0 = ds[0]["source_positions_at_t"][-1, 0]
tx1 = ds[1]["source_positions_at_t"][-1, 0]
tx0 = ds[0]["source_positions_at_t"][last_valid_idx, 0]
tx1 = ds[1]["source_positions_at_t"][last_valid_idx, 0]
assert np.isclose(tx0, tx1, rtol=0.1, atol=0.1).all()

print(f"Last valid idx: {last_valid_idx}, rx-pos:{rx0} tx-pos:{tx0}")

dynamics = get_default_dynamics()

gm = get_default_gm(args.serial)
gm.set_current_position(
gm.controller.set_current_position(
motor_channel=ds.get_yaml_config()["emitter"]["motor_channel"],
steps=dynamics.to_steps(tx0),
steps=gm.controller.dynamics.to_steps(tx0),
)

gm.set_current_position(
gm.controller.set_current_position(
motor_channel=ds.get_yaml_config()["receivers"][0]["motor_channel"],
steps=dynamics.to_steps(dynamics.to_steps(rx0)),
steps=gm.controller.dynamics.to_steps(rx0),
)

0 comments on commit 209ff61

Please sign in to comment.