From dba58168d5d37b14fbe08ff624f86ee129aab67f Mon Sep 17 00:00:00 2001 From: Ali Ekber Celik Date: Mon, 2 Nov 2026 14:23:41 +0100 Subject: [PATCH] add json schemas for topics and services based on json data --- .../cleanup_application.response.schema.json | 37 ++ schema/get_variables.response.schema.json | 40 ++ schema/global_variable_update.schema.json | 80 ++++ schema/modbus_client_signals.schema.json | 411 ++++++++++++++++++ .../set_shared_variables.request.schema.json | 118 +++++ schema/shared_variable_update.schema.json | 45 ++ schema/variable_value.schema.json | 161 +++++++ 7 files changed, 892 insertions(+) create mode 100644 schema/cleanup_application.response.schema.json create mode 100644 schema/get_variables.response.schema.json create mode 100644 schema/global_variable_update.schema.json create mode 100644 schema/modbus_client_signals.schema.json create mode 100644 schema/set_shared_variables.request.schema.json create mode 100644 schema/shared_variable_update.schema.json create mode 100644 schema/variable_value.schema.json diff --git a/schema/cleanup_application.response.schema.json b/schema/cleanup_application.response.schema.json new file mode 100644 index 0000000..6e03938 --- /dev/null +++ b/schema/cleanup_application.response.schema.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "cleanup_application.response.schema.json", + "title": "cleanup_application response", + "description": "JSON payload of the `cleanup_application` service response, found in `response.data.json_string.data` of the `urinterfaces/srv/VariablesViewer` service. The request is empty.\n\nThe service stops all programs and clears the shared variables. The response contains the shared variables as they were before they were cleared, or an error object if the cleanup failed. Some failures (for example a timeout while stopping the programs) are returned as plain text instead of JSON.", + "oneOf": [ + { + "$ref": "shared_variable_update.schema.json" + }, + { + "$ref": "#/$defs/Error" + } + ], + "$defs": { + "Error": { + "type": "object", + "description": "Returned instead of a variable update when the request failed.", + "required": [ + "error" + ], + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + } + } + } + }, + "examples": [ + { + "update_type": "full", + "shared_variables": { + "counter": 123 + } + } + ] +} diff --git a/schema/get_variables.response.schema.json b/schema/get_variables.response.schema.json new file mode 100644 index 0000000..a5e4295 --- /dev/null +++ b/schema/get_variables.response.schema.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "get_variables.response.schema.json", + "title": "get_variables response", + "description": "JSON payload of the `get_variables` service response, found in `response.data.json_string.data` of the `urinterfaces/srv/VariablesViewer` service. The request is empty.\n\nThe response contains all shared variables, or an error object if the variables could not be read, for example because a second request was made within 500 ms.", + "oneOf": [ + { + "$ref": "shared_variable_update.schema.json" + }, + { + "$ref": "#/$defs/Error" + } + ], + "$defs": { + "Error": { + "type": "object", + "description": "Returned instead of a variable update when the request failed.", + "required": [ + "error" + ], + "additionalProperties": false, + "properties": { + "error": { + "type": "string" + } + } + } + }, + "examples": [ + { + "update_type": "full", + "shared_variables": { + "counter": 123 + } + }, + { + "error": "Too many requests made" + } + ] +} diff --git a/schema/global_variable_update.schema.json b/schema/global_variable_update.schema.json new file mode 100644 index 0000000..b49c005 --- /dev/null +++ b/schema/global_variable_update.schema.json @@ -0,0 +1,80 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "global_variable_update.schema.json", + "title": "global_variable_update", + "description": "JSON payload of the `global_variable_update` topic, found in `data.json_string.data` of the `urinterfaces/msg/VariableUpdate` message.\n\nThe message contains the global variables of one logic program. A `diff` update with the changed variables is published while the logic program runs. A `full` update with all variables is published when the logic program stops. When the logic program starts, a `full` update with `sub_update_type` set to `initial` is published, which lists the names of all global variables with the value null.", + "type": "object", + "required": [ + "update_type", + "global_variables" + ], + "additionalProperties": false, + "properties": { + "update_type": { + "enum": [ + "full", + "diff" + ], + "description": "`full` if the message contains all global variables, `diff` if it only contains the changed ones." + }, + "global_variables": { + "type": "object", + "description": "Contains the id of the logic program and one object with the global variables, named after the logic program.", + "required": [ + "logic_program_id" + ], + "properties": { + "logic_program_id": { + "type": "integer", + "minimum": 1, + "description": "Number of the logic program that the update belongs to." + }, + "sub_update_type": { + "const": "initial", + "description": "Only present in the first update of a started logic program, which contains the variable names only." + }, + "error": { + "const": "incomplete message", + "description": "Present if the update did not fit in the message and is incomplete. When only part of the variables had to be left out, the same `error` entry is added inside the object of the logic program instead, next to the variables that did fit." + } + }, + "additionalProperties": { + "type": "object", + "description": "The global variables of the logic program, as `name: value` pairs. The value is null in the initial update.", + "additionalProperties": { + "anyOf": [ + { + "$ref": "variable_value.schema.json" + }, + { + "type": "null" + } + ] + } + } + } + }, + "examples": [ + { + "update_type": "diff", + "global_variables": { + "logic_program_id": 1, + "my_program": { + "global2": 5, + "global4": 7 + } + } + }, + { + "update_type": "full", + "global_variables": { + "logic_program_id": 1, + "sub_update_type": "initial", + "my_program": { + "global1": null, + "global2": null + } + } + } + ] +} diff --git a/schema/modbus_client_signals.schema.json b/schema/modbus_client_signals.schema.json new file mode 100644 index 0000000..1fec54d --- /dev/null +++ b/schema/modbus_client_signals.schema.json @@ -0,0 +1,411 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "modbus_client_signals.schema.json", + "title": "modbus_client_signals", + "description": "JSON payload of the `modbus_client_signals` topic, found in `data.json_string.data` of the `urinterfaces/msg/VariableUpdate` message.\n\nDiagnostics snapshot of every configured MODBUS client unit and signal. The topic is published every 500 ms with best effort reliability and volatile durability. Every message is a full snapshot. Each unit and signal splits its fields into `configuration` (what the user set), `state` (the current live reading) and `statistics` (counters and timings).\n\nA unit is one TCP endpoint. It is identified by its address. If the address was given without a port, the default port 502 is added, so `1.2.3.4` and `1.2.3.4:502` are the same unit. Signals configured with the same address belong to the same unit. Signal names are unique across all units. Signals for custom commands are not included.\n\nSamples may be dropped and nothing is latched, so a late joiner waits up to one period for the next full snapshot. A subscriber that requests reliable delivery cannot connect to a best effort publisher; `ros2 topic echo` selects a compatible QoS automatically, so pass no explicit `--qos-*` flags: `ros2 topic echo --full-length --field data.json_string.data //modbus_client_signals`.", + "type": "object", + "required": [ + "version", + "update_type", + "units" + ], + "additionalProperties": false, + "properties": { + "version": { + "type": "integer", + "const": 1, + "description": "Version of the payload format. It is increased whenever the payload changes in a way that existing consumers cannot ignore, so a consumer can recognise a payload it cannot parse." + }, + "update_type": { + "type": "string", + "const": "full", + "description": "Always `full`: the complete unit and signal list is sent every time." + }, + "units": { + "type": "array", + "description": "One entry per configured TCP endpoint. Empty when no MODBUS signals exist.", + "items": { + "$ref": "#/$defs/ModbusUnit" + } + } + }, + "$defs": { + "ModbusUnit": { + "type": "object", + "title": "MODBUS unit (one TCP endpoint)", + "required": [ + "configuration", + "state", + "statistics", + "signals" + ], + "additionalProperties": false, + "properties": { + "configuration": { + "$ref": "#/$defs/UnitConfiguration" + }, + "state": { + "$ref": "#/$defs/UnitState" + }, + "statistics": { + "$ref": "#/$defs/UnitStatistics" + }, + "signals": { + "type": "array", + "description": "Every non-custom-command signal configured on this unit.", + "items": { + "$ref": "#/$defs/ModbusSignal" + } + } + } + }, + "UnitConfiguration": { + "type": "object", + "required": [ + "ip", + "port", + "sequential_mode" + ], + "additionalProperties": false, + "properties": { + "ip": { + "type": "string", + "description": "Host of the MODBUS server, as configured. This string identifies the unit.", + "examples": [ + "192.168.1.10", + "192.168.1.11" + ] + }, + "port": { + "type": "integer", + "minimum": 0, + "maximum": 65535, + "description": "TCP port of the MODBUS server. 502 unless an explicit `host:port` was configured." + }, + "sequential_mode": { + "type": "boolean", + "description": "When true, the unit keeps only one request outstanding at a time and serves its signals in turn, which limits the update rate of each signal. The flag is set per unit: the last signal added with an explicit value decides for the whole unit." + } + } + }, + "UnitState": { + "type": "object", + "required": [ + "connected" + ], + "additionalProperties": false, + "properties": { + "connected": { + "type": "boolean", + "description": "True while at least one signal on the unit is getting answers from the server, i.e. has `connection_status >= 0`. A Modbus exception reply still counts as connected, because it proves the endpoint is reachable; only `disconnected` (-2) and `connecting` (-1) do not." + } + } + }, + "UnitStatistics": { + "type": "object", + "required": [ + "reconnect_count", + "invalid_packets", + "most_important_error" + ], + "additionalProperties": false, + "properties": { + "reconnect_count": { + "type": "integer", + "minimum": 0, + "description": "Reconnect attempts on this unit's socket since it was created. Monotonic." + }, + "invalid_packets": { + "type": "integer", + "minimum": 0, + "description": "Replies discarded because they could not be matched or parsed. A steadily growing value\npoints at a server that answers but disagrees with the request framing.\n" + }, + "most_important_error": { + "type": "integer", + "description": "POSIX `errno` of the most relevant socket error, or `0` for no error. **Not** a status enum. Use `state.connected` for the connection state; this field is for diagnosing why a connection fails.", + "examples": [ + 0, + 111, + 113 + ] + } + } + }, + "ModbusSignal": { + "type": "object", + "title": "MODBUS signal", + "required": [ + "name", + "configuration", + "state", + "statistics" + ], + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "description": "Signal name as given to `modbus_add_signal`. Unique across the whole controller, not\njust within the unit, so it is a safe consumer-side key.\n", + "examples": [ + "MODBUS_1" + ] + }, + "configuration": { + "$ref": "#/$defs/SignalConfiguration" + }, + "state": { + "$ref": "#/$defs/SignalState" + }, + "statistics": { + "$ref": "#/$defs/SignalStatistics" + } + } + }, + "SignalConfiguration": { + "type": "object", + "required": [ + "type", + "slave_number", + "read_address", + "write_address", + "read_register_count", + "write_register_count", + "update_frequency", + "runstate_choice", + "watchdog_timeout_s" + ], + "additionalProperties": false, + "properties": { + "type": { + "type": "integer", + "enum": [ + -1, + 0, + 1, + 2, + 3, + 4, + 15, + 16, + 23 + ], + "description": "Signal type. It is also\nthe discriminator for how `state.values` must be read.\n\n* `-1` UNDEFINED\n* `0` DIGITAL_INPUT - reads coils (FC1)\n* `1` DIGITAL_OUTPUT - reads coils (FC1), writes FC5 or FC15\n* `2` REGISTER_INPUT - reads **input** registers (FC4)\n* `3` REGISTER_OUTPUT - reads **holding** registers (FC3), writes FC6 or FC16\n* `4` CUSTOM_COMMAND\n* `15` MULTIPLE_DIGITAL_OUTPUT\n* `16` MULTIPLE_REGISTER_OUTPUT\n* `23` MULTIPLE_REGISTER_IO\n\nTypes 2 and 3 are how input registers and holding registers are distinguished; the\nnumbers 15, 16 and 23 happen to match their Modbus function codes.\n" + }, + "slave_number": { + "type": "integer", + "description": "MODBUS slave (unit) address inside the server. 255 when unused." + }, + "read_address": { + "type": "integer", + "description": "Address of the first coil or register read by this signal." + }, + "write_address": { + "type": "integer", + "description": "Address of the first coil or register written by this signal. 0 for input types." + }, + "read_register_count": { + "type": "integer", + "minimum": 1, + "maximum": 255, + "description": "Number of coils or registers per read request, and therefore the length of `state.values`. At least 1." + }, + "write_register_count": { + "type": "integer", + "minimum": 1, + "maximum": 255, + "description": "Number of coils or registers per write request. Never below 1, also for signals that are never written. A single-register write (FC5/FC6) is used when this is 1, a multi-write (FC15/FC16) above that." + }, + "update_frequency": { + "type": "integer", + "description": "Requested polling rate in Hz, as set by `modbus_set_signal_update_frequency` (default 10). `0` or `-1` mean **inactive**: the signal is only polled when a running program asks for it. The achieved rate can be lower, for example in `sequential_mode`; compare against `statistics.average_update_frequency` for what is actually happening.", + "minimum": -32768, + "maximum": 32767 + }, + "runstate_choice": { + "type": "integer", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "description": "What an output signal does when program or drive-power state changes.\n\n* `0` PRESERVE_STATE - never driven by runstate\n* `1` SET_LOW_AT_PROGRAM_STOP\n* `2` SET_HIGH_AT_PROGRAM_STOP\n* `3` REFLECT_PROGRAM_STATE\n* `4` LOW_WHILE_ABORTED\n* `5` REFLECT_ABORTED_STATE\n* `6` REFLECT_DRIVE_POWER_STATE - high while drive power is on\n* `7` LOW_WHILE_DRIVE_POWER - low while drive power is on, high otherwise\n\nOnly meaningful for output types; input signals report `0`.\n" + }, + "watchdog_timeout_s": { + "type": "number", + "description": "Watchdog timeout in **seconds** configured for the signal. It decides how long connection and device errors on this signal stay muted before they are reported to the program: while `connection_status` is not `0`, errors are suppressed until the signal has been invalid for longer than this.\n\n* negative (`-2`) - no watchdog has been set, which is the default\n* `0` - nothing is muted, errors are reported immediately\n* positive - seconds to mute\n\nOnly the watchdog set by the main program is reported. A watchdog set by a logic program does not show up here." + } + } + }, + "SignalState": { + "type": "object", + "required": [ + "values", + "valid", + "connection_status" + ], + "additionalProperties": false, + "properties": { + "values": { + "type": [ + "array", + "null" + ], + "items": { + "type": "integer" + }, + "description": "Last known values, `read_register_count` elements long, or `null` when `valid` is\n`false`. The elements are **untyped integers**; `configuration.type` tells the consumer\nhow to read them, because digital and register values share one array.\n\n* digital types (`0`, `1`, `15`) - each element is a coil, always exactly `0` or `1`,\n render as boolean\n* register types (`2`, `3`, `16`, `23`) - each element is an unsigned 16-bit register\n widened to int32, so the range is `0..65535`, render as a number\n\n`null` means there is no live reading to show right now - either no reply has ever been\nreceived, or the server has since become unreachable / started answering with an\nexception. Consumers must check `valid` before trusting `values`; the controller never\nemits a stale or placeholder array once a signal has stopped being valid.\n", + "examples": [ + [ + 1, + 2, + 3 + ], + [ + 0, + 1 + ], + null + ] + }, + "valid": { + "type": "boolean", + "description": "Whether `values` is currently a live reading. True only when the signal has received at\nleast one reply **and** `connection_status` is `0`. It is false before the first reply,\nand it goes false again while the server is unreachable or answering with an exception;\nin both cases `values` is `null` rather than showing a leftover reading.\n" + }, + "connection_status": { + "type": "integer", + "description": "Per-signal connection state. Negative and\nzero values are defined by UR, positive values are Modbus exception codes returned by\nthe server - which means any value `>= 0` proves the server answered.\n\n* `-2` DISCONNECTED\n* `-1` CONNECTING - also the initial value for a freshly added signal\n* `0` CONNECTION_OK\n* `1` EXCEPTION_ILLEGAL_FUNCTION_CODE\n* `2` EXCEPTION_ILLEGAL_DATA_ACCESS\n* `3` EXCEPTION_ILLEGAL_DATA_VALUE\n* `4` EXCEPTION_SERVER_FAILURE\n* `5` EXCEPTION_ACKNOWLEDGE\n* `6` EXCEPTION_SERVER_BUSY\n* `10` EXCEPTION_GATEWAY_PROBLEM - gateway path not available\n* `11` EXCEPTION_GATEWAY_PROBLEM_TARGET_FAILURE\n\nThe value is the exception code as the server sent it, so a server can also report a code that is not listed here. Only the values above have a defined meaning.\n", + "minimum": -128, + "maximum": 127 + } + } + }, + "SignalStatistics": { + "type": "object", + "required": [ + "response_time_ms", + "time_since_last_update_ms", + "failed_requests_cnt", + "response_timeouts_cnt", + "average_update_frequency" + ], + "additionalProperties": false, + "properties": { + "response_time_ms": { + "type": "integer", + "minimum": 0, + "description": "Latency of the most recent request/reply pair, measured in steps of 2 ms, so `2` is the smallest value rather than a real 2 ms round trip. Only written when a reply arrives, so it **freezes** at the last measured value when communication stops - it does not fall back to 0." + }, + "time_since_last_update_ms": { + "type": "integer", + "minimum": 0, + "description": "Milliseconds since the last reply. This is the field to watch for staleness: it keeps\ngrowing without bound while the server is silent, whereas `response_time_ms` and\n`average_update_frequency` freeze.\n" + }, + "failed_requests_cnt": { + "type": "integer", + "minimum": 0, + "maximum": 65535, + "description": "Requests that could not be sent, counted since the signal was added. 16-bit, wraps." + }, + "response_timeouts_cnt": { + "type": "integer", + "minimum": 0, + "maximum": 65535, + "description": "Requests that were sent but never answered within the 2 s communication timeout,\ncounted since the signal was added. 16-bit, wraps.\n" + }, + "average_update_frequency": { + "type": "number", + "description": "Observed reply rate in Hz, as an exponential moving average with weight 0.2 on the newest\ninterval. `-1` until enough replies have arrived to measure an interval. Freezes at the\nlast value when communication stops. Compare against\n`configuration.update_frequency` to see whether the signal keeps up with its request.\n", + "examples": [ + 9.8, + -1 + ] + } + } + } + }, + "examples": [ + { + "version": 1, + "update_type": "full", + "units": [ + { + "configuration": { + "ip": "192.168.1.10", + "port": 502, + "sequential_mode": true + }, + "state": { + "connected": true + }, + "statistics": { + "reconnect_count": 0, + "invalid_packets": 0, + "most_important_error": 0 + }, + "signals": [ + { + "name": "MODBUS_1", + "configuration": { + "type": 2, + "slave_number": 255, + "read_address": 0, + "write_address": 0, + "read_register_count": 3, + "write_register_count": 1, + "update_frequency": 10, + "runstate_choice": 0, + "watchdog_timeout_s": 1.5 + }, + "state": { + "values": [ + 1, + 2, + 3 + ], + "valid": true, + "connection_status": 0 + }, + "statistics": { + "response_time_ms": 3, + "time_since_last_update_ms": 100, + "failed_requests_cnt": 0, + "response_timeouts_cnt": 0, + "average_update_frequency": 9.8 + } + }, + { + "name": "MODBUS_2", + "configuration": { + "type": 1, + "slave_number": 255, + "read_address": 0, + "write_address": 1, + "read_register_count": 1, + "write_register_count": 1, + "update_frequency": 10, + "runstate_choice": 0, + "watchdog_timeout_s": -2.0 + }, + "state": { + "values": null, + "valid": false, + "connection_status": -2 + }, + "statistics": { + "response_time_ms": 0, + "time_since_last_update_ms": 5000, + "failed_requests_cnt": 3, + "response_timeouts_cnt": 3, + "average_update_frequency": -1.0 + } + } + ] + } + ] + } + ] +} diff --git a/schema/set_shared_variables.request.schema.json b/schema/set_shared_variables.request.schema.json new file mode 100644 index 0000000..2aa8457 --- /dev/null +++ b/schema/set_shared_variables.request.schema.json @@ -0,0 +1,118 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "set_shared_variables.request.schema.json", + "title": "set_shared_variables request", + "description": "JSON payload of the `set_shared_variables` service request, found in `request.json_string.data` of the `urinterfaces/srv/SharedVariablesEditor` service.\n\nVariables that do not exist are created, existing variables are assigned the new value. A variable set to null is deleted, which stops all running programs. The request is validated before anything is changed: if one value is invalid, no variable is modified. Other keys in the root object are ignored.", + "type": "object", + "required": [ + "shared_variables" + ], + "properties": { + "shared_variables": { + "type": "object", + "description": "The variables to create, modify or delete, as `name: value` pairs.", + "additionalProperties": { + "anyOf": [ + { + "$ref": "#/$defs/Value" + }, + { + "type": "null" + } + ] + } + } + }, + "$defs": { + "Value": { + "description": "A variable value. Structs cannot be set through this service.", + "anyOf": [ + { + "description": "Signed 32 bit integer.", + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + { + "description": "Floating point number. A number with a decimal point or an exponent is stored as a float, other numbers as an int. A whole number outside the 32 bit range is therefore only accepted when it is written as a float (`3e9`), which this schema cannot tell apart from the integer `3000000000`, that is rejected.", + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "string" + }, + { + "type": "array", + "description": "A list, or a matrix when every element is an array.", + "items": { + "$ref": "#/$defs/Value" + } + }, + { + "type": "object", + "description": "Cartesian pose `[x, y, z, rx, ry, rz]`, position in meters and rotation vector in radians.", + "required": [ + "_ur_pose" + ], + "additionalProperties": false, + "properties": { + "_ur_pose": { + "type": "array", + "minItems": 6, + "maxItems": 6, + "items": { + "type": "number" + } + } + } + }, + { + "type": "object", + "description": "A list with a capacity. The capacity must not be smaller than the length of the list. A list whose elements are lists is handled as a matrix and its capacity must then be equal to its length, which this schema does not express.", + "required": [ + "_ur_list", + "_ur_capacity" + ], + "additionalProperties": false, + "properties": { + "_ur_list": { + "type": "array", + "items": { + "$ref": "#/$defs/Value" + } + }, + "_ur_capacity": { + "type": "integer", + "minimum": 0 + } + } + } + ] + } + }, + "examples": [ + { + "shared_variables": { + "counter": 42, + "name": "abc", + "waypoint": { + "_ur_pose": [ + 0.1, + 0.5, + 0, + 3.14, + 0, + 0 + ] + } + } + }, + { + "shared_variables": { + "temperature": null + } + } + ] +} diff --git a/schema/shared_variable_update.schema.json b/schema/shared_variable_update.schema.json new file mode 100644 index 0000000..ae9d841 --- /dev/null +++ b/schema/shared_variable_update.schema.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "shared_variable_update.schema.json", + "title": "shared_variable_update", + "description": "JSON payload of the `shared_variable_update` topic, found in `data.json_string.data` of the `urinterfaces/msg/VariableUpdate` message.\n\nThe message contains all shared (application) variables. It is published periodically, at most every 500 ms.", + "type": "object", + "required": [ + "update_type", + "shared_variables" + ], + "additionalProperties": false, + "properties": { + "update_type": { + "const": "full", + "description": "Always `full`: every message contains all shared variables." + }, + "shared_variables": { + "type": "object", + "description": "All shared (application) variables as `name: value` pairs.", + "additionalProperties": { + "$ref": "variable_value.schema.json" + } + } + }, + "examples": [ + { + "update_type": "full", + "shared_variables": { + "counter": 123, + "name": "abc", + "temperature": 33.334455, + "waypoint": { + "_ur_pose": [ + 0.1, + 0.5, + 0, + 3.14, + 0, + 0 + ] + } + } + } + ] +} diff --git a/schema/variable_value.schema.json b/schema/variable_value.schema.json new file mode 100644 index 0000000..438858f --- /dev/null +++ b/schema/variable_value.schema.json @@ -0,0 +1,161 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "variable_value.schema.json", + "title": "Published variable value", + "description": "The value of one variable as it is published by the controller. Used by `shared_variable_update`, `global_variable_update`, `get_variables` and `cleanup_application`.\n\nAn int and a float are both published as a plain JSON number, and a float with an integral value is published without a decimal point (`1.0` becomes `1`), so a consumer cannot tell the two apart by looking at the number. A list is always an object with the keys `_ur_list` and `_ur_capacity`. A plain array is a matrix, an array of arrays of numbers. A pose is an object with the key `_ur_pose`. A struct is an object with one key per member. Values that cannot be represented as data (for example a function or a thread) are published as an object with a single `_ur_*` key set to null.", + "anyOf": [ + { + "$ref": "#/$defs/Int" + }, + { + "$ref": "#/$defs/Float" + }, + { + "type": "boolean" + }, + { + "type": "string" + }, + { + "$ref": "#/$defs/Matrix" + }, + { + "$ref": "#/$defs/Pose" + }, + { + "$ref": "#/$defs/ListWithCapacity" + }, + { + "$ref": "#/$defs/Placeholder" + }, + { + "$ref": "#/$defs/Struct" + } + ], + "$defs": { + "Int": { + "description": "Signed 32 bit integer.", + "type": "integer", + "minimum": -2147483648, + "maximum": 2147483647 + }, + "Float": { + "description": "Floating point number, published with 8 significant digits. A float with an integral value is published without a decimal point and large magnitudes use exponent notation (`1e+10`), so it can also look like an integer, even one outside the 32 bit range. Not a number and infinity are published as 0.", + "type": "number" + }, + "Matrix": { + "type": "array", + "description": "A matrix, as rows of numbers. Lists are not published as plain arrays, see `ListWithCapacity`.", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + }, + "Pose": { + "type": "object", + "description": "Cartesian pose `[x, y, z, rx, ry, rz]`, position in meters and rotation vector in radians.", + "required": [ + "_ur_pose" + ], + "additionalProperties": false, + "properties": { + "_ur_pose": { + "type": "array", + "minItems": 6, + "maxItems": 6, + "items": { + "type": "number" + } + } + } + }, + "ListWithCapacity": { + "type": "object", + "description": "A list together with its capacity.", + "required": [ + "_ur_list", + "_ur_capacity" + ], + "additionalProperties": false, + "properties": { + "_ur_list": { + "type": "array", + "items": { + "$ref": "#" + } + }, + "_ur_capacity": { + "type": "integer", + "minimum": 0 + } + } + }, + "Placeholder": { + "type": "object", + "description": "A value that has no data representation, for example a function or a thread. It is published as an object with a single `_ur_*` key set to null.", + "minProperties": 1, + "maxProperties": 1, + "propertyNames": { + "pattern": "^_ur_" + }, + "additionalProperties": { + "type": "null" + } + }, + "Struct": { + "type": "object", + "description": "A struct, one entry per member. Member names starting with `_ur_` are reserved for the other value types.", + "propertyNames": { + "not": { + "pattern": "^_ur_" + } + }, + "additionalProperties": { + "$ref": "#" + } + } + }, + "examples": [ + 42, + 1.5, + true, + "abc", + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ] + ], + { + "_ur_pose": [ + 0.1, + 0.5, + 0, + 3.14, + 0, + 0 + ] + }, + { + "_ur_list": [ + 1, + 2, + 3 + ], + "_ur_capacity": 5 + }, + { + "_ur_xmlrpc": null + }, + { + "x": 10, + "name": "item_1" + } + ] +}