Skip to content

Commit

Permalink
update dockerfile; add jumps to poly; tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
co2e14 committed Dec 10, 2024
1 parent f961931 commit 6d5c48f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ FROM python:${PYTHON_VERSION}-slim AS runtime
# Add apt-get system dependecies for runtime here if needed
COPY --from=build /venv/ /venv/
ENV PATH=/venv/bin:$PATH
RUN rtc6-fastcs install-library

# change this entrypoint if it is not the same as the repo
ENTRYPOINT ["rtc6-fastcs"]
Expand Down
8 changes: 4 additions & 4 deletions src/rtc6_fastcs/controller/rtc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class AddJump(XYCorrectedConnectedSubController):

@command(group="ListOps")
async def proc(self):
print("adding jump")
bindings = self._conn.get_bindings()
x, y = self.correct_xy(self.x.get(), self.y.get())
bindings.add_jump_to(x, y)
Expand All @@ -144,6 +145,7 @@ class AddArc(XYCorrectedConnectedSubController):

@command()
async def proc(self):
print("adding arc")
bindings = self._conn.get_bindings()
x, y = self.correct_xy(self.x.get(), self.y.get())
bindings.add_arc_to(x, y, self.angle.get())
Expand All @@ -154,11 +156,9 @@ class AddLine(XYCorrectedConnectedSubController):

@command()
async def proc(self):
print("adding line")
bindings = self._conn.get_bindings()
print(f"Current addline x: {self.x.get()}")
print(f"Current addline y: {self.y.get()}")
# x, y = self.correct_xy(self.x.get(), self.y.get())
bindings.add_line_to(self.x.get(), self.y.get())
bindings.add_line_to(*self.correct_xy(self.x.get(), self.y.get()))

@command()
async def init_list(self):
Expand Down
31 changes: 21 additions & 10 deletions src/rtc6_fastcs/plan_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,46 @@ def rectangle(rtc6: Rtc6Eth, x: int, y: int, origin: tuple[int, int] = (0, 0)):
yield from line(rtc6, *origin)


@bpp.run_decorator
@bpp.run_decorator()
def draw_square(rtc6: Rtc6Eth, size: int):
yield from bps.stage(rtc6)
yield from rectangle(rtc6, size, size)
yield from bps.trigger(rtc6)


LineInput = tuple[int, int]
JumpOrLineInput = tuple[int, int, bool] # x, y, laser_on
ArcInput = tuple[int, int, float]


@bpp.run_decorator
def draw_polygon(rtc6: Rtc6Eth, points: list[LineInput]):
@bpp.run_decorator()
def draw_polygon(rtc6: Rtc6Eth, points: list[JumpOrLineInput]):
yield from bps.stage(rtc6)
yield from jump(rtc6, *points[0])
yield from jump(rtc6, *points[0][:-1])
for point in points[1:]:
yield from line(rtc6, *point)
if point[2]:
yield from line(rtc6, *point[:-1])
else:
yield from jump(rtc6, *point[:-1])
yield from bps.trigger(rtc6)


@bpp.run_decorator
def draw_polygon_with_arcs(rtc6: Rtc6Eth, points: list[LineInput | ArcInput]):
@bpp.run_decorator()
def draw_polygon_with_arcs(rtc6: Rtc6Eth, points: list[JumpOrLineInput | ArcInput]):
yield from bps.stage(rtc6)
if len(points[0]) != 2:
raise ValueError("List of lines/arcs must start with a single point to jump to")
yield from jump(rtc6, *points[0])
for point in points[1:]:
if len(point) == 2:
yield from line(rtc6, *point)
if isinstance(point[2], bool):
if point[2]:
yield from line(rtc6, *point[:-1])
else:
yield from jump(rtc6, *point[:-1])
else:
yield from arc(rtc6, *point)
yield from bps.trigger(rtc6)

@bpp.run_decorator()
def go_to_home(rtc6: Rtc6Eth):
yield from bps.stage(rtc6)
yield from jump(rtc6, 0,0)

0 comments on commit 6d5c48f

Please sign in to comment.