Esta página foi traduzida por máquina e ainda não foi revisada por uma pessoa. O inglês é a referência; correções são bem-vindas no GitHub. GitHub

Cookwala / SDK e cenários / 053

Read what the reference hub claims to conform to

A device publishes its conformance claim with a pointer to a report. The reference hub claims the executor class, self-declared, with no report attached; its capability document and safety-limits pack say the same about what it is.

Público: certifier · Objetivo: Robôs para pessoas · Nível: beginner

Leia primeiro: /docs/CORE/ /docs/HUB/

Passos

  1. One claim, executor, and no report: the hub says so itself rather than implying a certification. conformance

  2. The capability document lists the same role and a self-declared ISO 10218-1 certification entry. capabilities

  3. The safety-limits pack is the draft default; its status field says draft and its disclaimer says makers must replace it. safetyLimits

Resultado

You can read a claim and tell self-declaration from a report. Next: scenario 054 checks signatures, which is how a report would be trusted.

Linha de comando

cookwala hub --recipes examples --speed 200
curl -s http://localhost:7878/v1/conformance
curl -s http://localhost:7878/v1/capabilities
cookwala conformance

Saída gravada

Status: ok

[1] conformance: {"claims": ["executor"], "report": null, "note": "reference hub, self-declared; run tools/run_conformance.py --report"}
[2] capabilities: {"cookwala": "0.1.0", "actor": {"kind": "robot", "id": "robot:arm-1", "vendor": "Example Robotics", "model": "CounterArm 2"}, "roles": ["executor"], "location": {"zone": "counter-left", "mobile": false}, "capabilities": {"ops": [{"op": "cw.op.cut", "params": {"shape": ["dice", "slice", "mince", "julienne"]}, "ingredientClasses": ["cw.ing.class.vegetable_firm", "cw.ing.class.herb"], "reliability": 0.97}, {"op": "cw.op.crack", "reliability": 0.95}, {"op": "cw.op.transfer", "maxMassG": 3000}], "sensors": [{"sensor": "cw.sense.vision", "visionCues": ["cw.sense.translucent", "cw.sense.egg_whites_se…
[3] safetyLimits: {"core": "0.2.0", "kind": "SafetyLimits", "id": "cookwala-default", "version": "0.2.0", "status": "draft", "limits": [{"id": "oil.max_temp", "kind": "max_temp", "action": "cut_heat", "message": "Cut heat above 200 °C: most cooking oils smoke and fire risk rises.", "source": "Common frying-oil smoke points; fire-safety practice", "appliesTo": {"medium": "oil", "ops": ["cw.op.fry", "cw.op.deep_fry"]}, "max": 200, "unit": "degC"}, {"id": "pan.max_surface", "kind": "max_temp", "action": "cut_heat", "message": "Cut heat above 280 °C pan surface (coatings degrade, oil ignites).", "source": "Cookware…

Código

Executar: python scenarios/out/053-the-reference-hubs-conformance-claim/python.py

# Scenario 053: Read what the reference hub claims to conform to
# A device publishes its conformance claim with a pointer to a report. The reference hub claims the executor class, self-declared, with no report attached; its capability document and safety-limits pack say the same about what it is.
# 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: One claim, executor, and no report: the hub says so itself rather than implying a certification.
claim = c.conformance()
assert pick(claim, "claims.length") == 1, pick(claim, "claims.length")
print("ok", "claims.length", "=", 1)
assert pick(claim, "claims[0]") == "executor", pick(claim, "claims[0]")
print("ok", "claims[0]", "=", "executor")
assert pick(claim, "report") == None, pick(claim, "report")
print("ok", "report", "=", None)

# Step 2: The capability document lists the same role and a self-declared ISO 10218-1 certification entry.
caps = c.capabilities()
assert pick(caps, "roles[0]") == "executor", pick(caps, "roles[0]")
print("ok", "roles[0]", "=", "executor")
assert pick(caps, "safety.certifications[0].selfDeclared") == True, pick(caps, "safety.certifications[0].selfDeclared")
print("ok", "safety.certifications[0].selfDeclared", "=", True)

# Step 3: The safety-limits pack is the draft default; its status field says draft and its disclaimer says makers must replace it.
limits = c.safety_limits()
assert pick(limits, "id") == "cookwala-default", pick(limits, "id")
print("ok", "id", "=", "cookwala-default")
assert pick(limits, "version") == "0.2.0", pick(limits, "version")
print("ok", "version", "=", "0.2.0")
assert pick(limits, "status") == "draft", pick(limits, "status")
print("ok", "status", "=", "draft")

print("scenario complete")

scenarios/053-the-reference-hubs-conformance-claim.json

Anterior: 052 Próximo: 054