Virtual commissioning (bt.vc)¶
The cell as the plant of a controller outside it: the exchange derived from the I/O map, a plant session driven through it, loopback and replay, and the Modbus / OPC UA links to a controller on the wire. See Virtual commissioning for the guide and Offline commissioning for the file-based half.
xc = bt.vc.exchange(scene, "plc1") # what the controller writes and reads
with bt.vc.loopback(scene, ["pick"], host="plc1") as s:
s.run()
assert s.timeline().duration == tl.duration # the bake, bit for bit
rec = s.recording() # every input, with its time
cases = [bt.vc.TestCase("beam open", faults=[bt.io.open("beam")], # the FAT: tests as a table
expect=[bt.vc.never("vacuum", during=10.0)]),
*bt.vc.interlock_tests(scene, "pick"), *bt.vc.safety_tests(scene)]
fat = bt.vc.run_fat(scene, cases) # offline; links={"plc1": link} for a PLC
fat.save("cell_fat.md"); assert fat.ok
link = bt.vc.ursim(bt.vc.exchange(scene, "UR"), robot="arm") # the robot controller in the loop (URSim, RTDE)
uop = bt.vc.interfaces.fanuc_uop_pns(programs={"pick": 1}) # a vendor interface as data
uop.apply(scene, "arm", "RC1")
bt.parts.cylinder(scene, "press", (0.2, 0, 0.55), axis=(0, 0, -1), stroke=0.03, solenoid="double")
scene.add_linear_axis("feed", ["strip"], axis=(1, 0, 0), speed=0.25, range=(0, 0.4), encoder=True)
scene.add_io_node("PLC1", kind="plc", programs=["index"],
channels=bt.io.di8() + bt.io.do8() + bt.io.word(4, base="%QW100", unit="mm"))
xc = bt.vc.exchange(scene, "PLC1") # press/extend, press/retract, press/extended, press/retracted,
# feed.position (INT, mm), feed (done), feed.encoder (INT, mm)
tl.word("feed.encoder").max() # the word lanes the plant records
s.word("feed.encoder") # … and reads live
vc
¶
Virtual commissioning: the cell as the plant of a controller outside it (design-virtual-commissioning.md, VC1).
The bake is the trajectory the cell follows if its controller behaves as
designed. A plant session lets a controller actually drive the cell: the
programs on the controller's host are not scanned — the controller writes
the host's inputs (coils, device commands, robot start and program words)
and reads its outputs (sensors, limit switches, in-position and done
contacts, handshake wires) through the host's exchange, the half of the
I/O map that host sees. Everything else — the other programs, devices,
sensors, physics — runs as in the bake, so the result is the same
SequenceTimeline: studio playback, USD, the clearance report and
tl.diff work on it unchanged.
Nothing here is authored. The exchange is derived from the I/O map — the same points, variables, types and addresses the PLCopen export declares::
xc = bt.vc.exchange(scene, "plc1") # what the controller writes and reads
print(xc.to_markdown())
Two links come with VC1, both deterministic (no wall clock):
-
loopback — botrail runs the host's own programs, but every action they fire is encoded onto the exchange and decoded back. The reference run: it reproduces the batch bake bit for bit, which is what proves the exchange lossless and the I/O derivation complete::
with bt.vc.loopback(scene, ["pick"], host="UR") as s: s.run() # to the end of the programs tl2 = s.timeline() # == scene.simulate_sequence("pick") rec = s.recording() # every input written, with its time
-
replay — the recorded inputs fed back, with the host external::
with bt.vc.Session(scene, ["pick"], links={"UR": bt.vc.replay(rec)}) as s: s.run(for_=tl2.duration)
A session can also pin lanes like a PLC force (force / unforce) and
inject faults (inject(bt.io.stuck("beam", False), at=bt.vc.rising("x"))),
and tl.diff(bt.trace.from_timeline(tl2)) then names where the plant and
the design parted.
With a controller on the wire the session runs in wall-clock time
(pace="realtime"), the plant answering as a field device — a Modbus TCP
server the PLC polls, an OPC UA client of the controller's server, or the
RTDE client of a UR controller that runs the robot's own program and
streams its joints into the plant (bt.vc.ursim; the link's robots make
the session mirror them) — and the programs the plant scans itself cycle
like the controller's (cycle=True)::
xc = bt.vc.exchange(scene, "PLC1")
link = bt.vc.modbus_server(xc, "0.0.0.0:5020", allow_remote=True) # the PLC polls this
with bt.vc.Session(scene, ["pick"], links={"PLC1": link}, pace="realtime", cycle=True) as s:
s.run(for_=60.0)
print(s.stats()) # scans, lag, overruns
d = bake.diff(s.trace(), tolerance=0.1, align_on="conv")
The session is the hand on the plant while it runs — pause / resume /
step, speed, press (a panel button), break_on (a breakpoint on a
lane's edge), record / stop_record (a clip of the run as a timeline of
its own) — and with a studio open on the scene (bt.studio(scene,
block=False)) the run streams there live, the dock's plant bar and the I/O
table's force column send the same commands back, and a stopped recording
lands on the dock playable and exportable (design-virtual-commissioning.md
VC3).
Everything above writes the controller's inputs, which is for a
controller under test. A controller that runs a real machine is only ever
read: bt.vc.monitor mirrors it from a log of its I/O (bt.vc.IoLog) or
through a read-only reader (bt.vc.modbus_reader, bt.vc.opcua_reader),
moving the model with what the controller wrote and comparing what it read
with what the model computes — see monitor.py.
CaseResult
¶
One row filled in: the verdict (pass, fail, n/a, error),
the setup as run, each check, and the window it was judged over.
detail
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
notes
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
source
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
Check
¶
One expectation's verdict on one run: ok is True, False, or
None when the run could not tell (the thing is not observable).
Deviation
¶
Where the machine's reading of a point and the model's lane parted
for longer than the tolerance: kind is late / early (the
machine's edge against the model's), level (the two stand apart, or
one pulsed alone), value (a word outside its band); open while
they still disagree.
open
class-attribute
¶
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
Exchange
¶
The exchange of one controller host — scene.exchange(host) with
the renderings: to_markdown(), to_csv(), to_json(), save(path).
Points are the plant's inputs (the controller writes) and outputs (the
controller reads); entries are the numbered robot commands;
parameters the device constants a bus cannot carry live.
Expectation
¶
Base of the expectations: window is the plant time after the
anchor the check needs (the run is kept going at least that long);
check(run) reads the recorded timeline.
kind
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
FatReport
¶
The FAT sheet: one CaseResult per case, the mode it ran in, and
the timelines of the runs (timelines[name] — playable, exportable,
the evidence behind a red row). ok is no row failed or errored;
rows reported n/a (a precondition that did not take, a derived row
nothing can pin, a step no monitor word shows) do not fail it.
record
¶
record(
scene,
camera: str,
out_dir: Union[str, Path],
*,
cases: Optional[Iterable[str]] = None,
labels: bool = True,
fps: int = 30,
suffix: str = ".mp4",
) -> dict[str, Path]
Films each row's run through camera — the sheet's evidence as
clips, one per case (cases narrows them), named after the case in
out_dir: {case: path}. The 3D I/O tags ride in the picture by
default (labels), so a red row shows which point did what. Rows
that never ran (n/a, error) have no clip. Needs what
bt.capture.record_camera needs (playwright and chromium; ffmpeg
for .mp4 / .gif).
save
¶
Writes the sheet; the format follows the extension (.md,
.csv, .json) unless format says otherwise.
section
¶
The sheet as a cell-report section: scene.cell_report(...,
sections=[fat.section()]).
IoLog
¶
The I/O image of one controller over time. series[label] is that
point's samples (t, value), the first being its first reading and
the rest its changes; written are the points the controller writes
(coils, commands), read the ones it reads (contacts, feedback).
delayed
¶
delayed(label: str, seconds: float) -> IoLog
The same log with one point's changes moved by seconds (its
first reading stays) — a sensor that answers late, to see what a
comparison makes of it.
from_csv
classmethod
¶
from_csv(
text: str,
exchange,
*,
names: Optional[dict[str, str]] = None,
t0: Optional[float] = None,
source: str = "log",
) -> IoLog
Reads a logger's CSV against exchange. names maps headings
the exchange does not know ({"X0": "s1"}); t0 is the time that
becomes zero (the first row's by default).
recording
¶
The controller's writes as a bt.vc.Recording — what
bt.vc.replay feeds a plant session.
to_csv
¶
The wide table: a row at every time something changes, every
point's value in it. Columns are headed by the point's address
(its name when unbound), tag, var or label.
value
¶
The point's value at t — None before its first reading.
IoTap
¶
A link with a logger on it: every image that crosses link — the
plant's outputs going to the controller, the controller's writes
coming back — is kept as an IoLog (tap.log), the table a machine's
data logger would have written of the run. The link itself is
untouched: Session(links={"PLC1": bt.vc.tap(link, xc)}).
Link
¶
Bases: typing.Protocol
What a session asks a controller each scan: given the host, the time
of the scan about to run and the plant's outputs after the last one,
the inputs to write ({label: value}, changed ones suffice).
ModbusReader
¶
A read-only Modbus TCP client of a running controller's server.
exchange is the controller's (bt.vc.exchange(scene, "PLC1")): the
points it writes are read from its coils and holding registers, the
points it reads from its discrete inputs and input registers — the
tables a PLC's Modbus server publishes its output and input images in.
The numbering follows the IEC addresses (%IX100.5 → discrete input
(100 - iec_base) * 8 + 5, %QW100 → holding register 100 -
iec_base); iec_base=0 reads the image where OpenPLC serves it.
addresses={point: number} places a point whose address is in
another notation (X0), tables={point: "coil"} moves one to
another table. Every point must have a place: a reader does not guess
where a controller keeps a bit.
period is the poll period in seconds (0.2 by default). The image is
read in as few requests as the map allows (contiguous blocks, small
gaps bridged).
ModbusServerLink
¶
botrail as a Modbus TCP server — the virtual remote I/O station the
controller polls. exchange is the host's (bt.vc.exchange), bind
the address to listen on ("127.0.0.1:5020"; a non-loopback address
needs allow_remote=True — the link writes the controller's inputs,
so it is for a controller under test; running equipment is read with
bt.vc.modbus_reader, never written). iec_base is the IEC byte / word the controller's
image starts at (OpenPLC v3 maps a slave device from %IX100.0,
%QX100.0, %IW100, %QW100); points bound outside that image, or
unbound, are appended in exchange order.
The server is botrail's own (function codes 1–6, 15, 16 over the MBAP framing): a field device's register image, no library behind it.
exchange
¶
Publishes the plant's outputs to the controller's image and returns the inputs the controller has written since the last scan.
Monitor
¶
The cell mirroring a controller from what was read of it — see the
module's documentation. source is an IoLog (replayed in plant
time) or a reader (bt.vc.modbus_reader, bt.vc.opcua_reader;
followed in wall-clock time). sequences are the cell's programs as
for a plant session: the monitored controller's own (not scanned —
the controller runs them) and whatever the model scans itself (the
equipment's programs); leave out a script that stands in for the
operator, whose buttons the controller reports.
tolerance is how long a reading and the model may disagree before it
counts (0.1 s, or twice the source's period when that is longer — an
edge read by polling is that much late); bands={lane: gap} is how
far a word may sit from the model's (2 % of its value, and 2 counts on
an integer, by default); follow=[...] names the read points the
model takes from the controller instead of comparing (by default the
ones nothing in the model drives, and the panel's push buttons).
deviations
¶
deviations() -> list[Deviation]
Where the readings and the model parted for longer than the
tolerance, in time order; the ones still apart are open.
finish
¶
Closes the monitor into its timeline — the model's run with the
readings and the deviations on it; publish shows it in the open
studios (by default when one followed the run).
log
¶
log() -> IoLog
Everything read so far as an IoLog — save it, and the run
replays exactly (bt.vc.monitor(scene, programs, log)).
readings
¶
The compared readings and the deviations, as the timeline
carries them (a ReadingsMsg).
run
¶
run(
until: Optional[Callable[[Monitor], bool]] = None,
*,
for_: Optional[float] = None,
timeout: Optional[float] = None,
) -> float
Scans until until(monitor) holds or for_ seconds pass. With
neither, a log runs to its end; a live reader has no end, so it
needs one of the two.
waiting
¶
What every program waits on now (SequenceTimeline.waiting) —
the monitored controller's too, when its node reports its steps.
OpcUaClientLink
¶
botrail as an OPC UA client of the controller's server. nodes maps
a point's label to its NodeId string ("ns=4;s=GVL.beam"), or is a
callable label -> NodeId; by default every point is looked up as
ns=<namespace>;s=<tag or variable>. The plant's outputs are written
every period_ms; the controller's writes are taken from a data-change
subscription.
OpcUaReader
¶
A read-only OPC UA client of a running controller's server: every
point's node is read once, then followed through a data-change
subscription. nodes maps a point to its NodeId string
("ns=4;s=GVL.beam") or is a callable label -> NodeId; by default a
point is looked up as ns=<namespace>;s=<tag or variable>. period
is the subscription's publishing interval in seconds (0.5 by default).
Needs asyncua — pip install "botrail[vc]".
Recording
¶
ReplayLink
¶
A recorded input stream played back: at each scan the writes whose time is that scan's. Deterministic — the plant replays the same timeline the recording came from.
Session
¶
A plant session: the cell opened as the plant of the controllers in
links (and of hosts run with no link — a loopback host, or one
whose writes come through apply). Each tick asks every link for
its writes, hands them to the plant, and scans; run ticks until a
predicate holds, a duration passes, or — with neither — the plant's
own programs end. Deterministic: no wall clock, and every input is
recorded (recording()).
The session is also the hand on the plant while it runs: pause /
resume / step hold and release the scan loop (the controller keeps
polling a frozen world), speed scales a realtime run, press pushes
a panel button (its lane high for PRESS_HOLD_S), break_on pauses
at a lane's edge, record / stop_record cut a clip of the run as a
timeline of its own. With a studio connected to the scene the run
streams there live, the dock's plant controls and the I/O table's
force buttons send the same commands back, a stopped recording lands
on the dock as a playable, exportable clip, and finish publishes the
whole run. studio=False keeps a session off the wire to the studio.
PRESS_HOLD_S
class-attribute
¶
Convert a string or number to a floating-point number, if possible.
buttons
property
¶
The lanes a click presses: the cell's panel buttons (sensors
pinned as hmi.button).
finished
property
¶
Every program the plant scans has ended (never true while an external controller's program is still its own).
halted
property
¶
Why the session paused on its own — the breakpoint it hit
(↑part_at_pick at 12.34 s) — or None.
analog
¶
Every analog input's loop now — SequenceTimeline.analog at the
plant's clock: what the transmitter measures, the loop current,
the module's counts, the value the programs read.
apply
¶
Writes a host's inputs by hand (a controller without a link), for the next scan.
break_on
¶
Pauses the session the scan lane takes its rising (or
falling) edge — a breakpoint on a signal.
finish
¶
Closes the session into its timeline (the ordinary
SequenceTimeline); publish broadcasts it to open studios — by
default when a studio followed the run.
force
¶
Pins a lane (a PLC force) until unforce: a contact or a coil
to a level (True / False), a word to a number — a register, or
on an analog input what its transmitter measures, in its
engineering unit (the current, the counts and the scaled value
follow through the loop).
inject
¶
Injects bt.io.stuck / open / node_down now, or at a rising /
step anchor.
pause
¶
Holds the plant where it stands: run idles, the controller
keeps polling a frozen world and its writes wait for the next scan.
press
¶
Presses a push button: its lane (a panel button's zone sensor,
or any lane) is forced high now and released after hold_s plant
seconds (PRESS_HOLD_S by default) — long enough for a polled
controller to see the edge.
run
¶
run(
until: Optional[Callable[[Session], bool]] = None,
*,
for_: Optional[float] = None,
timeout: Optional[float] = None,
) -> float
Ticks until until(session) holds, or for_ seconds of plant
time pass, or — with neither — every program the plant scans has
ended. timeout (plant seconds) raises TimeoutError instead of
waiting forever on a controller that never answers. While paused
(pause, a breakpoint, the studio's hold) the loop idles — the
plant stands, the controller polls it as it stands — and goes on
when resumed or stepped. Returns the clock.
stats
¶
How the session kept time: scans run, and in realtime pace the
mean and worst lag behind the wall clock (s) and the scans that
started more than one period late.
status
¶
The session as the studio's dock shows it: the hosts and their links, the clock and the lag, what is paused, forced, broken on, recorded.
step
¶
n more scans, then hold again (from a running loop: run n
scans past now and pause).
stop_record
¶
Ends the clip and returns it: the stretch since record as a
SequenceTimeline starting at zero (clips keeps them all). With
a studio watching (or publish=True) the clip lands on its dock —
playable, exportable as USD — and the dock stops following the
live plant until follow. None without a recording running.
tick
¶
n scans: each asks the links for their writes for the scan
about to run, applies them, and scans. In realtime pace a scan
waits for its wall-clock moment (dt / speed apart); the lag it
started with is recorded (stats()). A direct tick always scans,
paused or not — it is the step.
waiting
¶
What every program waits on now — SequenceTimeline.waiting at
the plant's clock: the step each program stands in and the
contacts of its exits that do not conduct, with the I/O point the
program reads there and its address. A program on an external
controller shows only when its node reports its steps
(monitor=True): otherwise the plant cannot know where it
stands. After finish, the waits at the end of the run.
word
¶
A word lane's current value — a defined word (dp_warn), an
analog input's scaled value or counts (dp, dp.raw), an encoder
(feed.encoder), an identification reader (reader.id).
write
¶
Keys a value into a defined word — a setpoint changed while
the line runs. The programs read it from their next scan; nothing
is pinned (a program that writes the word overwrites it). A
register an external controller keeps is out of the plant's reach:
declare the word an input (scene.declare_io(word, role="input"))
so the controller reads it from the wire.
TestCase
¶
One row of the FAT: the moment (at, a bt.vc predicate; the
first scan when None), what goes in there — faults (bt.io.stuck /
open / node_down), forces (lanes pinned), press (panel buttons) —
how long the case runs on (until a predicate, for_ seconds, or
until the programs end / the horizon), and what must hold over the
window: given are preconditions (a case whose setup never took is
reported n/a, not failed), expect the verdict. scenario starts
the cell from a named scenario's deltas; skip reports the row n/a
without running it (a derived row nothing can pin).
baseline
property
¶
A row that changes nothing and runs the whole cycle: it shares one run with every other such row.
expect
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
faults
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
given
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
notes
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
press
class-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
source
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
Trace
¶
Recorded signal levels by name: (t, value) samples in time order.
Consecutive equal values are harmless — edges are what the diff reads.
UrDashboard
¶
The controller's dashboard (port 29999) and primary interface (port 30001) as the demo needs them: bring the arm to RUNNING, send a script, read the mode.
command
¶
Dashboard commands, one reply line each. A connection the controller accepts and drops (PolyScope still starting behind a port mapping) is retried.
prepare
¶
Closes popups, unlocks a protective stop a previous program left behind (the controller refuses to start the next one while it stands), powers on and releases the brakes until the arm reports RUNNING.
run_script
¶
Sends a URScript program over the primary interface; the controller runs it at once.
wait_ready
¶
Waits for the dashboard to answer a robotmode (a container
coming up: the port answers before PolyScope does).
UrRtdeLink
¶
botrail as the RTDE client of a Universal Robots controller — URSim or a real one on the bench — with the robot's program running on the controller and the plant mirroring it (design-virtual-commissioning.md VC5, fidelity level 2).
The exchange is the robot controller host's (bt.vc.exchange(scene,
"UR")): what the robot program writes — its coils, the handshakes it
raises — the plant reads from the controller's output bit registers
(write_output_boolean_register in the exported script, rtde=True);
what the program reads — the sensors, the handshakes from other hosts
— the plant writes to the input bit registers
(read_input_boolean_register). Register numbers are the exchange
points' ports (bt.io.ur_registers(), 64 up: 0–63 belong to the
fieldbus interfaces). Alongside, every output package carries
actual_q, which the session feeds to the plant as the robot's joints
(open_plant(joints=[robot]) — the arm moves as the controller moves
it, botrail watches collisions, clearance, sensors and handshakes), and
runtime_state, the controller's word on whether a program runs
(idle — the robot's done contact on the plant side).
The client is botrail's own (protocol v2, one output recipe at
frequency Hz, one input recipe), no library behind it. robot names
the scene robot the controller moves (the host's robot).
idle
property
¶
Whether no program runs on the controller — the robot's done
contact on the plant side (None before the first package).
exchange
¶
The plant's outputs go to the program's input registers (changes only); the program's output registers come back as the plant's inputs (changes only, every register on the first scan).
joints
¶
The controller's actual_q of the last package, or None before
the first one.
done
¶
Bases: botrail.vc._Predicate
A program the plant scans has run to its end (every program when
program is None).
elapsed
¶
Bases: botrail.vc._Predicate
seconds of plant time since the predicate was first checked.
falling
¶
Bases: botrail.vc._Predicate
level
¶
Bases: botrail.vc._Predicate
The lane stands at value.
rising
¶
Bases: botrail.vc._Predicate
The lane rose since the last check (as an until), or its next
rising edge (as an at).
step
¶
Bases: botrail.vc._Predicate
A program the plant scans stands in step name (as an until), or
enters it (as an at).
cases_from_data
¶
cases_from_data(
data: Mapping, scene=None
) -> list[TestCase]
Test cases from plain data — the FAT file's mapping: cases is a
list of rows (name, faults, forces, press, at, until,
for, given, expect, scenario, notes), or of
{"interlock_tests": program | true} / {"safety_tests": true} to
splice the derived rows in (needs scene).
cases_to_data
¶
cases_to_data(cases: Iterable[TestCase]) -> dict
The cases as the plain mapping cases_from_data reads ({"cases":
[...]}) — what a FAT YAML / JSON file holds.
check
¶
check(
fn: Callable[[Any, float, float], Any], label: str
) -> Expectation
Your own predicate: fn(timeline, t0, t1) returns a truth value, or
(ok, detail). For what the built-in expectations do not say.
clearance
¶
clearance(
min_m: float, to: Optional[list[str]] = None
) -> Expectation
The minimum clearance over the window stays at or above min_m
metres (to narrows it to named obstacles).
cycle_within
¶
cycle_within(
seconds: float, program: Optional[str] = None
) -> Expectation
Every program (or program) runs to its end within seconds of the
anchor. An external controller's program ends when its monitor word
parks.
exchange
¶
exchange(
scene, host: str, sequences: Optional[list[str]] = None
) -> Exchange
The exchange of controller host over sequences (every sequence
by default) — derived from the I/O map, never authored.
falls
¶
falls(
lane: str, within: Optional[float] = None
) -> Expectation
lane takes a falling edge within within seconds of the anchor.
held
¶
held(
lane: str,
value: bool = True,
for_: Optional[float] = None,
) -> Expectation
lane holds value from the anchor for for_ seconds (to the end
of the run when None) — no edge in between.
interlock_tests
¶
interlock_tests(
scene,
program: Optional[str] = None,
sequences: Optional[Sequence[str]] = None,
prefix: str = "IL",
) -> list[TestCase]
One case per row of the interlock table (scene.interlocks): the
row's condition pinned false from the first scan — the lanes and
levels the table names as its denial — with the program expected to
reach the gate (given: the step before) and never enter the step
that switches the output. A row whose condition no pin denies (a
timer, motion completion, device or robot feedback, a first step) is
carried as n/a with the reason. program narrows the rows; the cases
run over sequences (every program by default).
load_cases
¶
load_cases(
path: Union[str, Path], scene=None
) -> list[TestCase]
Test cases from a FAT file — .yaml / .yml (PyYAML) or .json —
in the shape cases_from_data reads. Derived rows
(interlock_tests, safety_tests) need scene.
loopback
¶
loopback(
scene,
sequences: Union[str, list[str]],
host: Union[str, Iterable[str]],
**kw,
) -> Session
A session whose external host(s) botrail runs itself, through the exchange — the reference run that must equal the bake.
modbus_reader
¶
modbus_reader(exchange, address: str, **kw) -> ModbusReader
A read-only Modbus TCP client of a running controller (see
[ModbusReader]).
modbus_server
¶
modbus_server(
exchange, bind: str = "127.0.0.1:5020", **kw
) -> ModbusServerLink
botrail as the Modbus TCP server a controller polls (see
[ModbusServerLink]).
never
¶
never(what, during: Optional[float] = None) -> Expectation
A lane is never high — or, with bt.vc.step(program, step), the
step is never entered — during during seconds after the anchor (the
whole run when None).
no_motion
¶
no_motion(
robot: Optional[str] = None,
during: Optional[float] = None,
) -> Expectation
No robot (or robot) starts or continues a motion during during
seconds after the anchor (the whole run when None).
opcua_client
¶
opcua_client(exchange, url: str, **kw) -> OpcUaClientLink
botrail as an OPC UA client of the controller's server (see
[OpcUaClientLink]).
opcua_reader
¶
opcua_reader(exchange, url: str, **kw) -> OpcUaReader
A read-only OPC UA client of a running controller (see
[OpcUaReader]).
replay
¶
replay(
recording: Union[Recording, str, Path],
) -> ReplayLink
A link that plays a recording (or a saved one) back.
rises
¶
rises(
lane: str, within: Optional[float] = None
) -> Expectation
lane takes a rising edge within within plant seconds of the
anchor (by the end of the run when None).
run_fat
¶
run_fat(
scene,
cases: Iterable[TestCase],
sequences: Optional[Sequence[str]] = None,
*,
links: Union[
Mapping[str, Any],
Callable[[], Mapping[str, Any]],
None,
] = None,
horizon: Optional[float] = None,
dt: float = 0.01,
pace: Optional[str] = None,
cycle: bool = False,
before: Optional[Callable[[TestCase], None]] = None,
on_open: Optional[
Callable[[TestCase, Any], None]
] = None,
title: Optional[str] = None,
studio: bool = False,
) -> FatReport
Runs the cases and fills the sheet in. Without links every case is
a loopback session over every host of the program set — botrail's own
executor through its own wiring, bit for bit the bake — so the FAT is
an offline document of the design. With links ({host: link}, or a
callable returning a fresh dict per case, for a controller that must
be restarted between rows) each case is a session with the controller
on the wire, and the sheet has the same shape. horizon caps each
case's plant time after its anchor (default: 1.5 × the baseline cycle
+ 1 s); before(case) runs before a case's session opens and
on_open(case, session) once it listens — where a PLC is stopped and
started again. studio=True streams each case's run to a studio open
on the scene, as a session does.
safety_tests
¶
safety_tests(
scene,
sequences: Optional[Sequence[str]] = None,
prefix: str = "SF",
) -> list[TestCase]
One case per safety input of the I/O map (safety=True on its
declaration or binding) that a program reads: the input pinned to the
level that denies the program's test of it, from the first scan, and
the cycle expected to stall — the E-stop in, the guard switch open,
the curtain broken, none of them let the cycle start. A safety input
whose level no program condition fixes is carried as n/a.
stalls
¶
stalls(
program: Optional[str] = None, at: Optional[str] = None
) -> Expectation
The cycle is refused: program (any program when None) has not
run to its end when the run ends — standing in step at when given.
What a stuck guard switch or an E-stop in must do to a start.
step_reached
¶
step_reached(
program: str,
step: Union[str, Sequence[str]],
within: Optional[float] = None,
) -> Expectation
program enters step (any of several) within within seconds of
the anchor. An external controller's steps are seen through its
monitor word (monitor=True).
ursim
¶
ursim(
exchange, host: str = "127.0.0.1", **kw
) -> UrRtdeLink
botrail as the RTDE client of a UR controller (URSim in Docker, or
one on the bench with allow_remote=True): the robot program runs on
the controller, its I/O crosses the bit registers, and its joints
stream into the plant. See UrRtdeLink.
A machine's log and the monitor¶
A controller that runs a real machine is read, never written: its I/O log replayed, or its image followed through a read-only reader, and compared with the model. See Monitoring.
log = bt.vc.IoLog.load("line_io.csv", xc) # columns by address, tag, variable or name
with bt.vc.monitor(scene, programs, log) as m: # the log replayed on the model
m.run()
m.deviations() # where the machine and the model parted
reader = bt.vc.modbus_reader(xc, "10.0.0.5:502") # function codes 1-4, nothing else
with bt.vc.monitor(scene, programs, reader) as m: # a running PLC, in wall-clock time
m.run(for_=600.0)
m.log().save("shift.csv")
iolog
¶
A controller's I/O over time, as a machine's data logger writes it — read against the cell's exchange.
A PLC's logging function, a SCADA trend or a gateway exports the I/O image
as a table: a time column and one column per device, headed by its address
(X0, %IX100.5) or its tag. IoLog reads such a table against the
exchange of the controller it came from, so every column lands on a point
of the cell — the coils and command words the controller wrote (which
drive the model when the log is replayed) and the contacts and words it
read (which are compared with what the model computes)::
xc = bt.vc.exchange(scene, "PLC1")
log = bt.vc.IoLog.load("line_io.csv", xc) # columns by address, tag, variable or name
print(log.unmatched) # columns that are no point of the cell
A wide table (t, X0, X1, Y0, D100 — one row per sample, an empty cell is
"unchanged") and a long one (t, name, value) are both read. Values are
what the controller holds: 1/0, true/false, on/off on a bit, the
register's number on a word.
bt.vc.tap(link, xc) writes the same table from a plant session — the I/O
of a commissioning run, to replay or to compare later.
IoLog
¶
The I/O image of one controller over time. series[label] is that
point's samples (t, value), the first being its first reading and
the rest its changes; written are the points the controller writes
(coils, commands), read the ones it reads (contacts, feedback).
delayed
¶
delayed(label: str, seconds: float) -> IoLog
The same log with one point's changes moved by seconds (its
first reading stays) — a sensor that answers late, to see what a
comparison makes of it.
from_csv
classmethod
¶
from_csv(
text: str,
exchange,
*,
names: Optional[dict[str, str]] = None,
t0: Optional[float] = None,
source: str = "log",
) -> IoLog
Reads a logger's CSV against exchange. names maps headings
the exchange does not know ({"X0": "s1"}); t0 is the time that
becomes zero (the first row's by default).
recording
¶
The controller's writes as a bt.vc.Recording — what
bt.vc.replay feeds a plant session.
to_csv
¶
The wide table: a row at every time something changes, every
point's value in it. Columns are headed by the point's address
(its name when unbound), tag, var or label.
value
¶
The point's value at t — None before its first reading.
IoTap
¶
A link with a logger on it: every image that crosses link — the
plant's outputs going to the controller, the controller's writes
coming back — is kept as an IoLog (tap.log), the table a machine's
data logger would have written of the run. The link itself is
untouched: Session(links={"PLC1": bt.vc.tap(link, xc)}).
monitor
¶
Monitoring: the cell as the mirror of a controller that runs a real machine (design-plc-resolution.md §11, PM0 / PM1).
A plant session (bt.vc.Session) answers a controller under test: it
writes the controller's inputs. A monitor never answers. It takes the
controller's I/O image as it was read — from a machine's log, or live
through a read-only reader — and does three things with it:
- what the controller wrote (coils, device commands, robot starts) drives the model, so the 3D cell moves as the machine was told to;
- what the controller read and the model computes itself (sensors, limit switches, feedback words) is compared with the model's lanes — never written over them. A disagreement that outlasts the tolerance is a deviation: the machine's sensor came late, never came, reads a level the model does not;
- what the controller read and the model has no source for (a push button, a selector, a setpoint keyed in at the panel) is followed: the model's lane takes the read value.
A log, replayed (deterministic, as fast as it computes)::
xc = bt.vc.exchange(scene, "PLC1", programs)
log = bt.vc.IoLog.load("line_io.csv", xc)
with bt.vc.monitor(scene, programs, log) as m:
m.run() # to the end of the log
for d in m.deviations():
print(d.note) # `s2` rose 0.50 s later on the machine than in the model
tl = m.timeline() # the model's run, with the readings on it
A running controller, read only (wall-clock time)::
reader = bt.vc.modbus_reader(xc, "10.0.0.5:502", period=0.2)
with bt.vc.monitor(scene, programs, reader) as m:
m.run(for_=600.0)
m.log().save("shift.csv") # what was read: replays later, exactly
The monitor has no force, press, write, inject or apply, and
refuses those commands from a studio: nothing goes back to the controller,
by the reader's construction (readers.py) and by this class's. The model
is an approximation: the 3D shows what the controller sees and how the
model moves under its commands, not a photograph of the machine. Start a
live monitor with the machine in the state the scene is built in — the
model does not know what happened before it began to read.
Deviation
¶
Where the machine's reading of a point and the model's lane parted
for longer than the tolerance: kind is late / early (the
machine's edge against the model's), level (the two stand apart, or
one pulsed alone), value (a word outside its band); open while
they still disagree.
open
class-attribute
¶
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
IoLog
¶
The I/O image of one controller over time. series[label] is that
point's samples (t, value), the first being its first reading and
the rest its changes; written are the points the controller writes
(coils, commands), read the ones it reads (contacts, feedback).
delayed
¶
delayed(label: str, seconds: float) -> IoLog
The same log with one point's changes moved by seconds (its
first reading stays) — a sensor that answers late, to see what a
comparison makes of it.
from_csv
classmethod
¶
from_csv(
text: str,
exchange,
*,
names: Optional[dict[str, str]] = None,
t0: Optional[float] = None,
source: str = "log",
) -> IoLog
Reads a logger's CSV against exchange. names maps headings
the exchange does not know ({"X0": "s1"}); t0 is the time that
becomes zero (the first row's by default).
recording
¶
The controller's writes as a bt.vc.Recording — what
bt.vc.replay feeds a plant session.
to_csv
¶
The wide table: a row at every time something changes, every
point's value in it. Columns are headed by the point's address
(its name when unbound), tag, var or label.
value
¶
The point's value at t — None before its first reading.
Monitor
¶
The cell mirroring a controller from what was read of it — see the
module's documentation. source is an IoLog (replayed in plant
time) or a reader (bt.vc.modbus_reader, bt.vc.opcua_reader;
followed in wall-clock time). sequences are the cell's programs as
for a plant session: the monitored controller's own (not scanned —
the controller runs them) and whatever the model scans itself (the
equipment's programs); leave out a script that stands in for the
operator, whose buttons the controller reports.
tolerance is how long a reading and the model may disagree before it
counts (0.1 s, or twice the source's period when that is longer — an
edge read by polling is that much late); bands={lane: gap} is how
far a word may sit from the model's (2 % of its value, and 2 counts on
an integer, by default); follow=[...] names the read points the
model takes from the controller instead of comparing (by default the
ones nothing in the model drives, and the panel's push buttons).
deviations
¶
deviations() -> list[Deviation]
Where the readings and the model parted for longer than the
tolerance, in time order; the ones still apart are open.
finish
¶
Closes the monitor into its timeline — the model's run with the
readings and the deviations on it; publish shows it in the open
studios (by default when one followed the run).
log
¶
log() -> IoLog
Everything read so far as an IoLog — save it, and the run
replays exactly (bt.vc.monitor(scene, programs, log)).
readings
¶
The compared readings and the deviations, as the timeline
carries them (a ReadingsMsg).
run
¶
run(
until: Optional[Callable[[Monitor], bool]] = None,
*,
for_: Optional[float] = None,
timeout: Optional[float] = None,
) -> float
Scans until until(monitor) holds or for_ seconds pass. With
neither, a log runs to its end; a live reader has no end, so it
needs one of the two.
waiting
¶
What every program waits on now (SequenceTimeline.waiting) —
the monitored controller's too, when its node reports its steps.
Session
¶
A plant session: the cell opened as the plant of the controllers in
links (and of hosts run with no link — a loopback host, or one
whose writes come through apply). Each tick asks every link for
its writes, hands them to the plant, and scans; run ticks until a
predicate holds, a duration passes, or — with neither — the plant's
own programs end. Deterministic: no wall clock, and every input is
recorded (recording()).
The session is also the hand on the plant while it runs: pause /
resume / step hold and release the scan loop (the controller keeps
polling a frozen world), speed scales a realtime run, press pushes
a panel button (its lane high for PRESS_HOLD_S), break_on pauses
at a lane's edge, record / stop_record cut a clip of the run as a
timeline of its own. With a studio connected to the scene the run
streams there live, the dock's plant controls and the I/O table's
force buttons send the same commands back, a stopped recording lands
on the dock as a playable, exportable clip, and finish publishes the
whole run. studio=False keeps a session off the wire to the studio.
PRESS_HOLD_S
class-attribute
¶
Convert a string or number to a floating-point number, if possible.
buttons
property
¶
The lanes a click presses: the cell's panel buttons (sensors
pinned as hmi.button).
finished
property
¶
Every program the plant scans has ended (never true while an external controller's program is still its own).
halted
property
¶
Why the session paused on its own — the breakpoint it hit
(↑part_at_pick at 12.34 s) — or None.
analog
¶
Every analog input's loop now — SequenceTimeline.analog at the
plant's clock: what the transmitter measures, the loop current,
the module's counts, the value the programs read.
apply
¶
Writes a host's inputs by hand (a controller without a link), for the next scan.
break_on
¶
Pauses the session the scan lane takes its rising (or
falling) edge — a breakpoint on a signal.
finish
¶
Closes the session into its timeline (the ordinary
SequenceTimeline); publish broadcasts it to open studios — by
default when a studio followed the run.
force
¶
Pins a lane (a PLC force) until unforce: a contact or a coil
to a level (True / False), a word to a number — a register, or
on an analog input what its transmitter measures, in its
engineering unit (the current, the counts and the scaled value
follow through the loop).
inject
¶
Injects bt.io.stuck / open / node_down now, or at a rising /
step anchor.
pause
¶
Holds the plant where it stands: run idles, the controller
keeps polling a frozen world and its writes wait for the next scan.
press
¶
Presses a push button: its lane (a panel button's zone sensor,
or any lane) is forced high now and released after hold_s plant
seconds (PRESS_HOLD_S by default) — long enough for a polled
controller to see the edge.
run
¶
run(
until: Optional[Callable[[Session], bool]] = None,
*,
for_: Optional[float] = None,
timeout: Optional[float] = None,
) -> float
Ticks until until(session) holds, or for_ seconds of plant
time pass, or — with neither — every program the plant scans has
ended. timeout (plant seconds) raises TimeoutError instead of
waiting forever on a controller that never answers. While paused
(pause, a breakpoint, the studio's hold) the loop idles — the
plant stands, the controller polls it as it stands — and goes on
when resumed or stepped. Returns the clock.
stats
¶
How the session kept time: scans run, and in realtime pace the
mean and worst lag behind the wall clock (s) and the scans that
started more than one period late.
status
¶
The session as the studio's dock shows it: the hosts and their links, the clock and the lag, what is paused, forced, broken on, recorded.
step
¶
n more scans, then hold again (from a running loop: run n
scans past now and pause).
stop_record
¶
Ends the clip and returns it: the stretch since record as a
SequenceTimeline starting at zero (clips keeps them all). With
a studio watching (or publish=True) the clip lands on its dock —
playable, exportable as USD — and the dock stops following the
live plant until follow. None without a recording running.
tick
¶
n scans: each asks the links for their writes for the scan
about to run, applies them, and scans. In realtime pace a scan
waits for its wall-clock moment (dt / speed apart); the lag it
started with is recorded (stats()). A direct tick always scans,
paused or not — it is the step.
waiting
¶
What every program waits on now — SequenceTimeline.waiting at
the plant's clock: the step each program stands in and the
contacts of its exits that do not conduct, with the I/O point the
program reads there and its address. A program on an external
controller shows only when its node reports its steps
(monitor=True): otherwise the plant cannot know where it
stands. After finish, the waits at the end of the run.
word
¶
A word lane's current value — a defined word (dp_warn), an
analog input's scaled value or counts (dp, dp.raw), an encoder
(feed.encoder), an identification reader (reader.id).
write
¶
Keys a value into a defined word — a setpoint changed while
the line runs. The programs read it from their next scan; nothing
is pinned (a program that writes the word overwrites it). A
register an external controller keeps is out of the plant's reach:
declare the word an input (scene.declare_io(word, role="input"))
so the controller reads it from the wire.
readers
¶
Readers: a running controller's I/O image, read and never written.
The links in links.py put botrail where the cell's I/O would be: they
write the controller's inputs, which is what a controller under test wants
and what running equipment must never get. A reader is a different type
for a different job — watching a controller that runs a real machine — and
it is read-only by construction, not by a flag:
- [
ModbusReader] — a Modbus TCP client that sends read requests only: function codes 1 (coils), 2 (discrete inputs), 3 (holding registers) and 4 (input registers). The module has one request builder and it refuses any other code; there is no code here that assembles a write (5, 6, 15, 16), a diagnostic or a file transfer. - [
OpcUaReader] — an OPC UA client that reads each node once and then subscribes to its data changes. It never calls Write or a method.
Neither carries a way to start or stop the controller, load a program or
set its clock. A reader hands bt.vc.monitor the latest image it read
(sample); the monitor moves the model with what the controller wrote and
compares what the controller read with what the model computes.
Reading is not free for the controller: every request is served by its
communication task. The poll period is explicit and unhurried by default
(period=0.2 s; a trend, not a scope) — slow it down on a busy CPU, and
prefer the controller's OPC UA server, a gateway or its data logger to a
direct connection to the CPU. Connecting a tool to a control network is
the plant's call (network segmentation, permits), not this module's.
This module imports nothing from links.py.
READ_FUNCTION_CODES
module-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
ModbusReader
¶
A read-only Modbus TCP client of a running controller's server.
exchange is the controller's (bt.vc.exchange(scene, "PLC1")): the
points it writes are read from its coils and holding registers, the
points it reads from its discrete inputs and input registers — the
tables a PLC's Modbus server publishes its output and input images in.
The numbering follows the IEC addresses (%IX100.5 → discrete input
(100 - iec_base) * 8 + 5, %QW100 → holding register 100 -
iec_base); iec_base=0 reads the image where OpenPLC serves it.
addresses={point: number} places a point whose address is in
another notation (X0), tables={point: "coil"} moves one to
another table. Every point must have a place: a reader does not guess
where a controller keeps a bit.
period is the poll period in seconds (0.2 by default). The image is
read in as few requests as the map allows (contiguous blocks, small
gaps bridged).
OpcUaReader
¶
A read-only OPC UA client of a running controller's server: every
point's node is read once, then followed through a data-change
subscription. nodes maps a point to its NodeId string
("ns=4;s=GVL.beam") or is a callable label -> NodeId; by default a
point is looked up as ns=<namespace>;s=<tag or variable>. period
is the subscription's publishing interval in seconds (0.5 by default).
Needs asyncua — pip install "botrail[vc]".
modbus_reader
¶
modbus_reader(exchange, address: str, **kw) -> ModbusReader
A read-only Modbus TCP client of a running controller (see
[ModbusReader]).
opcua_reader
¶
opcua_reader(exchange, url: str, **kw) -> OpcUaReader
A read-only OPC UA client of a running controller (see
[OpcUaReader]).
Interfaces (bt.vc.interfaces)¶
interfaces
¶
Robot controller interfaces as data (design-virtual-commissioning.md VC5, §4.6 / §4.8 fidelity level 1).
A PLC drives a robot through a handful of wires the vendor names: FANUC
calls them the UOP (PROD_START, PNS1-8 + PNSTROBE, PROGRUN), KUKA
Automatic External ($EXT_START, PGNO + PGNO_VALID, APPL_RUN), ABB
System I/O (Start at Main, Cycle On), Universal Robots the remote
control inputs of its I/O setup. botrail's generic handshake has the same
three parts — a start pulse, a program word, a done contact (the I/O
map's rule ⑥) — so a vendor interface is a mapping: which channel of
the controller node each part lands on, with the vendor's name, polarity,
edge and pulse width. That mapping is what these templates hold, as data,
and apply writes it into the I/O map as bindings (tag, invert,
note), from where the I/O list, the exchange table and the handshake
specification carry it::
scene.add_io_node("RC1", kind="robot_controller", robots=["arm"], channels=bt.io.fanuc_uop())
uop = bt.vc.interfaces.fanuc_uop_pns(programs={"pick": 1})
uop.apply(scene, "arm", "RC1") # arm.start → UI18 PROD_START, arm.program → PNS, arm.done → UO3 PROGRUN
print(uop.to_markdown()) # the interface sheet: every signal, its polarity, edge, timing
print(tl.handshake_spec()) # the robot lines now say `PROD_START — falling edge, pulse ≥ 100 ms`
Nothing here changes how the plant or the exporters behave: the engine keeps its generic handshake, the sheet tells the integrator what the controller expects. The numbers are the manuals' standard assignments and the usual PLC timings — check them against the controller's own I/O configuration before wiring.
HANDSHAKE_ROLES
module-attribute
¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.
If the argument is a tuple, the return value is the same object.
Line
¶
One signal of a vendor interface: its role (botrail's word for
it — start, program, done, and the ones the generic handshake
does not drive: enable, ready, fault, reset, at_home, …),
the controller channel it lands on, the vendor's name (tag), the
direction seen from the PLC (in = PLC → robot, out = robot → PLC),
the wire polarity (invert for an active-low / NC signal), the edge
the controller acts on and the pulse width the PLC must hold.
invert
class-attribute
¶
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
note
class-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
RobotInterface
¶
A vendor interface template: its lines, the program numbers the
cell's motions map to (programs), and where the data comes from.
apply
¶
Binds the robot's handshake points on its controller node to the
template's channels: <robot>.start on the start line (an input
of the controller), <robot>.program on the program-select word
when the cell selects among programs, <robot>.done on the busy /
running line (inverted: done is the program not running). The
node must carry the template's channels (bt.io.fanuc_uop() and
friends). Returns {role: "<robot>.<aspect>"} for what was bound.
to_markdown
¶
The interface sheet: every line with its direction, polarity, edge and timing, and the program numbers.
abb_system_io
¶
abb_system_io(
programs: Optional[Mapping[str, int]] = None,
*,
pulse_ms: int = 100,
) -> RobotInterface
ABB's System I/O (IRC5 / OmniCore, bt.io.abb_system_io()):
MotorsOn then StartAtMain (both edge-triggered system inputs)
start the RAPID main; CycleOn is high while it runs, AutoOn and
MotorsOnState say the controller is in automatic with motors on.
Program selection is not a system I/O: a group input (ProgNo) the
RAPID main reads, here on the program role.
fanuc_uop_pns
¶
fanuc_uop_pns(
programs: Optional[Mapping[str, int]] = None,
*,
strobe_ms: int = 100,
start_ms: int = 100,
) -> RobotInterface
FANUC's UOP with PNS program selection on the standard UOP map
(bt.io.fanuc_uop()): the PLC puts the program number on PNS1–8
(UI[9]–UI[16]), latches it with PNSTROBE (UI[17], a pulse), reads it
back on SNO1–8 (UO[11]–UO[18]) acknowledged by SNACK (UO[19]), then
pulses PROD_START (UI[18]) — the program starts on its falling
edge. PROGRUN (UO[3]) is high while it runs. The NC signals *IMSTP,
*HOLD and *SFSPD (UI[1]–UI[3]) must be held high, ENBL (UI[8]) too,
and CMDENBL (UO[1]) says the controller takes remote commands.
programs maps the cell's motions to PNS numbers (PNS0001 = 1).
kuka_automatic_external
¶
kuka_automatic_external(
programs: Optional[Mapping[str, int]] = None,
*,
pulse_ms: int = 100,
) -> RobotInterface
KUKA's Automatic External interface (KRC4 / KRC5,
bt.io.kuka_automatic_external()): the controller asks for a program
number with PGNO_REQ, the PLC puts it on the PGNO bits and strobes
PGNO_VALID, then pulses $EXT_START (rising edge) — APPL_RUN /
$PRO_ACT are high while the program runs. $MOVE_ENABLE and
$DRIVES_OFF (active low) must be held high, $DRIVES_ON pulsed to
switch the drives on, $CONF_MESS acknowledges messages. $RC_RDY1
says the controller is ready for a start.
robot_interface
¶
robot_interface(
scene, robot: str, node: str, template: RobotInterface
) -> dict[str, str]
template.apply(scene, robot, node) — binds a robot's handshake
points on its controller node the way the vendor names them.
ur_remote
¶
ur_remote(
*,
start: str = "DI0",
stop: str = "DI1",
running: str = "DO0",
) -> RobotInterface
Universal Robots' remote control on the standard digital I/O
(bt.io.ur_standard()): an input assigned Start-Prog in the
installation's I/O setup starts the loaded program on its rising
edge, one assigned Stop-Prog stops it, an output set to high when
running reports it. UR has no program-number word on the I/O: the
loaded program itself branches (or the dashboard loads another).