{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://adasengineer.com/schemas/adas-scenario-v1.json",
  "title": "ADASEngineer educational scenario version 1",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "metadata": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,39}$",
          "maxLength": 40
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "description": {
          "type": "string",
          "maxLength": 1000
        },
        "duration": {
          "type": "number",
          "minimum": 1,
          "maximum": 120,
          "multipleOf": 0.02
        }
      },
      "required": [
        "id",
        "name",
        "description",
        "duration"
      ],
      "additionalProperties": false
    },
    "environment": {
      "type": "object",
      "properties": {
        "type": {
          "enum": [
            "straight",
            "multi-lane",
            "intersection",
            "parking"
          ]
        },
        "laneCount": {
          "type": "integer",
          "minimum": 1,
          "maximum": 6
        },
        "laneWidth": {
          "type": "number",
          "minimum": 2.5,
          "maximum": 5
        },
        "intersectionX": {
          "type": "number",
          "minimum": -150,
          "maximum": 150
        }
      },
      "required": [
        "type",
        "laneCount",
        "laneWidth",
        "intersectionX"
      ],
      "additionalProperties": false
    },
    "ego": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,39}$",
          "maxLength": 40
        },
        "kind": {
          "enum": [
            "ego",
            "car",
            "truck",
            "pedestrian",
            "cyclist",
            "obstacle",
            "traffic-sign"
          ]
        },
        "position": {
          "type": "object",
          "properties": {
            "x": {
              "type": "number",
              "minimum": -200,
              "maximum": 200
            },
            "y": {
              "type": "number",
              "minimum": -200,
              "maximum": 200
            }
          },
          "required": [
            "x",
            "y"
          ],
          "additionalProperties": false
        },
        "heading": {
          "type": "number",
          "minimum": -3.141592653589793,
          "maximum": 3.141592653589793
        },
        "speed": {
          "type": "number",
          "minimum": 0,
          "maximum": 45
        },
        "startTime": {
          "type": "number",
          "minimum": 0,
          "maximum": 120,
          "multipleOf": 0.02
        },
        "behavior": {
          "enum": [
            "constant-speed",
            "stationary",
            "brake"
          ]
        },
        "signLabel": {
          "type": "string",
          "minLength": 1,
          "maxLength": 12
        }
      },
      "required": [
        "id",
        "kind",
        "position",
        "heading",
        "speed",
        "startTime",
        "behavior",
        "signLabel"
      ],
      "additionalProperties": false
    },
    "actors": {
      "type": "array",
      "maxItems": 30,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,39}$",
            "maxLength": 40
          },
          "kind": {
            "enum": [
              "ego",
              "car",
              "truck",
              "pedestrian",
              "cyclist",
              "obstacle",
              "traffic-sign"
            ]
          },
          "position": {
            "type": "object",
            "properties": {
              "x": {
                "type": "number",
                "minimum": -200,
                "maximum": 200
              },
              "y": {
                "type": "number",
                "minimum": -200,
                "maximum": 200
              }
            },
            "required": [
              "x",
              "y"
            ],
            "additionalProperties": false
          },
          "heading": {
            "type": "number",
            "minimum": -3.141592653589793,
            "maximum": 3.141592653589793
          },
          "speed": {
            "type": "number",
            "minimum": 0,
            "maximum": 45
          },
          "startTime": {
            "type": "number",
            "minimum": 0,
            "maximum": 120,
            "multipleOf": 0.02
          },
          "behavior": {
            "enum": [
              "constant-speed",
              "stationary",
              "brake"
            ]
          },
          "signLabel": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12
          }
        },
        "required": [
          "id",
          "kind",
          "position",
          "heading",
          "speed",
          "startTime",
          "behavior",
          "signLabel"
        ],
        "additionalProperties": false
      }
    },
    "sensors": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "object",
          "properties": {
            "radar": {
              "type": "boolean"
            },
            "camera": {
              "type": "boolean"
            }
          },
          "required": [
            "radar",
            "camera"
          ],
          "additionalProperties": false
        },
        "radar": {
          "type": "object",
          "properties": {
            "maxRange": {
              "type": "number",
              "minimum": 10,
              "maximum": 200
            },
            "horizontalFov": {
              "type": "number",
              "minimum": 0.17453292519943295,
              "maximum": 2.0943951023931953
            },
            "rangeAccuracy": {
              "type": "number",
              "minimum": 0,
              "maximum": 5
            },
            "rangeRateAccuracy": {
              "type": "number",
              "minimum": 0,
              "maximum": 2
            },
            "updateFrequency": {
              "type": "number",
              "minimum": 1,
              "maximum": 50
            },
            "detectionProbability": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "noiseEnabled": {
              "type": "boolean"
            }
          },
          "required": [
            "maxRange",
            "horizontalFov",
            "rangeAccuracy",
            "rangeRateAccuracy",
            "updateFrequency",
            "detectionProbability",
            "noiseEnabled"
          ],
          "additionalProperties": false
        },
        "camera": {
          "type": "object",
          "properties": {
            "range": {
              "type": "number",
              "minimum": 10,
              "maximum": 150
            },
            "fieldOfView": {
              "type": "number",
              "minimum": 0.5235987755982988,
              "maximum": 2.0943951023931953
            },
            "confidenceThreshold": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "visibilityDegradation": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          },
          "required": [
            "range",
            "fieldOfView",
            "confidenceThreshold",
            "visibilityDegradation"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "enabled",
        "radar",
        "camera"
      ],
      "additionalProperties": false
    },
    "adas": {
      "type": "object",
      "properties": {
        "acc": {
          "type": "boolean"
        },
        "aeb": {
          "type": "boolean"
        },
        "lka": {
          "type": "boolean"
        },
        "targetSpeed": {
          "type": "number",
          "minimum": 0,
          "maximum": 45
        },
        "timeHeadway": {
          "type": "number",
          "minimum": 0.8,
          "maximum": 3.5
        },
        "minimumDistance": {
          "type": "number",
          "minimum": 2,
          "maximum": 15
        }
      },
      "required": [
        "acc",
        "aeb",
        "lka",
        "targetSpeed",
        "timeHeadway",
        "minimumDistance"
      ],
      "additionalProperties": false
    },
    "events": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "time": {
                "type": "number",
                "minimum": 0,
                "maximum": 120,
                "multipleOf": 0.02
              },
              "type": {
                "const": "set-speed"
              },
              "actorId": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,39}$",
                "maxLength": 40
              },
              "value": {
                "type": "number",
                "minimum": 0,
                "maximum": 45
              }
            },
            "required": [
              "time",
              "type",
              "actorId",
              "value"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "time": {
                "type": "number",
                "minimum": 0,
                "maximum": 120,
                "multipleOf": 0.02
              },
              "type": {
                "const": "set-heading"
              },
              "actorId": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,39}$",
                "maxLength": 40
              },
              "value": {
                "type": "number",
                "minimum": -3.141592653589793,
                "maximum": 3.141592653589793
              }
            },
            "required": [
              "time",
              "type",
              "actorId",
              "value"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "time": {
                "type": "number",
                "minimum": 0,
                "maximum": 120,
                "multipleOf": 0.02
              },
              "type": {
                "const": "set-behavior"
              },
              "actorId": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,39}$",
                "maxLength": 40
              },
              "value": {
                "enum": [
                  "constant-speed",
                  "stationary",
                  "brake"
                ]
              }
            },
            "required": [
              "time",
              "type",
              "actorId",
              "value"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "time": {
                "type": "number",
                "minimum": 0,
                "maximum": 120,
                "multipleOf": 0.02
              },
              "type": {
                "const": "sensor-enable"
              },
              "sensor": {
                "enum": [
                  "radar",
                  "camera"
                ]
              },
              "value": {
                "type": "boolean"
              }
            },
            "required": [
              "time",
              "type",
              "sensor",
              "value"
            ],
            "additionalProperties": false
          }
        ]
      }
    }
  },
  "required": [
    "schemaVersion",
    "metadata",
    "environment",
    "ego",
    "actors",
    "sensors",
    "adas",
    "events"
  ],
  "additionalProperties": false
}
