Esta página fue traducida por una máquina y aún no ha sido revisada por una persona. El inglés es la referencia; las correcciones son bienvenidas en GitHub. GitHub
Cookwala / SDK y escenarios / 010
Allow or forbid model estimates and watch the rungs change
A logged model estimate is a rung below a sensor and above time. Forbidding it shows which steps a robot without thermometers can still verify, and how.
Leer primero: /docs/CORE/ /docs/QUICKSTART/
Pasos
Lentil soup on the robot without thermometers, estimates allowed: heating, sauteing, boiling and simmering are verified by model.
dryRunEstimates forbidden: heating and sauteing fall to the person present; boiling, simmering and hot holding fall to time.
dryRunThe robot with thermometers never needs the estimate: every heat step has a sensor.
dryRunBoth runs on the basic robot are accepted with eleven steps; only the verification differs.
Resultado
You can measure how much of a recipe a device verifies by sensor, by estimate, by time or by a person, and compare devices on that. Next: scenario 031 compares two devices on the same recipe.
Línea de comandos
cookwala dryrun examples/lentil-soup.cookwala.json --device examples/capabilities/demo-hob-robot-basic.json --human-present
cookwala dryrun examples/lentil-soup.cookwala.json --device examples/capabilities/demo-hob-robot-basic.json --human-present --no-model
cookwala dryrun examples/lentil-soup.cookwala.json --device examples/capabilities/demo-hob-robot.json --human-present --no-modelSalida grabada
Estado: ok
[1] dryRun: {"state": "accepted", "plan": [{"node": "n1", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n2", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n3", "op": "cw.op.crush", "by": "device", "verifiedBy": "time", "rung": "time"}, {"node": "n4", "op": "cw.op.heat", "by": "device", "verifiedBy": "model", "rung": "model"}, {"node": "n5", "op": "cw.op.saute", "by": "device", "verifiedBy": "model", "rung": "model"}, {"node": "n6", "op": "cw.op.boil", "by": "device", "verifiedBy": "model", "rung": "model"…
[2] dryRun: {"state": "accepted", "plan": [{"node": "n1", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n2", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n3", "op": "cw.op.crush", "by": "device", "verifiedBy": "time", "rung": "time"}, {"node": "n4", "op": "cw.op.heat", "by": "device", "verifiedBy": "human", "rung": "human"}, {"node": "n5", "op": "cw.op.saute", "by": "device", "verifiedBy": "human", "rung": "human"}, {"node": "n6", "op": "cw.op.boil", "by": "device", "verifiedBy": "time", "rung": "time"},…
[3] dryRun: {"state": "accepted", "plan": [{"node": "n1", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n2", "op": "cw.op.cut", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.vision"}, {"node": "n3", "op": "cw.op.crush", "by": "device", "verifiedBy": "time", "rung": "time"}, {"node": "n4", "op": "cw.op.heat", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.pan_surface_temp"}, {"node": "n5", "op": "cw.op.saute", "by": "device", "verifiedBy": "sensor", "rung": "cw.sense.pan_surface_temp"}, {"node": "n6", "op": "cw.op.boil", "by": "devic…Código
Ejecutar: python scenarios/out/010-model-estimates-allowed-or-not/python.py
# Scenario 010: Allow or forbid model estimates and watch the rungs change
# A logged model estimate is a rung below a sensor and above time. Forbidding it shows which steps a robot without thermometers can still verify, and how.
# Run a hub first: python hub/cookwala_hub.py --recipes examples
import json, os
from cookwala.client import CookwalaClient, CookwalaProblem
def load(path):
with open(path, encoding="utf-8") as f:
return json.load(f)
def pick(obj, path):
for part in path.replace("]", "").replace("[", ".").split("."):
obj = obj[int(part)] if part.isdigit() else (len(obj) if part == "length" else obj.get(part))
return obj
c = CookwalaClient(os.environ.get("COOKWALA_HUB", "http://localhost:7878"))
# Step 1: Lentil soup on the robot without thermometers, estimates allowed: heating, sauteing, boiling and simmering are verified by model.
withModel = c.dry_run(recipe_id="lentil-soup", device_id="demo-hob-robot-basic", human_present=True, allow_model=True)
assert pick(withModel, "state") == "accepted", pick(withModel, "state")
print("ok", "state", "=", "accepted")
assert pick(withModel, "plan[3].node") == "n4", pick(withModel, "plan[3].node")
print("ok", "plan[3].node", "=", "n4")
assert pick(withModel, "plan[3].rung") == "model", pick(withModel, "plan[3].rung")
print("ok", "plan[3].rung", "=", "model")
assert pick(withModel, "plan[4].rung") == "model", pick(withModel, "plan[4].rung")
print("ok", "plan[4].rung", "=", "model")
assert pick(withModel, "plan[6].rung") == "model", pick(withModel, "plan[6].rung")
print("ok", "plan[6].rung", "=", "model")
assert pick(withModel, "plan[9].rung") == "model", pick(withModel, "plan[9].rung")
print("ok", "plan[9].rung", "=", "model")
# Step 2: Estimates forbidden: heating and sauteing fall to the person present; boiling, simmering and hot holding fall to time.
noModel = c.dry_run(recipe_id="lentil-soup", device_id="demo-hob-robot-basic", human_present=True, allow_model=False)
assert pick(noModel, "state") == "accepted", pick(noModel, "state")
print("ok", "state", "=", "accepted")
assert pick(noModel, "plan[3].rung") == "human", pick(noModel, "plan[3].rung")
print("ok", "plan[3].rung", "=", "human")
assert pick(noModel, "plan[4].rung") == "human", pick(noModel, "plan[4].rung")
print("ok", "plan[4].rung", "=", "human")
assert pick(noModel, "plan[6].rung") == "time", pick(noModel, "plan[6].rung")
print("ok", "plan[6].rung", "=", "time")
assert pick(noModel, "plan[9].rung") == "time", pick(noModel, "plan[9].rung")
print("ok", "plan[9].rung", "=", "time")
# Step 3: The robot with thermometers never needs the estimate: every heat step has a sensor.
sensors = c.dry_run(recipe_id="lentil-soup", device_id="demo-hob-robot", human_present=True, allow_model=False)
assert pick(sensors, "state") == "accepted", pick(sensors, "state")
print("ok", "state", "=", "accepted")
assert pick(sensors, "plan[3].rung") == "cw.sense.pan_surface_temp", pick(sensors, "plan[3].rung")
print("ok", "plan[3].rung", "=", "cw.sense.pan_surface_temp")
assert pick(sensors, "plan[6].rung") == "cw.sense.liquid_temp", pick(sensors, "plan[6].rung")
print("ok", "plan[6].rung", "=", "cw.sense.liquid_temp")
assert pick(sensors, "plan[9].rung") == "cw.sense.core_temp", pick(sensors, "plan[9].rung")
print("ok", "plan[9].rung", "=", "cw.sense.core_temp")
# Step 4: Both runs on the basic robot are accepted with eleven steps; only the verification differs.
assert pick(withModel, "plan.length") == 11, pick(withModel, "plan.length")
print("ok", "plan.length", "=", 11)
assert pick(noModel, "plan.length") == 11, pick(noModel, "plan.length")
print("ok", "plan.length", "=", 11)
print("scenario complete")