Run It
Every instrument is mocked, so the example runs without hardware.
bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run headingThe procedure
procedure.yaml
name: Heading Indicatorversion: 1.0.0plugs: - key: turntable name: Turntable python: plugs.turntable:Turntablemain: - key: heading name: Turn to heading python: phases.heading:turn measurements: - key: final_heading name: Heading after the turn unit: deg validators: - operator: ">=" expected_value: 268 - operator: "<=" expected_value: 272 ui: panel: panels/heading.htmlThe panel
panels/heading.html
<div class="inst"> <div class="dial"> <svg viewBox="38 7 210 210" role="img" aria-label="Heading indicator"> <rect x="43" y="12" width="200" height="200" rx="18" fill="#1b1f24"/> <circle cx="54" cy="23" r="4" fill="#4a525b"/><circle cx="232" cy="23" r="4" fill="#4a525b"/> <circle cx="54" cy="201" r="4" fill="#4a525b"/><circle cx="232" cy="201" r="4" fill="#4a525b"/> <circle cx="143" cy="112" r="94" fill="#2a3037"/> <circle cx="143" cy="112" r="90" fill="#0c0e10"/> <g class="card" data-bind="ui.hdg"> <path d="M150.0 32.3L150.5 26.3M163.7 34.7L165.3 28.9M176.8 39.5L179.3 34.1M188.9 46.5L192.3 41.6M199.6 55.4L203.8 51.2M208.5 66.1L213.4 62.7M215.5 78.2L220.9 75.7M220.3 91.3L226.1 89.7M222.7 105.0L228.7 104.5M222.7 119.0L228.7 119.5M220.3 132.7L226.1 134.3M215.5 145.8L220.9 148.3M208.5 157.9L213.4 161.3M199.6 168.6L203.8 172.8M188.9 177.5L192.3 182.4M176.8 184.5L179.3 189.9M163.7 189.3L165.3 195.1M150.0 191.7L150.5 197.7M136.0 191.7L135.5 197.7M122.3 189.3L120.7 195.1M109.2 184.5L106.7 189.9M97.1 177.5L93.7 182.4M86.4 168.6L82.2 172.8M77.5 157.9L72.6 161.3M70.5 145.8L65.1 148.3M65.7 132.7L59.9 134.3M63.3 119.0L57.3 119.5M63.3 105.0L57.3 104.5M65.7 91.3L59.9 89.7M70.5 78.2L65.1 75.7M77.5 66.1L72.6 62.7M86.4 55.4L82.2 51.2M97.1 46.5L93.7 41.6M109.2 39.5L106.7 34.1M122.3 34.7L120.7 28.9M136.0 32.3L135.5 26.3" stroke="#f2f4f6" stroke-width="1"/> <path d="M143.0 37.0L143.0 26.0M156.0 38.1L157.9 27.3M168.7 41.5L172.4 31.2M180.5 47.0L186.0 37.5M191.2 54.5L198.3 46.1M200.5 63.8L208.9 56.7M208.0 74.5L217.5 69.0M213.5 86.3L223.8 82.6M216.9 99.0L227.7 97.1M218.0 112.0L229.0 112.0M216.9 125.0L227.7 126.9M213.5 137.7L223.8 141.4M208.0 149.5L217.5 155.0M200.5 160.2L208.9 167.3M191.2 169.5L198.3 177.9M180.5 177.0L186.0 186.5M168.7 182.5L172.4 192.8M156.0 185.9L157.9 196.7M143.0 187.0L143.0 198.0M130.0 185.9L128.1 196.7M117.3 182.5L113.6 192.8M105.5 177.0L100.0 186.5M94.8 169.5L87.7 177.9M85.5 160.2L77.1 167.3M78.0 149.5L68.5 155.0M72.5 137.7L62.2 141.4M69.1 125.0L58.3 126.9M68.0 112.0L57.0 112.0M69.1 99.0L58.3 97.1M72.5 86.3L62.2 82.6M78.0 74.5L68.5 69.0M85.5 63.8L77.1 56.7M94.8 54.5L87.7 46.1M105.5 47.0L100.0 37.5M117.3 41.5L113.6 31.2M130.0 38.1L128.1 27.3" stroke="#f2f4f6" stroke-width="2.2"/> <text x="143" y="48" class="num cardinal" transform="rotate(0 143 112)">N</text><text x="143" y="48" class="num" transform="rotate(30 143 112)">3</text><text x="143" y="48" class="num" transform="rotate(60 143 112)">6</text><text x="143" y="48" class="num cardinal" transform="rotate(90 143 112)">E</text><text x="143" y="48" class="num" transform="rotate(120 143 112)">12</text><text x="143" y="48" class="num" transform="rotate(150 143 112)">15</text><text x="143" y="48" class="num cardinal" transform="rotate(180 143 112)">S</text><text x="143" y="48" class="num" transform="rotate(210 143 112)">21</text><text x="143" y="48" class="num" transform="rotate(240 143 112)">24</text><text x="143" y="48" class="num cardinal" transform="rotate(270 143 112)">W</text><text x="143" y="48" class="num" transform="rotate(300 143 112)">30</text><text x="143" y="48" class="num" transform="rotate(330 143 112)">33</text> <g class="bug" data-bind="ui.hdg_bug"> <path d="M137 20H149V25L143 29L137 25Z"/> </g> </g> <path class="lubber" d="M143 33L137 22H149Z"/> <path d="M143 96V128M131 104H155M137 124H149" class="plane"/> </svg> <div class="readout heading"> <b data-bind="ui.hdg" data-format="0">0</b> <span>HDG</span> </div> </div></div><style> .inst { display: flex; justify-content: center; padding: 0 16px; } .dial { position: relative; width: min(360px, 90vw); } .dial svg { display: block; width: 100%; height: auto; } .num { font: 700 15px "Barlow Condensed", "Arial Narrow", sans-serif; fill: #f2f4f6; text-anchor: middle; dominant-baseline: central; } .cap { font: 600 7px system-ui, sans-serif; fill: #8a949e; text-anchor: middle; letter-spacing: .12em; } .readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; pointer-events: none; } .readout b { font: 600 30px/1 ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; color: #f2f4f6; transition: color .2s; } .readout span { font: 600 10px system-ui, sans-serif; letter-spacing: .12em; color: #8a949e; } .track, .arc { fill: none; stroke-width: 7; stroke-linecap: round; } .track { stroke: #22282f; } .arc { stroke: #4aa8ff; transition: stroke-dasharray .12s linear, stroke .2s; } .tip { fill: #f2f4f6; transform-box: view-box; transform-origin: 143px 112px; transition: transform .12s linear, fill .2s; } /* The card turns under the lubber line: the heading reads at the top. */ .card { transform-box: view-box; transform-origin: 143px 112px; transform: rotate(calc(var(--value, 0) * -1deg)); transition: transform .12s linear; } .cardinal { font-size: 18px; } .bug { fill: #22d3ee; transform-box: view-box; transform-origin: 143px 112px; transform: rotate(calc(var(--value, 0) * 1deg)); } .lubber { fill: #4aa8ff; } .plane { stroke: #8a949e; stroke-width: 2.5; stroke-linecap: round; fill: none; } .readout.heading { justify-content: flex-end; padding-bottom: 30%; } .readout.heading b { font-size: 24px; }</style>The phase
phases/heading.py
"""Turns the unit to the selected heading on a turntable. The panel's cardfollows `ui.hdg`, a value only the panel shows, and its bug sits on`ui.hdg_bug`. The run records the heading after the turn."""import timeSELECTED_DEG = 270def turn(ui, measurements, turntable): ui.hdg_bug = SELECTED_DEG heading = 0.0 for _ in range(turntable.length()): heading = turntable.read() ui.hdg = heading time.sleep(0.1) measurements.final_heading = heading time.sleep(1.5)The mocked instrument
plugs/turntable.py
"""Mock turntable: replays a right turn from 090 to 270, one heading per read.Replace it with your turntable's driver on a real bench."""import math# Hold, turn right with a small overshoot, settle on the selected heading.PROFILE = [(90, 90, 10), (90, 272, 110), (272, 270, 30), (270, 270, 25)]class Turntable: def __init__(self): self.samples = [] for h0, h1, steps in PROFILE: for i in range(steps): eased = 0.5 - 0.5 * math.cos(math.pi * (i + 1) / steps) self.samples.append(h0 + (h1 - h0) * eased + 0.2 * math.sin(len(self.samples) * 1.7)) self.index = 0 def length(self): return len(self.samples) def read(self): """Heading in degrees.""" heading = self.samples[min(self.index, len(self.samples) - 1)] self.index += 1 return round(heading, 1)