Packages that control devices
A package can offer items to other machines in a mesh. It lists them under mesh_catalog in its
singularity.json. This page covers the rules for items that move hardware, belong to an attached
device, or show a notification. Snippbot checks these rules itself. It doesn’t rely on your package
to follow them.
An example
Section titled “An example”{ "mesh_catalog": { "items": [ { "slug": "head", "kind": "movement", "name": "Head", "process": "subprocess", "device": { "id": "desk-bot", "name": "Desk robot", "type": "robot" }, "actions": [ { "id": "turn", "name": "Turn the head", "effects": ["moves_hardware"], "input": { "pan": "integer", "tilt": "integer", "speed": "integer" }, "motion": { "axes": [ { "name": "pan", "min": -90, "max": 90, "unit": "deg" }, { "name": "tilt", "min": -30, "max": 45, "unit": "deg" } ], "speed_max": 60, "speed_unit": "deg_s" } } ] } ], "provider": { "run": ["bin/runner"], "process": "subprocess" } }}Moving actions
Section titled “Moving actions”An action moves hardware when its item’s kind is movement or the action lists the
moves_hardware effect.
Declare its motion limits
Section titled “Declare its motion limits”Give each moving action a motion object:
axes: 1 to 6 axes, each{name, min, max, unit}. Sort the axes by name and use each name once. A name is a lowercase letter followed by up to 31 lowercase letters, digits or_.minmust be less thanmax.unitisdegormm.speed_max: the top speed, from 1 to 1,000,000.speed_unit:deg_sormm_s.
Use whole numbers only. min and max must be between -1,000,000 and 1,000,000. motion takes
no other fields.
Match the input to the limits
Section titled “Match the input to the limits”A moving action’s input must have exactly one numeric field for each axis, named after it, plus a
numeric speed. A numeric field has type number or integer. Don’t name an axis speed.
Axis values are absolute positions within [min, max]. They are not steps or offsets from where
the device is now. A runner that treats them as relative moves breaks its declaration.
If motion is missing or invalid, or the input has any other field (a step size, a relative
switch, a duration), Snippbot drops the motion limits and the action is Restricted: someone is
asked every time it is used. A moving action with valid limits is classed Operate.
What Snippbot checks before a move
Section titled “What Snippbot checks before a move”Snippbot checks every call against the limits before your runner hears of it. It refuses the call when:
- an axis value is outside
[min, max], or isn’t a finite number speedis missing, below 0, abovespeed_max, or isn’t a finite number
An axis left out of a call is not moved.
Stopping on an emergency stop
Section titled “Stopping on an emergency stop”If any item in your package moves hardware, Snippbot sends your running runner this line when the machine has to stop mesh work: an emergency stop, the mesh switched off on this machine, or the machine isolated or paused:
{"op": "halt"}Your runner must stop all motion and answer within 2 seconds with:
{"op": "halted"}Exiting within those 2 seconds also counts. Otherwise Snippbot kills the runner’s whole process
group at once. An older runner that doesn’t know halt doesn’t answer, so it is killed too. When a
runner is killed, its open uses end as crashed. If Snippbot can’t read the installed packages’
declarations at that moment, it sends halt to every running runner.
Each stop is written to the audit log, once per device, with what happened: halted, exited,
killed or not_running.
Naming the device
Section titled “Naming the device”An item may name the attached device it belongs to:
"device": { "id": "desk-bot", "name": "Desk robot", "type": "robot" }id: 1 to 48 characters. It starts with a lowercase letter or digit, then lowercase letters, digits,_,.or-.name: 1 to 48 characters that can be shown.type:robot,iotorphone.
device takes exactly these three fields. If one item’s device is invalid, none of the package’s
items are listed.
Notifications
Section titled “Notifications”An item of kind notify takes exactly one input field, text, which must not be blank. Your runner
gets the text with the asking machine’s name in front:
studio-mac: The print is done.Snippbot adds the machine name from the mesh record, never from the input. It joins all whitespace into single spaces and keeps at most 200 characters of the text. Each machine can send at most 5 notifications an hour to this machine. Show the text as plain text, with no links or buttons, so it never looks like an approval request.