Run It
Every instrument is mocked, so the example runs without hardware.
bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run charuco-detectionThe procedure
procedure.yaml
name: ChArUco Boardversion: 1.0.0plugs: - key: charuco_camera name: Station camera python: plugs.charuco_camera:CharucoCameramain: - key: board name: Detect board python: phases.charuco_detection:detect_board measurements: - key: markers_found name: Markers found unit: "" validators: - operator: ">=" expected_value: 17 - operator: "<=" expected_value: 17 - key: corners_found name: Corners found unit: "" validators: - operator: ">=" expected_value: 24 - operator: "<=" expected_value: 24 ui: panel: panels/detection.htmlThe panel
panels/detection.html
<div class="inst"><svg viewBox="0 0 640 478" role="img"><image class="photo" href="images/charuco.jpg" x="0" y="0" width="640" height="478"/><g data-bind="ui.step"><polygon class="rv mk" style="--k: 0" points="273.1,115.2 297.3,115.2 297.3,140.5 273.1,140.5"/><polygon class="rv mk" style="--k: 1" points="340.5,114.9 364.8,114.9 364.8,140.0 340.5,140.3"/><polygon class="rv mk" style="--k: 2" points="239.5,150.4 263.5,150.1 264.0,175.5 239.7,175.5"/><polygon class="rv mk" style="--k: 3" points="306.7,150.1 331.2,149.9 331.2,175.2 306.9,175.2"/><polygon class="rv mk" style="--k: 4" points="374.4,149.6 398.7,149.6 398.7,174.7 374.4,174.9"/><polygon class="rv mk" style="--k: 5" points="273.3,185.1 297.6,185.1 297.6,210.1 273.3,210.1"/><polygon class="rv mk" style="--k: 6" points="340.5,184.8 364.8,184.5 365.1,209.9 340.8,209.9"/><polygon class="rv mk" style="--k: 7" points="240.0,220.0 264.0,220.0 264.0,245.1 240.0,245.1"/><polygon class="rv mk" style="--k: 8" points="306.9,219.7 331.2,219.7 331.5,244.8 307.2,244.8"/><polygon class="rv mk" style="--k: 9" points="374.4,219.5 398.7,219.5 398.7,244.5 374.4,244.5"/><polygon class="rv mk" style="--k: 10" points="273.6,254.7 297.9,254.7 297.9,279.7 273.6,279.7"/><polygon class="rv mk" style="--k: 11" points="340.8,254.4 365.1,254.4 365.1,279.5 340.8,279.5"/><polygon class="rv mk" style="--k: 12" points="240.0,289.6 264.3,289.6 264.3,314.7 240.0,314.7"/><polygon class="rv mk" style="--k: 13" points="307.2,289.3 331.5,289.1 331.7,314.1 307.2,314.4"/><polygon class="rv mk" style="--k: 14" points="374.4,289.1 398.7,288.8 398.9,314.1 374.7,314.1"/><polygon class="rv mk" style="--k: 15" points="273.9,324.3 297.9,324.0 298.1,349.1 274.1,349.3"/><polygon class="rv mk" style="--k: 16" points="340.8,324.0 365.1,323.7 365.3,349.1 341.1,349.1"/><circle class="rv cr" style="--k: 17" cx="268.5" cy="145.4" r="2.8"/><circle class="rv cr" style="--k: 18" cx="302.2" cy="145.3" r="2.8"/><circle class="rv cr" style="--k: 19" cx="335.8" cy="145.0" r="2.8"/><circle class="rv cr" style="--k: 20" cx="369.4" cy="144.9" r="2.8"/><circle class="rv cr" style="--k: 21" cx="268.6" cy="180.2" r="2.8"/><circle class="rv cr" style="--k: 22" cx="302.2" cy="180.1" r="2.8"/><circle class="rv cr" style="--k: 23" cx="335.9" cy="179.9" r="2.8"/><circle class="rv cr" style="--k: 24" cx="369.5" cy="179.7" r="2.8"/><circle class="rv cr" style="--k: 25" cx="268.7" cy="215.1" r="2.8"/><circle class="rv cr" style="--k: 26" cx="302.3" cy="214.9" r="2.8"/><circle class="rv cr" style="--k: 27" cx="335.9" cy="214.8" r="2.8"/><circle class="rv cr" style="--k: 28" cx="369.6" cy="214.7" r="2.8"/><circle class="rv cr" style="--k: 29" cx="268.8" cy="249.8" r="2.8"/><circle class="rv cr" style="--k: 30" cx="302.4" cy="249.8" r="2.8"/><circle class="rv cr" style="--k: 31" cx="336.1" cy="249.6" r="2.8"/><circle class="rv cr" style="--k: 32" cx="369.7" cy="249.5" r="2.8"/><circle class="rv cr" style="--k: 33" cx="268.9" cy="284.6" r="2.8"/><circle class="rv cr" style="--k: 34" cx="302.5" cy="284.5" r="2.8"/><circle class="rv cr" style="--k: 35" cx="336.2" cy="284.4" r="2.8"/><circle class="rv cr" style="--k: 36" cx="369.8" cy="284.2" r="2.8"/><circle class="rv cr" style="--k: 37" cx="269.0" cy="319.4" r="2.8"/><circle class="rv cr" style="--k: 38" cx="302.6" cy="319.3" r="2.8"/><circle class="rv cr" style="--k: 39" cx="336.4" cy="319.2" r="2.8"/><circle class="rv cr" style="--k: 40" cx="370.0" cy="319.1" r="2.8"/><line class="rv ax" style="--k: 41; stroke: #ff4d4f" x1="235.7" y1="113.8" x2="301.6" y2="111.3"/><line class="rv ax" style="--k: 42; stroke: #38e07a" x1="235.7" y1="113.8" x2="235.9" y2="181.7"/><line class="rv ax" style="--k: 43; stroke: #4aa8ff" x1="235.7" y1="113.8" x2="211.9" y2="102.8"/></g></svg></div><style> .inst { width: min(560px, 100%); margin: 0 auto; } .inst svg { display: block; width: 100%; height: auto; } .inst text { font-family: system-ui, sans-serif; } .dp rect { fill: var(--off); } .dp.on rect, .dp[data-value=true] rect { fill: var(--on); } .led circle { fill: #2a2f35; transition: fill .15s; } .led[data-value=true] circle { fill: var(--led, #38e07a); } .ann text { fill: var(--off); transition: fill .15s; } .ann[data-value=true] text { fill: var(--on); } .d7 rect { fill: var(--off); transition: fill .08s; } .d7[data-value="0"] :is(.sa, .sb, .sc, .sd, .se, .sf) { fill: var(--on); } .d7[data-value="1"] :is(.sb, .sc) { fill: var(--on); } .d7[data-value="2"] :is(.sa, .sb, .sd, .se, .sg) { fill: var(--on); } .d7[data-value="3"] :is(.sa, .sb, .sc, .sd, .sg) { fill: var(--on); } .d7[data-value="4"] :is(.sb, .sc, .sf, .sg) { fill: var(--on); } .d7[data-value="5"] :is(.sa, .sc, .sd, .sf, .sg) { fill: var(--on); } .d7[data-value="6"] :is(.sa, .sc, .sd, .se, .sf, .sg) { fill: var(--on); } .d7[data-value="7"] :is(.sa, .sb, .sc) { fill: var(--on); } .d7[data-value="8"] :is(.sa, .sb, .sc, .sd, .se, .sf, .sg) { fill: var(--on); } .d7[data-value="9"] :is(.sa, .sb, .sc, .sd, .sf, .sg) { fill: var(--on); } .d7[data-value="-"] :is(.sg) { fill: var(--on); } .d7[data-value="E"] :is(.sa, .sd, .se, .sf, .sg) { fill: var(--on); } .d7[data-value="U"] :is(.sb, .sc, .sd, .se, .sf) { fill: var(--on); } .d7[data-value="r"] :is(.se, .sg) { fill: var(--on); } .rv { opacity: clamp(0, calc((var(--value, -1) - var(--k)) * 4 + 1), 1); transition: opacity .15s linear; } .photo { opacity: .92; } .mk { fill: none; stroke: #38e07a; stroke-width: 2; } .cr { fill: none; stroke: #ff4d4f; stroke-width: 1.8; } .ax { stroke-width: 3.5; stroke-linecap: round; }</style>The phase
phases/charuco_detection.py
"""Detects the ChArUco board: `ui.step` reveals its markers, then itscorners, then the board's pose axes. The run records the markers and cornersfound."""import timedef detect_board(ui, measurements, charuco_camera): results = charuco_camera.results() total = results["markers"] + results["corners"] + 3 for _ in range(3): for step in range(total + 1): ui.step = step time.sleep(0.12) time.sleep(1.5) ui.step = -1 time.sleep(0.4) ui.step = total measurements.markers_found = results["markers"] measurements.corners_found = results["corners"] time.sleep(2)The mocked instrument
plugs/charuco_camera.py
"""Mock station camera: the ChArUco markers, corners and board pose OpenCV found on the rotary-stage photo. Replace it with your camera and the OpenCV calls of your station."""import jsonRESULTS = json.loads("{\"markers\":17,\"corners\":24}")class CharucoCamera: def results(self): return RESULTS