Cette page a été traduite par une machine et n'a pas encore été révisée par une personne. L'anglais est la référence ; les corrections sont les bienvenues sur GitHub. GitHub

Cookwala / SDK et scénarios / 024

A saute trace, and why sauteing is never left alone

Sauteing is a pan surface at 150 to 210 degC, with continuous attention and two hazards named in the vocabulary. The trace check is the same as for any envelope; the attention rules are what make a robot ask for a person.

Audience: home cook · Objectif: Des robots pour les gens · Niveau: beginner

Lire d'abord: /docs/CORE/ /docs/QUICKSTART/

Étapes

  1. The pan warms to 165, 180 and 190 degC: inside the band. checkEnvelope

  2. It climbs to 215 degC: that is searing temperature, outside the saute band. checkEnvelope

  3. A pan that reached 140 degC never got hot enough to saute. checkEnvelope

  4. The vocabulary says it may not run unattended, needs continuous attention, and names hot oil burns and pan fire as hazards. getOps

Résultat

You can read a pan log against the band and you know why a robot refuses to saute when nobody is home (scenario 011). Next: scenario 025 shows what happens when a recipe asks for a temperature outside the band.

Ligne de commande

printf '[{"t": 0, "tempC": 120}, {"t": 30, "tempC": 165}, {"t": 60, "tempC": 180}, {"t": 90, "tempC": 190}]' > trace.json && cookwala envelope cw.op.saute trace.json
printf '[{"t": 0, "tempC": 120}, {"t": 30, "tempC": 165}, {"t": 60, "tempC": 200}, {"t": 90, "tempC": 215}]' > trace.json && cookwala envelope cw.op.saute trace.json
curl -s http://localhost:7878/v1/tools/vocab/ops

Sortie enregistrée

Statut: ok

[1] checkEnvelope: {"envelopeOk": true, "targetOk": null, "reason": "ok"}
[2] checkEnvelope: {"envelopeOk": false, "targetOk": null, "reason": "left_envelope"}
[3] checkEnvelope: {"envelopeOk": false, "targetOk": null, "reason": "never_reached_envelope"}
[4] getOps: {"name": "ops", "version": "0.2.0", "entries": [{"id": "cw.op.dispense", "label": {"en": "Dispense / measure", "ar": "قياس وإضافة"}, "definition": "Measure an ingredient by mass, volume or count and add it to a target.", "classes": ["cw.opfamily.handle"], "paramsSchema": {"type": "object", "properties": {"precision": {"type": "number"}}}, "sensors": ["cw.sense.mass"], "links": {"ieee1872": "IEEE 1872.1-2024 Task (to be mapped)"}}, {"id": "cw.op.transfer", "label": {"en": "Transfer", "ar": "نقل"}, "definition": "Move food or a vessel's contents from one place to another.", "classes": ["cw.opfam…

Code

Exécuter: python scenarios/out/024-saute-trace-and-attention/python.py

# Scenario 024: A saute trace, and why sauteing is never left alone
# Sauteing is a pan surface at 150 to 210 degC, with continuous attention and two hazards named in the vocabulary. The trace check is the same as for any envelope; the attention rules are what make a robot ask for a person.
# 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: The pan warms to 165, 180 and 190 degC: inside the band.
ok = c.check_envelope("cw.op.saute", [{"t": 0, "tempC": 120}, {"t": 30, "tempC": 165}, {"t": 60, "tempC": 180}, {"t": 90, "tempC": 190}])
assert pick(ok, "envelopeOk") == True, pick(ok, "envelopeOk")
print("ok", "envelopeOk", "=", True)
assert pick(ok, "reason") == "ok", pick(ok, "reason")
print("ok", "reason", "=", "ok")

# Step 2: It climbs to 215 degC: that is searing temperature, outside the saute band.
hot = c.check_envelope("cw.op.saute", [{"t": 0, "tempC": 120}, {"t": 30, "tempC": 165}, {"t": 60, "tempC": 200}, {"t": 90, "tempC": 215}])
assert pick(hot, "envelopeOk") == False, pick(hot, "envelopeOk")
print("ok", "envelopeOk", "=", False)
assert pick(hot, "reason") == "left_envelope", pick(hot, "reason")
print("ok", "reason", "=", "left_envelope")

# Step 3: A pan that reached 140 degC never got hot enough to saute.
cold = c.check_envelope("cw.op.saute", [{"t": 0, "tempC": 120}, {"t": 30, "tempC": 140}])
assert pick(cold, "envelopeOk") == False, pick(cold, "envelopeOk")
print("ok", "envelopeOk", "=", False)
assert pick(cold, "reason") == "never_reached_envelope", pick(cold, "reason")
print("ok", "reason", "=", "never_reached_envelope")

# Step 4: The vocabulary says it may not run unattended, needs continuous attention, and names hot oil burns and pan fire as hazards.
ops = c.get_ops()
assert pick(ops, "entries[26].id") == "cw.op.saute", pick(ops, "entries[26].id")
print("ok", "entries[26].id", "=", "cw.op.saute")
assert pick(ops, "entries[26].envelope.unattended") == False, pick(ops, "entries[26].envelope.unattended")
print("ok", "entries[26].envelope.unattended", "=", False)
assert pick(ops, "entries[26].envelope.attention") == "continuous", pick(ops, "entries[26].envelope.attention")
print("ok", "entries[26].envelope.attention", "=", "continuous")
assert pick(ops, "entries[26].envelope.hazards[0]") == "cw.hz.burn.hot_oil", pick(ops, "entries[26].envelope.hazards[0]")
print("ok", "entries[26].envelope.hazards[0]", "=", "cw.hz.burn.hot_oil")
assert pick(ops, "entries[26].envelope.hazards[1]") == "cw.hz.fire.pan", pick(ops, "entries[26].envelope.hazards[1]")
print("ok", "entries[26].envelope.hazards[1]", "=", "cw.hz.fire.pan")

print("scenario complete")

scenarios/024-saute-trace-and-attention.json

Précédent: 023 Suivant: 025