Skip to content

Commit

Permalink
correct coord matrix transform; plan stubs for blueapi; print lines t…
Browse files Browse the repository at this point in the history
…o terminal between addition to list
  • Loading branch information
co2e14 committed Dec 11, 2024
1 parent 6d5c48f commit a27746f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
6 changes: 4 additions & 2 deletions correction_files/coord_transform
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# |-1 0 | | 0 1 |
#

0.000000000000000000e+00 -1.000000000000000000e+00
-1.000000000000000000e+00 0.000000000000000000e+00
# 0.000000000000000000e+00 -1.000000000000000000e+00
# -1.000000000000000000e+00 0.000000000000000000e+00

0 1
1 0
3 changes: 3 additions & 0 deletions src/rtc6_fastcs/controller/rtc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ async def proc(self):
bindings = self._conn.get_bindings()
x, y = self.correct_xy(self.x.get(), self.y.get())
bindings.add_jump_to(x, y)
print("---")

class AddArc(XYCorrectedConnectedSubController):
x = AttrRW(Int(), group="ListOps")
Expand All @@ -149,6 +150,7 @@ async def proc(self):
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())
print("---")

class AddLine(XYCorrectedConnectedSubController):
x = AttrRW(Int(), group="ListOps")
Expand All @@ -159,6 +161,7 @@ async def proc(self):
print("adding line")
bindings = self._conn.get_bindings()
bindings.add_line_to(*self.correct_xy(self.x.get(), self.y.get()))
print("---")

@command()
async def init_list(self):
Expand Down
26 changes: 22 additions & 4 deletions src/rtc6_fastcs/plan_stubs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import Generator
import bluesky.plan_stubs as bps
import bluesky.preprocessors as bpp
from rtc6_fastcs.device import Rtc6Eth

from blueapi.core import MsgGenerator
from dodal.common.beamlines.beamline_utils import device_factory
from bluesky.run_engine import call_in_bluesky_event_loop

def line(rtc6: Rtc6Eth, x: int, y: int):
"""add an instruction to draw a line to x, y"""
Expand Down Expand Up @@ -60,9 +63,7 @@ def draw_polygon(rtc6: Rtc6Eth, points: list[JumpOrLineInput]):
@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])
yield from jump(rtc6, *points[0][:-1])
for point in points[1:]:
if isinstance(point[2], bool):
if point[2]:
Expand All @@ -77,3 +78,20 @@ def draw_polygon_with_arcs(rtc6: Rtc6Eth, points: list[JumpOrLineInput | ArcInpu
def go_to_home(rtc6: Rtc6Eth):
yield from bps.stage(rtc6)
yield from jump(rtc6, 0,0)
yield from bps.trigger(rtc6)

# standard shapes



# For BlueAPI

@device_factory()
def create_rtc_device() -> Rtc6Eth:
r = Rtc6Eth()
call_in_bluesky_event_loop(r.connect())
return r

def polygon_with_arcs(points: list[JumpOrLineInput | ArcInput]) -> MsgGenerator:
rtc6 = create_rtc_device()
yield from draw_polygon_with_arcs(rtc6, points)

0 comments on commit a27746f

Please sign in to comment.