# FactoryBench Knowledge Graph — Schema `knowledge_graph.json` bundles the structured "world model" that grounds FactoryBench Q&A items: machine and gripper capabilities, the task/event vocabulary, the fault catalogue, and the operator-facing remediation protocols. The prompt builders and answer-derivation code consult these tables to (a) inject relevant context into prompts and (b) generate ground-truth answers for L4 troubleshooting items. The file is a single JSON object with a top-level `$schema_version` and a `description`, plus the ten sections below. Every section value is either a `list` of records or a `dict`. ## machines (list) Robot arms used as test platforms. One entry per physical machine class. | Field | Type | Notes | |-------|------|-------| | `machine_id` | int | Stable id referenced by `datasets[*].machine_id`. | | `machine_model` | str | Vendor model code (e.g. `"UR3e"`). | | `manufacturer`, `series` | str | Vendor metadata. | | `machine_type` | str | E.g. `"collaborative robot"`. | | `weight_kg`, `payload_kg`, `degrees_of_freedom` | num | Physical specs. | | `joint_rotation` | list[num] | Per-joint rotation limits. | | `typical_applications` | list[str] | Free-text capability tags. | | `control_interfaces` | list[str] | E.g. `["UrScript", "PolyScope"]`. | | `joint_speed_limits`, `rated_current_per_joint` | list[num] | Per-joint maxima. | | `safety_modes`, `joint_modes`, `robot_modes`, `runtime_states` | list[obj] | Enum tables (id ↔ human-readable label). | | `used_in_paper_for` | list[str] | Datasets/tasks this machine appears in. | ## grippers (list) End-effectors. One entry per gripper class. | Field | Type | Notes | |-------|------|-------| | `gripper_id` | int | Stable id referenced by `datasets[*].gripper_id`. | | `gripper_model`, `manufacturer`, `gripper_type`, `actuation` | str | Vendor metadata. | | `finger_count`, `weight_kg`, `payload_kg`, `payload_kg_form_fit` | num | Physical specs. | | `grip_force_range_N`, `torque_range_Nm`, `max_stroke_mm`, `opening_range_mm` | obj/list | Force/motion ranges. | ## datasets (list) The four episode collections that make up FactoryWave. One entry per (machine, gripper, task) combination. | Field | Type | Notes | |-------|------|-------| | `dataset_id` | str | E.g. `"factorywave"`, `"aursad"`, `"vorausad"`. | | `name`, `description` | str | Human-facing label. | | `machine_id`, `gripper_id` | int | FK into `machines` / `grippers`. | | `task_id` | int | FK into `tasks`. | | `source` | str | URL or citation. | | `license` | str | | ## tasks (list) Task-level vocabulary: each task is a sequence of named phases the robot moves through. | Field | Type | Notes | |-------|------|-------| | `id` | int | Stable id referenced by `datasets[*].task_id` and used in `relevance_specs`. | | `name`, `description` | str | E.g. `"pick_and_place"`. | | `phases` | list[obj] | Ordered phase descriptors (id, name, intent). Used by phase-gated relevance sampling. | ## events (list) Atomic events that can occur during a task (e.g. collision triggers, gripper transitions, screwdriver phase changes). | Field | Type | Notes | |-------|------|-------| | `id` | int | Stable event id encoded in episode rows under `event`. | | `name`, `description` | str | | | `tasks` | list[int] | Tasks where this event can occur. | | `variables` | list[obj] | Per-event observable variables and their ranges. | ## root_causes (list) Catalogue of injectable fault mechanisms. The "physics" side of a fault. | Field | Type | Notes | |-------|------|-------| | `fault_id` | int | Stable id used in episode-level `fault_label`. Also the FK from `root_cause_error_mapping`. | | `task` | str | Which task this fault applies to. | | `root_cause` | str | Snake-case identifier (e.g. `"collision_rigid_object"`). FK from `root_cause_error_mapping[*].root_cause`. | | `description` | str | Plain-language explanation. | | `severity_levels` | list[obj] | Mild / moderate / severe variants and their parameters. | | `injectable` | bool | Whether the fault was actively injected (vs. passively observed). | | `possible_anomalies` | list[str] | FK into `anomalies[*].anomaly_name`. | | `simulation_procedure` | str | How to reproduce the fault. | | `datasets` | list[str] | FK into `datasets[*].dataset_id`. | ## anomalies (list) Catalogue of *observable* symptoms (the "phenomenology" side of a fault). | Field | Type | Notes | |-------|------|-------| | `anomaly_name` | str | Snake-case identifier (e.g. `"sudden_torque_spike"`). | | `description` | str | What the anomaly looks like in the data. | | `relevant_features_from_schema` | list[str] | Which channels (`feedback_speed_*`, `effort_target_torque_*`, etc.) the anomaly manifests on. | A single fault can manifest as multiple anomalies, and a single anomaly can be caused by multiple faults — the join is via `root_causes[*].possible_anomalies`. ## root_cause_error_mapping (list) The error-to-protocol table. Maps each `fault_id` / `root_cause` to the UR3 controller error it raises (when any) and the operator-facing remediation protocol. | Field | Type | Notes | |-------|------|-------| | `fault_id` | int | FK into `root_causes`. | | `root_cause` | str | Mirror of `root_causes[*].root_cause` (denormalised for direct lookup). | | `ur3_error_code` | str / null | UR3 controller error code (e.g. `"C 39 A 1"`), `null` for software-only faults. | | `ur3_error_name` | str / null | Human-readable error name as shown on the teach pendant. | | `ur3_description` | str / null | What the controller reports to the operator. | | `ur3_protocol` | str | Step-by-step remediation procedure. **This is the ground-truth answer for L4 troubleshooting items.** | ## anomaly_ranking (dict) Severity ordering of anomalies, used by the rubric scorer. | Field | Type | Notes | |-------|------|-------| | `ranking_least_to_most_severe` | list[str] | Anomaly names in ascending severity. | ## relevance_specs (dict) Drives fault-aware sub-series sampling — i.e. picking a window where the fault's signature is observable rather than uniformly random. See `src/question_generation/utils/relevance.py`. | Field | Type | Notes | |-------|------|-------| | `version` | str | Spec version. | | `description` | str | Human-facing summary. | | `locality_definitions` | dict | The four sampling localities: `global` (uniform), `event` (window must contain transient), `phase_gated` (window must overlap target task phase), `cumulative` (length-based with optional phase gate). | | `defaults` | dict | Per-locality default parameters merged into each spec. | | `specs` | dict | Per-`fault_id` overrides. Keys are stringified fault ids; values declare locality, target phases, min window length, etc. | Set `FB_RELEVANCE=0` in the environment to bypass and fall back to uniform sampling. ## Loading ```python import json, urllib.request URL = "https://huggingface.co/datasets/FactoryBench/FactoryBench/resolve/main/knowledge_graph/knowledge_graph.json" kg = json.loads(urllib.request.urlopen(URL).read()) # Machine spec lookup by id machines_by_id = {m["machine_id"]: m for m in kg["machines"]} # Error→protocol lookup protocol_for = {e["root_cause"]: e["ur3_protocol"] for e in kg["root_cause_error_mapping"]} print(protocol_for["collision_rigid_object"]) ```